dry-system-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +16 -0
  5. data/CHANGELOG.md +3 -0
  6. data/Gemfile +12 -0
  7. data/LICENSE +20 -0
  8. data/README.md +72 -0
  9. data/Rakefile +12 -0
  10. data/dry-system-rails.gemspec +23 -0
  11. data/lib/dry-system-rails.rb +1 -0
  12. data/lib/dry/system/rails.rb +62 -0
  13. data/lib/dry/system/rails/version.rb +7 -0
  14. data/spec/dummy/.rspec +1 -0
  15. data/spec/dummy/Gemfile +6 -0
  16. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  17. data/spec/dummy/app/models/user_repo.rb +5 -0
  18. data/spec/dummy/app/operations/create_user.rb +4 -0
  19. data/spec/dummy/config/application.rb +12 -0
  20. data/spec/dummy/config/boot.rb +3 -0
  21. data/spec/dummy/config/environment.rb +5 -0
  22. data/spec/dummy/config/environments/development.rb +39 -0
  23. data/spec/dummy/config/environments/production.rb +66 -0
  24. data/spec/dummy/config/environments/test.rb +36 -0
  25. data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
  26. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  27. data/spec/dummy/config/initializers/container.rb +5 -0
  28. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  29. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  30. data/spec/dummy/config/initializers/inflections.rb +16 -0
  31. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  32. data/spec/dummy/config/initializers/new_framework_defaults.rb +21 -0
  33. data/spec/dummy/config/initializers/session_store.rb +3 -0
  34. data/spec/dummy/config/initializers/wrap_parameters.rb +9 -0
  35. data/spec/dummy/config/locales/en.yml +23 -0
  36. data/spec/dummy/config/routes.rb +3 -0
  37. data/spec/dummy/config/secrets.yml +22 -0
  38. data/spec/dummy/config/spring.rb +6 -0
  39. data/spec/dummy/config/system/boot/persistence.rb +3 -0
  40. data/spec/dummy/config/system/import.rb +3 -0
  41. data/spec/dummy/log/.keep +0 -0
  42. data/spec/integration/container_spec.rb +17 -0
  43. data/spec/integration/models/user_repo_spec.rb +9 -0
  44. data/spec/spec_helper.rb +17 -0
  45. metadata +174 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: aa415ae413c6222d8b8163b956594c8417c69665
