├── .devtools └── templates │ └── changelog.erb ├── .github ├── ISSUE_TEMPLATE │ ├── ----please-don-t-ask-for-support-via-issues.md │ ├── ---bug-report.md │ └── ---feature-request.md └── workflows │ └── ci.yml ├── .gitignore ├── .rspec ├── .rubocop.yml ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Gemfile ├── Gemfile.devtools ├── LICENSE ├── README.md ├── Rakefile ├── changelog.yml ├── dry-web.gemspec ├── lib ├── dry-web.rb └── dry │ └── web │ ├── console.rb │ ├── container.rb │ └── version.rb ├── log └── .gitkeep ├── project.yml └── spec ├── fixtures ├── multiple_env_files │ ├── .env │ └── .env.test └── test │ ├── .env.test │ └── log │ └── .gitkeep ├── spec_helper.rb ├── support ├── coverage.rb └── warnings.rb └── unit └── container_spec.rb /.devtools/templates/changelog.erb: -------------------------------------------------------------------------------- 1 | <% releases.each_with_index do |r, idx| %> 2 | ## <%= r.version %> <%= r.date %> 3 | 4 | <% if r.summary %> 5 | <%= r.summary %> 6 | 7 | <% end %> 8 | 9 | <% if r.added? %> 10 | ### Added 11 | 12 | <% r.added.each do |log| %> 13 | - <%= log %> 14 | <% end %> 15 | 16 | <% end %> 17 | <% if r.fixed? %> 18 | ### Fixed 19 | 20 | <% r.fixed.each do |log| %> 21 | - <%= log %> 22 | <% end %> 23 | 24 | <% end %> 25 | <% if r.changed? %> 26 | ### Changed 27 | 28 | <% r.changed.each do |log| %> 29 | - <%= log %> 30 | <% end %> 31 | <% end %> 32 | <% curr_ver = r.date ? "v#{r.version}" : 'master' %> 33 | <% prev_rel = releases[idx + 1] %> 34 | <% if prev_rel %> 35 | <% ver_range = "v#{prev_rel.version}...#{curr_ver}" %> 36 | 37 | [Compare <%=ver_range%>](https://github.com/dry-rb/<%= project.name %>/compare/<%=ver_range%>) 38 | <% end %> 39 | 40 | <% end %> 41 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "⚠️ Please don't ask for support via issues" 3 | about: See CONTRIBUTING.md for more information 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/---bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F41B Bug report" 3 | about: See CONTRIBUTING.md for more information 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Before you submit this: WE ONLY ACCEPT BUG REPORTS AND FEATURE REQUESTS** 11 | 12 | For more information see `CONTRIBUTING.md`. 13 | 14 | **Describe the bug** 15 | 16 | A clear and concise description of what the bug is. 17 | 18 | **To Reproduce** 19 | 20 | Provide detailed steps to reproduce, an executable script would be best. 21 | 22 | **Expected behavior** 23 | 24 | A clear and concise description of what you expected to happen. 25 | 26 | **Your environment** 27 | 28 | - Affects my production application: **YES/NO** 29 | - Ruby version: ... 30 | - OS: ... 31 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/---feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F6E0 Feature request" 3 | about: See CONTRIBUTING.md for more information 4 | title: '' 5 | labels: feature 6 | assignees: '' 7 | 8 | --- 9 | 10 | Summary of what the feature is supposed to do. 11 | 12 | ## Examples 13 | 14 | Code examples showing how the feature could be used. 15 | 16 | ## Resources 17 | 18 | Additional information, like a link to the discussion forum thread where the feature was discussed etc. 19 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | # this file is managed by dry-rb/devtools project 2 | 3 | name: ci 4 | 5 | "on": 6 | push: 7 | paths: 8 | - ".github/workflows/ci.yml" 9 | - "lib/**" 10 | - "*.gemspec" 11 | - "spec/**" 12 | - "Rakefile" 13 | - "Gemfile" 14 | - "Gemfile.devtools" 15 | - ".rubocop.yml" 16 | - "project.yml" 17 | pull_request: 18 | branches: 19 | - master 20 | create: 21 | 22 | jobs: 23 | tests: 24 | runs-on: ubuntu-latest 25 | strategy: 26 | fail-fast: false 27 | matrix: 28 | ruby: 29 | - "2.7.0" 30 | - "2.6" 31 | - "2.5" 32 | - "2.4" 33 | - "jruby" 34 | include: 35 | - ruby: "2.6" 36 | coverage: "true" 37 | env: 38 | COVERAGE: ${{matrix.coverage}} 39 | COVERAGE_TOKEN: ${{secrets.CODACY_PROJECT_TOKEN}} 40 | steps: 41 | - uses: actions/checkout@v1 42 | - name: Install package dependencies 43 | run: "[ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS" 44 | - name: Set up Ruby 45 | uses: ruby/setup-ruby@v1 46 | with: 47 | ruby-version: ${{matrix.ruby}} 48 | - name: Install latest bundler 49 | run: | 50 | gem install bundler --no-document 51 | bundle config set without 'tools benchmarks docs' 52 | - name: Bundle install 53 | run: bundle install --jobs 4 --retry 3 54 | - name: Run all tests 55 | run: bundle exec rake 56 | - name: Run codacy-coverage-reporter 57 | uses: codacy/codacy-coverage-reporter-action@master 58 | if: env.COVERAGE == 'true' && env.COVERAGE_TOKEN != '' 59 | with: 60 | project-token: ${{secrets.CODACY_PROJECT_TOKEN}} 61 | coverage-reports: coverage/coverage.xml 62 | release: 63 | runs-on: ubuntu-latest 64 | if: contains(github.ref, 'tags') && github.event_name == 'create' 65 | needs: tests 66 | env: 67 | GITHUB_LOGIN: dry-bot 68 | GITHUB_TOKEN: ${{secrets.GH_PAT}} 69 | steps: 70 | - uses: actions/checkout@v1 71 | - name: Install package dependencies 72 | run: "[ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS" 73 | - name: Set up Ruby 74 | uses: ruby/setup-ruby@v1 75 | with: 76 | ruby-version: 2.6 77 | - name: Install dependencies 78 | run: gem install ossy --no-document 79 | - name: Trigger release workflow 80 | run: | 81 | tag=$(echo $GITHUB_REF | cut -d / -f 3) 82 | ossy gh w dry-rb/devtools release --payload "{\"tag\":\"$tag\",\"tag_creator\":\"$GITHUB_ACTOR\",\"repo\":\"$GITHUB_REPOSITORY\"}" 83 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | /.config 4 | /coverage/ 5 | /InstalledFiles 6 | /pkg/ 7 | /spec/reports/ 8 | /test/tmp/ 9 | /test/version_tmp/ 10 | /tmp/ 11 | 12 | ## Specific to RubyMotion: 13 | .dat* 14 | .repl_history 15 | build/ 16 | 17 | ## Documentation cache and generated files: 18 | /.yardoc/ 19 | /_yardoc/ 20 | /doc/ 21 | /rdoc/ 22 | 23 | ## Environment normalisation: 24 | /.bundle/ 25 | /lib/bundler/man/ 26 | 27 | # for a library or gem, you might want to ignore these files since the code is 28 | # intended to run in multiple environments; otherwise, check them in: 29 | Gemfile.lock 30 | # .ruby-version 31 | # .ruby-gemset 32 | 33 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: 34 | .rvmrc 35 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --require spec_helper 3 | --order random 4 | --warnings 5 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | # this file is managed by dry-rb/devtools project 2 | 3 | AllCops: 4 | TargetRubyVersion: 2.4 5 | Exclude: 6 | - spec/support/coverage.rb 7 | - spec/support/warnings.rb 8 | - Gemfile.devtools 9 | - "*.gemspec" 10 | 11 | Layout/SpaceAroundMethodCallOperator: 12 | Enabled: false 13 | 14 | Layout/SpaceInLambdaLiteral: 15 | Enabled: false 16 | 17 | Layout/MultilineMethodCallIndentation: 18 | Enabled: true 19 | EnforcedStyle: indented 20 | 21 | Layout/FirstArrayElementIndentation: 22 | EnforcedStyle: consistent 23 | 24 | Layout/SpaceInsideHashLiteralBraces: 25 | Enabled: true 26 | EnforcedStyle: no_space 27 | EnforcedStyleForEmptyBraces: no_space 28 | 29 | Layout/LineLength: 30 | Max: 100 31 | Exclude: 32 | - "spec/**/*_spec.rb" 33 | 34 | Lint/BooleanSymbol: 35 | Enabled: false 36 | 37 | Lint/RaiseException: 38 | Enabled: false 39 | 40 | Lint/StructNewOverride: 41 | Enabled: false 42 | 43 | Lint/SuppressedException: 44 | Exclude: 45 | - "spec/spec_helper.rb" 46 | 47 | Naming/PredicateName: 48 | Enabled: false 49 | 50 | Naming/FileName: 51 | Exclude: 52 | - "lib/*-*.rb" 53 | 54 | Naming/MethodName: 55 | Enabled: false 56 | 57 | Naming/MemoizedInstanceVariableName: 58 | Enabled: false 59 | 60 | Metrics/MethodLength: 61 | Enabled: false 62 | 63 | Metrics/ClassLength: 64 | Enabled: false 65 | 66 | Metrics/BlockLength: 67 | Enabled: false 68 | 69 | Metrics/AbcSize: 70 | Max: 25 71 | 72 | Metrics/CyclomaticComplexity: 73 | Enabled: true 74 | Max: 12 75 | 76 | Style/ExponentialNotation: 77 | Enabled: false 78 | 79 | Style/HashEachMethods: 80 | Enabled: false 81 | 82 | Style/HashTransformKeys: 83 | Enabled: false 84 | 85 | Style/HashTransformValues: 86 | Enabled: false 87 | 88 | Style/AccessModifierDeclarations: 89 | Enabled: false 90 | 91 | Style/Alias: 92 | Enabled: true 93 | EnforcedStyle: prefer_alias_method 94 | 95 | Style/AsciiComments: 96 | Enabled: false 97 | 98 | Style/BlockDelimiters: 99 | Enabled: false 100 | 101 | Style/ClassAndModuleChildren: 102 | Exclude: 103 | - "spec/**/*_spec.rb" 104 | 105 | Style/ConditionalAssignment: 106 | Enabled: false 107 | 108 | Style/DateTime: 109 | Enabled: false 110 | 111 | Style/Documentation: 112 | Enabled: false 113 | 114 | Style/EachWithObject: 115 | Enabled: false 116 | 117 | Style/FormatString: 118 | Enabled: false 119 | 120 | Style/GuardClause: 121 | Enabled: false 122 | 123 | Style/IfUnlessModifier: 124 | Enabled: false 125 | 126 | Style/Lambda: 127 | Enabled: false 128 | 129 | Style/LambdaCall: 130 | Enabled: false 131 | 132 | Style/ParallelAssignment: 133 | Enabled: false 134 | 135 | Style/StabbyLambdaParentheses: 136 | Enabled: false 137 | 138 | Style/StringLiterals: 139 | Enabled: true 140 | EnforcedStyle: double_quotes 141 | ConsistentQuotesInMultiline: false 142 | 143 | Style/StringLiteralsInInterpolation: 144 | Enabled: true 145 | EnforcedStyle: double_quotes 146 | 147 | Style/SymbolArray: 148 | Exclude: 149 | - "spec/**/*_spec.rb" 150 | 151 | Style/TrailingUnderscoreVariable: 152 | Enabled: false 153 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.8.0 2018-01-02 2 | 3 | 4 | ### Changed 5 | 6 | - Updated to `dry-system ~> 0.9` (solnic) 7 | 8 | [Compare v0.7.1...v0.8.0](https://github.com/dry-rb/dry-web/compare/v0.7.1...v0.8.0) 9 | 10 | ## 0.7.1 2017-07-25 11 | 12 | 13 | ### Changed 14 | 15 | - Default log level for `:test` env is set to `Logger::DEBUG` (solnic) 16 | 17 | [Compare v0.7.0...v0.7.1](https://github.com/dry-rb/dry-web/compare/v0.7.0...v0.7.1) 18 | 19 | ## 0.7.0 2017-06-16 20 | 21 | 22 | ### Changed 23 | 24 | - [BREAKING] `Dry::Web::Settings` now loads settings from local `.env` and `.env.` files (GustavoCaso) 25 | - [BREAKING] Removed `Dry::Web::Umbrella` with special handling of settings. Settings should for now be provided as a bootable component within your applications (dry-web-roda will be updated to generate such) (timriley) 26 | 27 | [Compare v0.6.0...v0.7.0](https://github.com/dry-rb/dry-web/compare/v0.6.0...v0.7.0) 28 | 29 | ## 0.6.0 2017-02-02 30 | 31 | 32 | ### Added 33 | 34 | - Support for [dry-monitor](https://github.com/dry-rb/dry-monitor) with notifications and rack logging (solnic) 35 | 36 | 37 | [Compare v0.5.0...v0.6.0](https://github.com/dry-rb/dry-web/compare/v0.5.0...v0.6.0) 38 | 39 | ## 0.5.0 2016-08-15 40 | 41 | Update to work with dry-system 42 | 43 | 44 | [Compare v0.4.1...v0.5.0](https://github.com/dry-rb/dry-web/compare/v0.4.1...v0.5.0) 45 | 46 | ## 0.4.1 2016-07-26 47 | 48 | 49 | ### Changed 50 | 51 | - Set a higher minimum Ruby version (>= 2.1.0) to match dry-auto_inject (timriley) 52 | 53 | [Compare v0.4.0...v0.4.1](https://github.com/dry-rb/dry-web/compare/v0.4.0...v0.4.1) 54 | 55 | ## 0.4.0 2016-07-26 56 | 57 | 58 | ### Changed 59 | 60 | - Require dry-component 0.4.1 for latest `Dry::Component::Container#injector` features and API (timriley) 61 | 62 | [Compare v0.3.1...v0.4.0](https://github.com/dry-rb/dry-web/compare/v0.3.1...v0.4.0) 63 | 64 | ## 0.3.1 2016-06-22 65 | 66 | 67 | ### Changed 68 | 69 | - Added a necessary version spec for the dry-component dependency (timriley) 70 | 71 | [Compare v0.3.0...v0.3.1](https://github.com/dry-rb/dry-web/compare/v0.3.0...v0.3.1) 72 | 73 | ## 0.3.0 2016-06-22 74 | 75 | 76 | ### Added 77 | 78 | - Added an `Umbrella` subclass of `Dry::Web::Container`, intended to be a single, top-level wrapper around multiple sub-apps in a dry-web project (timriley) 79 | - Added `Dry::Web::Settings`, designed to work as an app's single, top-level settings object (timriley) 80 | - Added `env` config to `Dry::Web::Container`, moved across from dry-component (timriley) 81 | 82 | ### Changed 83 | 84 | - Renamed `Dry::Web::Cli` to `Dry::Web::Console`, to make room for a real CLI in the future, starting with dry-web-roda (timriley) 85 | 86 | [Compare v0.2.0...v0.3.0](https://github.com/dry-rb/dry-web/compare/v0.2.0...v0.3.0) 87 | 88 | ## 0.2.0 2016-06-12 89 | 90 | 91 | ### Changed 92 | 93 | - Extracted Roda support into [dry-web-roda](https://github.com/dry-rb/dry-web-roda) (timriley) 94 | - Removed `Dry::Web::Transaction::Composer`, which was offering no value above direct calls to `Dry.Transaction` (timriley) 95 | - Basic skeleton example removed, since skeletons/app generators will soon be provided elsewhere (timriley) 96 | 97 | [Compare v0.1.0...v0.2.0](https://github.com/dry-rb/dry-web/compare/v0.1.0...v0.2.0) 98 | 99 | ## 0.1.0 2016-04-21 100 | 101 | 102 | ### Changed 103 | 104 | - – Renamed from rodakase to dry-web 105 | - – Dependency management features were extracted into [dry-component](https://github.com/dry-rb/dry-component) 106 | - – `Rodakase::View` was extracted into the [dry-view](https://github.com/dry-rb/dry-view) gem 107 | 108 | [Compare v0.0.1...v0.1.0](https://github.com/dry-rb/dry-web/compare/v0.0.1...v0.1.0) 109 | 110 | ## 0.0.1 2015-11-13 111 | 112 | Awesome, first release on Friday 13th. Let's be optimistic. This release ships with: 113 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. 4 | 5 | We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion. 6 | 7 | Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct. 8 | 9 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team. 10 | 11 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers. 12 | 13 | This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.4.0, available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct](https://www.contributor-covenant.org/version/1/4/code-of-conduct) 14 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Issue Guidelines 2 | 3 | ## Reporting bugs 4 | 5 | If you found a bug, report an issue and describe what's the expected behavior versus what actually happens. If the bug causes a crash, attach a full backtrace. If possible, a reproduction script showing the problem is highly appreciated. 6 | 7 | ## Reporting feature requests 8 | 9 | Report a feature request **only after discussing it first on [discourse.dry-rb.org](https://discourse.dry-rb.org)** where it was accepted. Please provide a concise description of the feature, don't link to a discussion thread, and instead summarize what was discussed. 10 | 11 | ## Reporting questions, support requests, ideas, concerns etc. 12 | 13 | **PLEASE DON'T** - use [discourse.dry-rb.org](http://discourse.dry-rb.org) instead. 14 | 15 | # Pull Request Guidelines 16 | 17 | A Pull Request will only be accepted if it addresses a specific issue that was reported previously, or fixes typos, mistakes in documentation etc. 18 | 19 | Other requirements: 20 | 21 | 1) Do not open a pull request if you can't provide tests along with it. If you have problems writing tests, ask for help in the related issue. 22 | 2) Follow the style conventions of the surrounding code. In most cases, this is standard ruby style. 23 | 3) Add API documentation if it's a new feature 24 | 4) Update API documentation if it changes an existing feature 25 | 5) Bonus points for sending a PR which updates user documentation in the `docsite` directory 26 | 27 | # Asking for help 28 | 29 | If these guidelines aren't helpful, and you're stuck, please post a message on [discourse.dry-rb.org](https://discourse.dry-rb.org) or join [our chat](https://dry-rb.zulipchat.com). 30 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source 'https://rubygems.org' 4 | 5 | gemspec 6 | 7 | eval_gemfile 'Gemfile.devtools' 8 | 9 | group :test do 10 | gem 'rack' 11 | end 12 | 13 | group :tools do 14 | gem 'pry' 15 | end 16 | -------------------------------------------------------------------------------- /Gemfile.devtools: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # this file is managed by dry-rb/devtools project 4 | 5 | git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } 6 | 7 | group :test do 8 | gem "simplecov", require: false, platforms: :ruby 9 | gem "simplecov-cobertura", require: false, platforms: :ruby 10 | 11 | gem "warning" if RUBY_VERSION >= "2.4.0" 12 | end 13 | 14 | group :tools do 15 | # this is the same version that we use on codacy 16 | gem "rubocop", "0.82.0" 17 | end 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015-2020 dry-rb team 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ⚠ Deprecated in favor of Hanami 2.0 2 | 3 | [gem]: https://rubygems.org/gems/dry-web 4 | [actions]: https://github.com/dry-rb/dry-web/actions 5 | [codacy]: https://www.codacy.com/gh/dry-rb/dry-web 6 | [chat]: https://dry-rb.zulipchat.com 7 | [inchpages]: http://inch-ci.org/github/dry-rb/dry-web 8 | 9 | # dry-web [![Join the chat at https://dry-rb.zulipchat.com](https://img.shields.io/badge/dry--rb-join%20chat-%23346b7a.svg)][chat] 10 | 11 | [![Gem Version](https://badge.fury.io/rb/dry-web.svg)][gem] 12 | [![CI Status](https://github.com/dry-rb/dry-web/workflows/ci/badge.svg)][actions] 13 | [![Codacy Badge](https://api.codacy.com/project/badge/Grade/be704195dea94c9185259c7a89fdecba)][codacy] 14 | [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/be704195dea94c9185259c7a89fdecba)][codacy] 15 | [![Inline docs](http://inch-ci.org/github/dry-rb/dry-web.svg?branch=master)][inchpages] 16 | 17 | ## Supported Ruby versions 18 | 19 | This library officially supports the following Ruby versions: 20 | 21 | * MRI >= `2.4` 22 | * jruby >= `9.2` 23 | 24 | ## License 25 | 26 | See `LICENSE` file. 27 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "bundler/gem_tasks" 4 | 5 | require "rspec/core/rake_task" 6 | RSpec::Core::RakeTask.new(:spec) 7 | 8 | task default: [:spec] 9 | -------------------------------------------------------------------------------- /changelog.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - version: 0.8.0 3 | date: '2018-01-02' 4 | changed: 5 | - Updated to `dry-system ~> 0.9` (solnic) 6 | - version: 0.7.1 7 | date: '2017-07-25' 8 | changed: 9 | - Default log level for `:test` env is set to `Logger::DEBUG` (solnic) 10 | - version: 0.7.0 11 | date: '2017-06-16' 12 | changed: 13 | - "[BREAKING] `Dry::Web::Settings` now loads settings from local `.env` and `.env.` 14 | files (GustavoCaso)" 15 | - "[BREAKING] Removed `Dry::Web::Umbrella` with special handling of settings. Settings 16 | should for now be provided as a bootable component within your applications (dry-web-roda 17 | will be updated to generate such) (timriley)" 18 | - version: 0.6.0 19 | date: '2017-02-02' 20 | added: 21 | - Support for [dry-monitor](https://github.com/dry-rb/dry-monitor) with notifications 22 | and rack logging (solnic) 23 | - version: 0.5.0 24 | date: '2016-08-15' 25 | summary: Update to work with dry-system 26 | - version: 0.4.1 27 | date: '2016-07-26' 28 | changed: 29 | - Set a higher minimum Ruby version (>= 2.1.0) to match dry-auto_inject (timriley) 30 | - version: 0.4.0 31 | date: '2016-07-26' 32 | changed: 33 | - Require dry-component 0.4.1 for latest `Dry::Component::Container#injector` features 34 | and API (timriley) 35 | - version: 0.3.1 36 | date: '2016-06-22' 37 | changed: 38 | - Added a necessary version spec for the dry-component dependency (timriley) 39 | - version: 0.3.0 40 | date: '2016-06-22' 41 | added: 42 | - Added an `Umbrella` subclass of `Dry::Web::Container`, intended to be a single, 43 | top-level wrapper around multiple sub-apps in a dry-web project (timriley) 44 | - Added `Dry::Web::Settings`, designed to work as an app's single, top-level settings 45 | object (timriley) 46 | - Added `env` config to `Dry::Web::Container`, moved across from dry-component (timriley) 47 | changed: 48 | - Renamed `Dry::Web::Cli` to `Dry::Web::Console`, to make room for a real CLI in 49 | the future, starting with dry-web-roda (timriley) 50 | - version: 0.2.0 51 | date: '2016-06-12' 52 | changed: 53 | - Extracted Roda support into [dry-web-roda](https://github.com/dry-rb/dry-web-roda) 54 | (timriley) 55 | - Removed `Dry::Web::Transaction::Composer`, which was offering no value above direct 56 | calls to `Dry.Transaction` (timriley) 57 | - Basic skeleton example removed, since skeletons/app generators will soon be provided 58 | elsewhere (timriley) 59 | - version: 0.1.0 60 | date: '2016-04-21' 61 | changed: 62 | - "– Renamed from rodakase to dry-web" 63 | - "– Dependency management features were extracted into [dry-component](https://github.com/dry-rb/dry-component)" 64 | - "– `Rodakase::View` was extracted into the [dry-view](https://github.com/dry-rb/dry-view) 65 | gem" 66 | - version: 0.0.1 67 | date: '2015-11-13' 68 | summary: 'Awesome, first release on Friday 13th. Let''s be optimistic. This release 69 | ships with:' 70 | -------------------------------------------------------------------------------- /dry-web.gemspec: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # this file is managed by dry-rb/devtools project 3 | 4 | lib = File.expand_path('lib', __dir__) 5 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 6 | require 'dry/web/version' 7 | 8 | Gem::Specification.new do |spec| 9 | spec.name = 'dry-web' 10 | spec.authors = ["Piotr Solnica"] 11 | spec.email = ["piotr.solnica@gmail.com"] 12 | spec.license = 'MIT' 13 | spec.version = Dry::Web::VERSION.dup 14 | 15 | spec.summary = "Lightweight web application stack on top of dry-system" 16 | spec.description = spec.summary 17 | spec.homepage = 'https://dry-rb.org/gems/dry-web' 18 | spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-web.gemspec", "lib/**/*"] 19 | spec.bindir = 'bin' 20 | spec.executables = [] 21 | spec.require_paths = ['lib'] 22 | 23 | spec.metadata['allowed_push_host'] = 'https://rubygems.org' 24 | spec.metadata['changelog_uri'] = 'https://github.com/dry-rb/dry-web/blob/master/CHANGELOG.md' 25 | spec.metadata['source_code_uri'] = 'https://github.com/dry-rb/dry-web' 26 | spec.metadata['bug_tracker_uri'] = 'https://github.com/dry-rb/dry-web/issues' 27 | 28 | spec.required_ruby_version = ">= 2.4.0" 29 | 30 | # to update dependencies edit project.yml 31 | spec.add_runtime_dependency "dry-monitor", "~> 0.3" 32 | spec.add_runtime_dependency "dry-system", "~> 0.15" 33 | 34 | spec.add_development_dependency "bundler" 35 | spec.add_development_dependency "rake" 36 | spec.add_development_dependency "rspec" 37 | end 38 | -------------------------------------------------------------------------------- /lib/dry-web.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'logger' 4 | 5 | require 'dry/web/version' 6 | require 'dry/web/container' 7 | -------------------------------------------------------------------------------- /lib/dry/web/console.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Dry 4 | module Web 5 | class Console 6 | REPL = begin 7 | require 'pry' 8 | Pry 9 | rescue LoadError 10 | require 'irb' 11 | IRB 12 | end 13 | 14 | def self.start 15 | REPL.start 16 | end 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /lib/dry/web/container.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'dry/system/container' 4 | require 'dry/monitor' 5 | 6 | module Dry 7 | module Web 8 | class Container < Dry::System::Container 9 | use :env, inferrer: -> { ENV.fetch('RACK_ENV', 'development').to_sym } 10 | use :logging 11 | use :notifications 12 | 13 | setting :logger_class, Monitor::Logger 14 | setting :listeners, false 15 | 16 | def self.inherited(klass) 17 | klass.after(:configure) do 18 | register_rack_monitor 19 | attach_listeners 20 | end 21 | super 22 | end 23 | 24 | class << self 25 | def register_rack_monitor 26 | return self if key?(:rack_monitor) 27 | 28 | register(:rack_monitor, Monitor::Rack::Middleware.new(self[:notifications])) 29 | self 30 | end 31 | 32 | def attach_listeners 33 | return unless config.listeners 34 | 35 | rack_logger = Monitor::Rack::Logger.new(self[:logger]) 36 | rack_logger.attach(self[:rack_monitor]) 37 | self 38 | end 39 | end 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /lib/dry/web/version.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Dry 4 | module Web 5 | VERSION = '0.8.0'.freeze 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /log/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dry-rb/dry-web/63e0295c4d046f72c3e7fa0eb451eb582b1bbb15/log/.gitkeep -------------------------------------------------------------------------------- /project.yml: -------------------------------------------------------------------------------- 1 | name: dry-web 2 | codacy_id: be704195dea94c9185259c7a89fdecba 3 | gemspec: 4 | authors: ["Piotr Solnica"] 5 | email: ["piotr.solnica@gmail.com"] 6 | summary: "Lightweight web application stack on top of dry-system" 7 | development_dependencies: 8 | - bundler 9 | - rake 10 | - rspec 11 | runtime_dependencies: 12 | - ["dry-system", "~> 0.15"] 13 | - ["dry-monitor", "~> 0.3"] 14 | -------------------------------------------------------------------------------- /spec/fixtures/multiple_env_files/.env: -------------------------------------------------------------------------------- 1 | IN_BOTH_ENVIRONMENT='.env' 2 | ONLY_ON_ENV='will be loaded from env' 3 | -------------------------------------------------------------------------------- /spec/fixtures/multiple_env_files/.env.test: -------------------------------------------------------------------------------- 1 | IN_BOTH_ENVIRONMENT='.env.test' 2 | ONLY_IN_TEST='will be loaded from env.test' 3 | -------------------------------------------------------------------------------- /spec/fixtures/test/.env.test: -------------------------------------------------------------------------------- 1 | API_KEY='yaml123' 2 | IN_BOTH_ENVIRONMENT='.env.test' 3 | PRECOMPILE_ASSETS="1" 4 | UNDECLARED=not declared in settings 5 | TESTING='variables with = in it' 6 | -------------------------------------------------------------------------------- /spec/fixtures/test/log/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dry-rb/dry-web/63e0295c4d046f72c3e7fa0eb451eb582b1bbb15/spec/fixtures/test/log/.gitkeep -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require_relative 'support/coverage' 4 | 5 | ENV['RACK_ENV'] = 'test' 6 | 7 | begin 8 | require 'byebug' 9 | rescue LoadError; end 10 | SPEC_ROOT = Pathname(__FILE__).dirname 11 | 12 | Dir[SPEC_ROOT.join('support/*.rb').to_s].each { |f| require f } 13 | Dir[SPEC_ROOT.join('shared/*.rb').to_s].each { |f| require f } 14 | 15 | require "dry-web" 16 | 17 | module Test; end 18 | 19 | RSpec.configure do |config| 20 | config.disable_monkey_patching! 21 | 22 | config.before do 23 | @test_constants = Test.constants 24 | end 25 | 26 | config.after do 27 | added_constants = Test.constants - @test_constants 28 | added_constants.each { |name| Test.send(:remove_const, name) } 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /spec/support/coverage.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # this file is managed by dry-rb/devtools 4 | 5 | if ENV["COVERAGE"] == "true" 6 | require "simplecov" 7 | require "simplecov-cobertura" 8 | 9 | SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter 10 | 11 | SimpleCov.start do 12 | add_filter "/spec/" 13 | enable_coverage :branch 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /spec/support/warnings.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # this file is managed by dry-rb/devtools project 4 | 5 | require "warning" 6 | 7 | Warning.ignore(%r{rspec/core}) 8 | Warning.ignore(%r{rspec/mocks}) 9 | Warning.ignore(/codacy/) 10 | Warning[:experimental] = false if Warning.respond_to?(:[]) 11 | -------------------------------------------------------------------------------- /spec/unit/container_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'rack' 4 | require 'dry/monitor' 5 | require 'dry/monitor/rack/middleware' 6 | require 'dry/monitor/rack/logger' 7 | 8 | RSpec.describe "Dry::Web::Container" do 9 | subject(:container) { Class.new(Dry::Web::Container) } 10 | 11 | describe "settings" do 12 | describe ".config.logger" do 13 | it 'sets up default logger for development env' do 14 | container.configure do |config| 15 | config.env = :development 16 | end 17 | 18 | expect(container[:logger].level).to be(Logger::DEBUG) 19 | end 20 | 21 | it 'sets up default logger for non-development env' do 22 | container.configure do |config| 23 | config.env = :production 24 | end 25 | 26 | expect(container[:logger].level).to be(Logger::ERROR) 27 | end 28 | 29 | it 'allows presetting a loggert' do 30 | container.configure do |config| 31 | config.logger = 'my logger' 32 | end 33 | 34 | expect(container[:logger]).to eql('my logger') 35 | end 36 | end 37 | 38 | describe '.config.notifications' do 39 | it 'sets up notifications by default' do 40 | container.configure do |config| 41 | config.env = :development 42 | end 43 | 44 | expect(container[:notifications].id).to be(container.config.name) 45 | end 46 | end 47 | 48 | describe '.config.rack_monitor' do 49 | it 'sets up rack monitor by default' do 50 | container.configure do |config| 51 | config.env = :development 52 | end 53 | 54 | expect(container[:rack_monitor].notifications).to be(container[:notifications]) 55 | end 56 | end 57 | 58 | describe '.config.rack_logger' do 59 | it 'sets up rack logger by default' do 60 | logger = spy(:logger) 61 | 62 | container.configure do |config| 63 | config.env = :development 64 | config.logger = logger 65 | config.listeners = true 66 | end 67 | 68 | payload = { a_rack: :env_hash } 69 | 70 | container[:rack_monitor].instrument(:start, env: payload) 71 | 72 | expect(logger).to have_received(:info) 73 | end 74 | end 75 | 76 | describe ".config.env" do 77 | context "existing RACK_ENV environment variable" do 78 | it "returns the RACK_ENV" do 79 | expect(Class.new(Dry::Web::Container).config.env).to eq :test 80 | end 81 | end 82 | end 83 | end 84 | end 85 | --------------------------------------------------------------------------------