4
+ data.tar.gz: b0b0fd7ca295ff62516c14e24a46f957d20738b6
5
+ SHA512:
6
+ metadata.gz: 132c694fddf4f00c3768de8e97250924ee8a2d89316083eb6583537323d15e5a399f4fadffd037f7c58067a8a33bba08129c3cb030c2cd653f87b0251a41dd2d
7
+ data.tar.gz: 8c1126ee9cf18a1e0acbd7f3abe6f563f59c141cfe448b646f08ed8fde1d6ee0fcbd27f12f143f6d411686df27f580b56c87d6ccafc731e2b5853f56d06c0379
@@ -0,0 +1,8 @@
1
+ .DS_Store
2
+ coverage
3
+ /.bundle
4
+ vendor/bundle
5
+ bin/
6
+ tmp/
7
+ .idea/
8
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --require spec_helper
3
+ --order random
@@ -0,0 +1,16 @@
1
+ language: ruby
2
+ sudo: false
3
+ cache: bundler
4
+ bundler_args: --without console
5
+ script:
6
+ - bundle exec rake spec
7
+ rvm:
8
+ - 2.3.1
9
+ notifications:
10
+ email: false
11
+ webhooks:
12
+ urls:
13
+ - https://webhooks.gitter.im/e/19098b4253a72c9796db
14
+ on_success: change # options: [always|never|change] default: always
15
+ on_failure: always # options: [always|never|change] default: always
16
+ on_start: false # default: false
@@ -0,0 +1,3 @@
1
+ # v0.0.1 2016-08-17
2
+
3
+ First public release
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem 'railties'
7
+ gem 'actionpack'
8
+ end
9
+
10
+ group :tools do
11
+ gem 'byebug', platform: :mri
12
+ end
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 dry-rb.org 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.
@@ -0,0 +1,72 @@
1
+ [gem]: https://rubygems.org/gems/dry-system-rails
2
+ [travis]: https://travis-ci.org/dry-rb/dry-system-rails
3
+ [codeclimate]: https://codeclimate.com/github/dry-rb/dry-system-rails
4
+ [coveralls]: https://coveralls.io/r/dry-rb/dry-system-rails
5
+ [inchpages]: http://inch-ci.org/github/dry-rb/dry-system-rails
6
+
7
+ # dry-system-rails [![Join the chat at https://gitter.im/dry-rb/chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/dry-rb/chat)
8
+
9
+ [![Gem Version](https://badge.fury.io/rb/dry-system-rails.svg)][gem]
10
+ [![Build Status](https://travis-ci.org/dry-rb/dry-system-rails.svg?branch=master)][travis]
11
+ [![Code Climate](https://codeclimate.com/github/dry-rb/dry-system-rails/badges/gpa.svg)][codeclimate]
12
+ [![Test Coverage](https://codeclimate.com/github/dry-rb/dry-system-rails/badges/coverage.svg)][codeclimate]
13
+ [![Inline docs](http://inch-ci.org/github/dry-rb/dry-system-rails.svg?branch=master)][inchpages]
14
+
15
+ Railtie for dry-system (つ◕౪◕)つ━☆゚.*・。゚
16
+
17
+ ## Installation
18
+
19
+ Add it to your Gemfile:
20
+
21
+ ```
22
+ gem 'dry-system-rails'
23
+ ```
24
+
25
+ Assuming your `Rails.application.class` is `MyApp::Application`, add `config/system/import.rb`
26
+ file with the following content:
27
+
28
+ ``` ruby
29
+ # config/system/import.rb
30
+ module MyApp
31
+ Import = Container.injector
32
+ end
33
+ ```
34
+
35
+ To configure auto-registration create `config/initializer/system.rb` with the following content:
36
+
37
+ ``` ruby
38
+ require 'dry/system/rails'
39
+
40
+ Dry::System::Rails.configure do |config|
41
+ # you can set it to whatever you want and add as many dirs you want
42
+ config.auto_register << 'lib'
43
+ end
44
+ ```
45
+
46
+ Now you can use `MyApp::Import` to inject components into your objects:
47
+
48
+ ``` ruby
49
+ # lib/user_repo.rb
50
+ class UserRepo
51
+ end
52
+
53
+ # lib/create_user.rb
54
+ require 'import'
55
+
56
+ class CreateUser
57
+ include Import['user_repo']
58
+ end
59
+ ```
60
+
61
+ ## TODO
62
+
63
+ This is super alpha and it's missing a couple of things:
64
+
65
+ * Support for code reloading in dev mode
66
+ * Some generators to make UX nicer
67
+ * Tests for loading scripts (console etc)
68
+ * Tests for running rake tasks
69
+
70
+ ## License
71
+
72
+ See `LICENSE` file.
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler/gem_tasks'
3
+
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
5
+
6
+ require 'rspec/core'
7
+ require 'rspec/core/rake_task'
8
+
9
+ task default: :spec
10
+
11
+ desc 'Run all specs in spec directory'
12
+ RSpec::Core::RakeTask.new(:spec)
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ require File.expand_path('../lib/dry/system/rails/version', __FILE__)
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = 'dry-system-rails'
6
+ spec.version = Dry::System::Rails::VERSION
7
+ spec.authors = ['Piotr Solnica']
8
+ spec.email = ['piotr.solnica@gmail.com']
9
+ spec.summary = 'Railtie for dry-system'
10
+ spec.homepage = 'https://github.com/dry-rb/dry-system-rails'
11
+ spec.license = 'MIT'
12
+
13
+ spec.files = `git ls-files -z`.split("\x0")
14
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
15
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
+ spec.require_paths = ['lib']
17
+
18
+ spec.add_runtime_dependency 'dry-system', '~> 0.5'
19
+
20
+ spec.add_development_dependency 'bundler'
21
+ spec.add_development_dependency 'rake'
22
+ spec.add_development_dependency 'rspec'
23
+ end
@@ -0,0 +1 @@
1
+ require 'dry/system/rails'
@@ -0,0 +1,62 @@
1
+ require 'dry/system/container'
2
+ require 'rails/railtie'
3
+
4
+ module Dry
5
+ module System
6
+ module Rails
7
+ extend Dry::Configurable
8
+
9
+ setting :auto_register, []
10
+
11
+ def self.configure
12
+ super
13
+
14
+ container = create_container(config)
15
+
16
+ Railtie.configure do
17
+ config.container = container
18
+ end
19
+ end
20
+
21
+ def self.create_container(defaults)
22
+ auto_register = defaults.auto_register
23
+
24
+ container = Class.new(Dry::System::Container).configure do |config|
25
+ config.root = ::Rails.root
26
+ config.system_dir = config.root.join('config/system')
27
+ config.auto_register = auto_register
28
+ end
29
+
30
+ container.load_paths!('lib', 'app', 'app/models')
31
+ end
32
+
33
+ class Railtie < ::Rails::Railtie
34
+ initializer 'dry.system.create_container' do
35
+ System::Rails.configure
36
+ end
37
+
38
+ config.to_prepare do |*args|
39
+ Railtie.finalize!
40
+ end
41
+
42
+ def finalize!
43
+ namespace.const_set(:Container, container)
44
+ container.config.name = name
45
+ container.finalize!
46
+ end
47
+
48
+ def name
49
+ namespace.name.underscore.to_sym
50
+ end
51
+
52
+ def namespace
53
+ Object.const_get(::Rails.application.class.to_s.split('::').first)
54
+ end
55
+
56
+ def container
57
+ Railtie.config.container
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,7 @@
1
+ module Dry
2
+ module System
3
+ module Rails
4
+ VERSION = '0.0.1'.freeze
5
+ end
6
+ end
7
+ end
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'railties'
4
+ gem 'actionpack'
5
+ gem 'listen'
6
+ gem 'dry-system-rails', path: '../..'
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery with: :exception
3
+ end
@@ -0,0 +1,5 @@
1
+ require 'import'
2
+
3
+ class UserRepo
4
+ include Dummy::Import['persistence.db']
5
+ end
@@ -0,0 +1,4 @@
1
+ module Operations
2
+ class CreateUser
3
+ end
4
+ end
@@ -0,0 +1,12 @@
1
+ require_relative 'boot'
2
+
3
+ require 'rails'
4
+ require 'action_controller/railtie'
5
+
6
+ Bundler.setup(*Rails.groups)
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+ config.root = Pathname(__dir__).join('..')
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
2
+
3
+ require 'bundler/setup' # Set up gems listed in the Gemfile.
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require_relative 'application'
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!
@@ -0,0 +1,39 @@
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Do not eager load code on boot.
10
+ config.eager_load = false
11
+
12
+ # Show full error reports.
13
+ config.consider_all_requests_local = true
14
+
15
+ # Enable/disable caching. By default caching is disabled.
16
+ if Rails.root.join('tmp/caching-dev.txt').exist?
17
+ config.action_controller.perform_caching = true
18
+
19
+ config.cache_store = :memory_store
20
+ config.public_file_server.headers = {
21
+ 'Cache-Control' => 'public, max-age=172800'
22
+ }
23
+ else
24
+ config.action_controller.perform_caching = false
25
+
26
+ config.cache_store = :null_store
27
+ end
28
+
29
+ # Print deprecation notices to the Rails logger.
30
+ config.active_support.deprecation = :log
31
+
32
+
33
+ # Raises error for missing translations
34
+ # config.action_view.raise_on_missing_translations = true
35
+
36
+ # Use an evented file watcher to asynchronously detect changes in source code,
37
+ # routes, locales, etc. This feature depends on the listen gem.
38
+ config.file_watcher = ActiveSupport::EventedFileUpdateChecker
39
+ end
@@ -0,0 +1,66 @@
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # Code is not reloaded between requests.
5
+ config.cache_classes = true
6
+
7
+ # Eager load code on boot. This eager loads most of Rails and
8
+ # your application in memory, allowing both threaded web servers
9
+ # and those relying on copy on write to perform better.
10
+ # Rake tasks automatically ignore this option for performance.
11
+ config.eager_load = true
12
+
13
+ # Full error reports are disabled and caching is turned on.
14
+ config.consider_all_requests_local = false
15
+ config.action_controller.perform_caching = true
16
+
17
+ # Disable serving static files from the `/public` folder by default since
18
+ # Apache or NGINX already handles this.
19
+ config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
20
+
21
+
22
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
23
+ # config.action_controller.asset_host = 'http://assets.example.com'
24
+
25
+ # Specifies the header that your server uses for sending files.
26
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
27
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
28
+
29
+
30
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
31
+ # config.force_ssl = true
32
+
33
+ # Use the lowest log level to ensure availability of diagnostic information
34
+ # when problems arise.
35
+ config.log_level = :debug
36
+
37
+ # Prepend all log lines with the following tags.
38
+ config.log_tags = [ :request_id ]
39
+
40
+ # Use a different cache store in production.
41
+ # config.cache_store = :mem_cache_store
42
+
43
+ # Use a real queuing backend for Active Job (and separate queues per environment)
44
+ # config.active_job.queue_adapter = :resque
45
+ # config.active_job.queue_name_prefix = "dummy_#{Rails.env}"
46
+
47
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
48
+ # the I18n.default_locale when a translation cannot be found).
49
+ config.i18n.fallbacks = true
50
+
51
+ # Send deprecation notices to registered listeners.
52
+ config.active_support.deprecation = :notify
53
+
54
+ # Use default logging formatter so that PID and timestamp are not suppressed.
55
+ config.log_formatter = ::Logger::Formatter.new
56
+
57
+ # Use a different logger for distributed setups.
58
+ # require 'syslog/logger'
59
+ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
60
+
61
+ if ENV["RAILS_LOG_TO_STDOUT"].present?
62
+ logger = ActiveSupport::Logger.new(STDOUT)
63
+ logger.formatter = config.log_formatter
64
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
65
+ end
66
+ end
@@ -0,0 +1,36 @@
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Do not eager load code on boot. This avoids loading your whole application
11
+ # just for the purpose of running a single test. If you are using a tool that
12
+ # preloads Rails for running tests, you may have to set it to true.
13
+ config.eager_load = false
14
+
15
+ # Configure public file server for tests with Cache-Control for performance.
16
+ config.public_file_server.enabled = true
17
+ config.public_file_server.headers = {
18
+ 'Cache-Control' => 'public, max-age=3600'
19
+ }
20
+
21
+ # Show full error reports and disable caching.
22
+ config.consider_all_requests_local = true
23
+ config.action_controller.perform_caching = false
24
+
25
+ # Raise exceptions instead of rendering exception templates.
26
+ config.action_dispatch.show_exceptions = false
27
+
28
+ # Disable request forgery protection in test environment.
29
+ config.action_controller.allow_forgery_protection = false
30
+
31
+ # Print deprecation notices to the stderr.
32
+ config.active_support.deprecation = :stderr
33
+
34
+ # Raises error for missing translations
35
+ # config.action_view.raise_on_missing_translations = true
36
+ end
@@ -0,0 +1,6 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # ApplicationController.renderer.defaults.merge!(
4
+ # http_host: 'example.org',
5
+ # https: false
6
+ # )
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,5 @@
1
+ require 'dry/system/rails'
2
+
3
+ Dry::System::Rails.configure do |config|
4
+ config.auto_register << 'app/operations'
5
+ end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Specify a serializer for the signed and encrypted cookie jars.
4
+ # Valid options are :json, :marshal, and :hybrid.
5
+ Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure sensitive parameters which will be filtered from the log file.
4
+ Rails.application.config.filter_parameters += [:password]
@@ -0,0 +1,16 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format. Inflections
4
+ # are locale specific, and you may define rules for as many different
5
+ # locales as you wish. All of these examples are active by default:
6
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
+ # inflect.plural /^(ox)$/i, '\1en'
8
+ # inflect.singular /^(ox)en/i, '\1'
9
+ # inflect.irregular 'person', 'people'
10
+ # inflect.uncountable %w( fish sheep )
11
+ # end
12
+
13
+ # These inflection rules are supported but not enabled by default:
14
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
+ # inflect.acronym 'RESTful'
16
+ # end
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
@@ -0,0 +1,21 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file contains migration options to ease your Rails 5.0 upgrade.
4
+ #
5
+ # Read the Rails 5.0 release notes for more info on each option.
6
+
7
+ # Enable per-form CSRF tokens. Previous versions had false.
8
+ Rails.application.config.action_controller.per_form_csrf_tokens = true
9
+
10
+ # Enable origin-checking CSRF mitigation. Previous versions had false.
11
+ Rails.application.config.action_controller.forgery_protection_origin_check = true
12
+
13
+ # Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
14
+ # Previous versions had false.
15
+ ActiveSupport.to_time_preserves_timezone = true
16
+
17
+ # Do not halt callback chains when a callback returns false. Previous versions had true.
18
+ ActiveSupport.halt_callback_chains_on_return_false = false
19
+
20
+ # Configure SSL options to enable HSTS with subdomains. Previous versions had false.
21
+ Rails.application.config.ssl_options = { hsts: { subdomains: true } }
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Rails.application.config.session_store :cookie_store, key: '_dummy_session'
@@ -0,0 +1,9 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json]
9
+ end
@@ -0,0 +1,23 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ hello: "Hello world"
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
3
+ end
@@ -0,0 +1,22 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rails secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ development:
14
+ secret_key_base: 93cc56a5c8991ad66f5a0ad2fa901a680d33b4d2b2556737115113246700705a46122df56d060d3da333778569e9bd5a0a0e8c21693cd10c48ad496db33edffd
15
+
16
+ test:
17
+ secret_key_base: 3040bb7ecbe834a675144408fc988bdaa791f78e9a9df2493665d514e25b8e409644e65194e070f903d18a03cd01e9463d0d562bb50bfbb7ba9dc8d0aef2076b
18
+
19
+ # Do not keep production secrets in the repository,
20
+ # instead read values from the environment.
21
+ production:
22
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -0,0 +1,6 @@
1
+ %w(
2
+ .ruby-version
3
+ .rbenv-vars
4
+ tmp/restart.txt
5
+ tmp/caching-dev.txt
6
+ ).each { |path| Spring.watch(path) }
@@ -0,0 +1,3 @@
1
+ Dummy::Container.finalize(:persistence) do |container|
2
+ container.register('persistence.db', :i_am_db)
3
+ end
@@ -0,0 +1,3 @@
1
+ module Dummy
2
+ Import = Container.injector
3
+ end
File without changes
@@ -0,0 +1,17 @@
1
+ RSpec.describe 'Application container' do
2
+ subject(:system) { Dummy::Container }
3
+
4
+ describe '#load_component' do
5
+ it 'loads component by its identifier' do
6
+ system.load_component('user_repo')
7
+
8
+ expect(Object.const_defined?(:UserRepo)).to be(true)
9
+ end
10
+ end
11
+
12
+ describe '#[]' do
13
+ it 'returns auto-registered component' do
14
+ expect(system['operations.create_user']).to be_instance_of(Operations::CreateUser)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ require 'user_repo'
2
+
3
+ RSpec.describe UserRepo do
4
+ subject(:user_repo) { UserRepo.new }
5
+
6
+ it 'has persistence.db injected in' do
7
+ expect(user_repo.db).to be(Dummy::Container['persistence.db'])
8
+ end
9
+ end
@@ -0,0 +1,17 @@
1
+ begin
2
+ require 'byebug'
3
+ rescue LoadError; end
4
+
5
+ require 'dry-system-rails'
6
+
7
+ SPEC_ROOT = Pathname(__dir__)
8
+
9
+ Dir[SPEC_ROOT.join('shared/**/*.rb')].each(&method(:require))
10
+ Dir[SPEC_ROOT.join('support/**/*.rb')].each(&method(:require))
11
+
12
+ ENV['RAILS_ENV'] = 'test'
13
+ require SPEC_ROOT.join('dummy/config/environment')
14
+
15
+ RSpec.configure do |config|
16
+ config.disable_monkey_patching!
17
+ end
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dry-system-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Piotr Solnica
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dry-system
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description:
70
+ email:
71
+ - piotr.solnica@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - CHANGELOG.md
80
+ - Gemfile
81
+ - LICENSE
82
+ - README.md
83
+ - Rakefile
84
+ - dry-system-rails.gemspec
85
+ - lib/dry-system-rails.rb
86
+ - lib/dry/system/rails.rb
87
+ - lib/dry/system/rails/version.rb
88
+ - spec/dummy/.rspec
89
+ - spec/dummy/Gemfile
90
+ - spec/dummy/app/controllers/application_controller.rb
91
+ - spec/dummy/app/models/user_repo.rb
92
+ - spec/dummy/app/operations/create_user.rb
93
+ - spec/dummy/config/application.rb
94
+ - spec/dummy/config/boot.rb
95
+ - spec/dummy/config/environment.rb
96
+ - spec/dummy/config/environments/development.rb
97
+ - spec/dummy/config/environments/production.rb
98
+ - spec/dummy/config/environments/test.rb
99
+ - spec/dummy/config/initializers/application_controller_renderer.rb
100
+ - spec/dummy/config/initializers/backtrace_silencers.rb
101
+ - spec/dummy/config/initializers/container.rb
102
+ - spec/dummy/config/initializers/cookies_serializer.rb
103
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
104
+ - spec/dummy/config/initializers/inflections.rb
105
+ - spec/dummy/config/initializers/mime_types.rb
106
+ - spec/dummy/config/initializers/new_framework_defaults.rb
107
+ - spec/dummy/config/initializers/session_store.rb
108
+ - spec/dummy/config/initializers/wrap_parameters.rb
109
+ - spec/dummy/config/locales/en.yml
110
+ - spec/dummy/config/routes.rb
111
+ - spec/dummy/config/secrets.yml
112
+ - spec/dummy/config/spring.rb
113
+ - spec/dummy/config/system/boot/persistence.rb
114
+ - spec/dummy/config/system/import.rb
115
+ - spec/dummy/log/.keep
116
+ - spec/integration/container_spec.rb
117
+ - spec/integration/models/user_repo_spec.rb
118
+ - spec/spec_helper.rb
119
+ homepage: https://github.com/dry-rb/dry-system-rails
120
+ licenses:
121
+ - MIT
122
+ metadata: {}
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 2.5.1
140
+ signing_key:
141
+ specification_version: 4
142
+ summary: Railtie for dry-system
143
+ test_files:
144
+ - spec/dummy/.rspec
145
+ - spec/dummy/Gemfile
146
+ - spec/dummy/app/controllers/application_controller.rb
147
+ - spec/dummy/app/models/user_repo.rb
148
+ - spec/dummy/app/operations/create_user.rb
149
+ - spec/dummy/config/application.rb
150
+ - spec/dummy/config/boot.rb
151
+ - spec/dummy/config/environment.rb
152
+ - spec/dummy/config/environments/development.rb
153
+ - spec/dummy/config/environments/production.rb
154
+ - spec/dummy/config/environments/test.rb
155
+ - spec/dummy/config/initializers/application_controller_renderer.rb
156
+ - spec/dummy/config/initializers/backtrace_silencers.rb
157
+ - spec/dummy/config/initializers/container.rb
158
+ - spec/dummy/config/initializers/cookies_serializer.rb
159
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
160
+ - spec/dummy/config/initializers/inflections.rb
161
+ - spec/dummy/config/initializers/mime_types.rb
162
+ - spec/dummy/config/initializers/new_framework_defaults.rb
163
+ - spec/dummy/config/initializers/session_store.rb
164
+ - spec/dummy/config/initializers/wrap_parameters.rb
165
+ - spec/dummy/config/locales/en.yml
166
+ - spec/dummy/config/routes.rb
167
+ - spec/dummy/config/secrets.yml
168
+ - spec/dummy/config/spring.rb
169
+ - spec/dummy/config/system/boot/persistence.rb
170
+ - spec/dummy/config/system/import.rb
171
+ - spec/dummy/log/.keep
172
+ - spec/integration/container_spec.rb
173
+ - spec/integration/models/user_repo_spec.rb
174
+ - spec/spec_helper.rb