trailblazer-rails 2.1.1 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,91 +1,30 @@
1
- require "rails/railtie"
2
- require "trailblazer/loader"
3
-
4
- module Trailblazer
5
- class Railtie < ::Rails::Railtie
6
- config.trailblazer = ActiveSupport::OrderedOptions.new
7
- ## Accept also an Array of controllers
8
- config.trailblazer.application_controller ||= 'ActionController::Base'
9
- config.trailblazer.use_loader ||= true
10
- config.trailblazer.enable_tracing ||= false
11
-
12
- def self.load_concepts(app)
13
- # Loader.new.(insert: [ModelFile, before: Loader::AddConceptFiles]) { |file| require_dependency("#{app.root}/#{file}") }
14
- load_for(app)
15
-
16
- engines.each { |engine| load_for(engine) }
17
- end
18
-
19
- def self.engines
20
- if Gem::Version.new(::Rails.version) >= Gem::Version.new("4.1")
21
- ::Rails.application.railties.find_all { |tie| tie.is_a?(::Rails::Engine) }
22
- else
23
- ::Rails.application.railties.engines
24
- end
25
- end
26
-
27
- def self.load_for(app)
28
- Loader.new.(prepend: AllModelFiles, root: app.root) { |file| require_dependency(file) }
29
- end
30
-
31
- # This is to autoload Operation::Dispatch, etc. I'm simply assuming people find this helpful in Rails.
32
- initializer "trailblazer.library_autoloading" do
33
- end
34
-
35
- # thank you, http://stackoverflow.com/a/17573888/465070
36
- initializer 'trailblazer.install', after: "reform.form_extensions" do |app|
37
- # the trb autoloading has to be run after initializers have been loaded, so we can tweak inclusion of features in
38
- # initializers.
39
- if config.trailblazer.use_loader
40
- reloader_class.to_prepare do
41
- Trailblazer::Railtie.load_concepts(app)
42
- end
43
- end
44
- end
45
-
46
- initializer "trailblazer.application_controller", before: "finisher_hook" do
47
- reloader_class.to_prepare do
48
- ActiveSupport.on_load(:action_controller) do |app|
49
- Trailblazer::Railtie.extend_application_controller!(app)
50
- end
51
- end
52
- end
53
-
54
- # Prepend model file, before the concept files like operation.rb get loaded.
55
- ModelFile = ->(input, options) do
56
- model = "app/models/#{options[:name]}.rb"
57
- File.exist?(model) ? [model] + input : input
58
- end
59
-
60
- # Load all model files before any TRB files.
61
- AllModelFiles = ->(input, options) do
62
- Dir.glob("#{options[:root]}/app/models/**/*.rb").sort + input
63
- end
64
-
65
- private
66
-
67
- def reloader_class
68
- # Rails 5.0.0.rc1 says:
69
- # DEPRECATION WARNING: to_prepare is deprecated and will be removed from Rails 5.1
70
- # (use ActiveSupport::Reloader.to_prepare instead)
71
- if Gem.loaded_specs['activesupport'].version >= Gem::Version.new('5')
72
- ActiveSupport::Reloader
73
- else
74
- ActionDispatch::Reloader
75
- end
76
- end
77
-
78
- module ExtendApplicationController
79
- def extend_application_controller!(app)
80
- controllers = Array(::Rails.application.config.trailblazer.application_controller).map { |x| x.to_s }
81
- if controllers.include? app.to_s
82
- app.send :include, Trailblazer::Rails::Controller
83
- app.send :include, Trailblazer::Rails::Controller::Cell if defined?(::Cell)
84
- end
85
- app
86
- end
87
- end
88
-
89
- extend ExtendApplicationController
90
- end
91
- end
1
+ require "rails/railtie"
2
+ require "trailblazer/loader"
3
+ require "trailblazer/rails/railtie/extend_application_controller"
4
+ require "trailblazer/rails/railtie/loader"
5
+
6
+ module Trailblazer
7
+ class Railtie < ::Rails::Railtie
8
+ config.trailblazer = ActiveSupport::OrderedOptions.new
9
+ ## Accept also an Array of controllers
10
+ config.trailblazer.application_controller ||= 'ActionController::Base'
11
+ config.trailblazer.use_loader ||= true
12
+ config.trailblazer.enable_tracing ||= false
13
+
14
+ include Loader
15
+ include ExtendApplicationController
16
+
17
+ private
18
+
19
+ def reloader_class
20
+ # Rails 5.0.0.rc1 says:
21
+ # DEPRECATION WARNING: to_prepare is deprecated and will be removed from Rails 5.1
22
+ # (use ActiveSupport::Reloader.to_prepare instead)
23
+ if Gem.loaded_specs['activesupport'].version >= Gem::Version.new('5')
24
+ ActiveSupport::Reloader
25
+ else
26
+ ActionDispatch::Reloader
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,28 @@
1
+ require 'active_support/concern'
2
+
3
+ module Trailblazer
4
+ class Railtie < ::Rails::Railtie
5
+ module ExtendApplicationController
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ initializer "trailblazer.application_controller", before: "finisher_hook" do
10
+ reloader_class.to_prepare do
11
+ ActiveSupport.on_load(:action_controller) do |app|
12
+ Trailblazer::Railtie.extend_application_controller!(app)
13
+ end
14
+ end
15
+ end
16
+
17
+ def extend_application_controller!(app)
18
+ controllers = Array(::Rails.application.config.trailblazer.application_controller).map { |x| x.to_s }
19
+ if controllers.include? app.to_s
20
+ app.send :include, Trailblazer::Rails::Controller
21
+ app.send :include, Trailblazer::Rails::Controller::Cell if defined?(::Cell)
22
+ end
23
+ app
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,56 @@
1
+ require 'active_support/concern'
2
+
3
+ module Trailblazer
4
+ class Railtie < ::Rails::Railtie
5
+ module Loader
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ def self.load_concepts(app)
10
+ # Loader.new.(insert: [ModelFile, before: Loader::AddConceptFiles]) { |file| require_dependency("#{app.root}/#{file}") }
11
+ load_for(app)
12
+
13
+ engines.each { |engine| load_for(engine) }
14
+ end
15
+
16
+ def self.engines
17
+ if Gem::Version.new(::Rails.version) >= Gem::Version.new("4.1")
18
+ ::Rails.application.railties.find_all { |tie| tie.is_a?(::Rails::Engine) }
19
+ else
20
+ ::Rails.application.railties.engines
21
+ end
22
+ end
23
+
24
+ def self.load_for(app)
25
+ Trailblazer::Loader.new.(prepend: AllModelFiles, root: app.root) { |file| require_dependency(file) }
26
+ end
27
+
28
+ # Prepend model file, before the concept files like operation.rb get loaded.
29
+ ModelFile = ->(input, options) do
30
+ model = "app/models/#{options[:name]}.rb"
31
+ File.exist?(model) ? [model] + input : input
32
+ end
33
+
34
+ # Load all model files before any TRB files.
35
+ AllModelFiles = ->(input, options) do
36
+ Dir.glob("#{options[:root]}/app/models/**/*.rb").sort + input
37
+ end
38
+
39
+ # This is to autoload Operation::Dispatch, etc. I'm simply assuming people find this helpful in Rails.
40
+ initializer "trailblazer.library_autoloading" do
41
+ end
42
+
43
+ # thank you, http://stackoverflow.com/a/17573888/465070
44
+ initializer 'trailblazer.install', after: "reform.form_extensions" do |app|
45
+ # the trb autoloading has to be run after initializers have been loaded, so we can tweak inclusion of features in
46
+ # initializers.
47
+ if config.trailblazer.use_loader
48
+ reloader_class.to_prepare do
49
+ Trailblazer::Railtie.load_concepts(app)
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -1,6 +1,6 @@
1
- require "minitest/rails/capybara" # loads Capybara, etc.
2
-
3
- module Trailblazer::Test
4
- class Integration < Capybara::Rails::TestCase
5
- end
6
- end
1
+ require "minitest/rails/capybara" # loads Capybara, etc.
2
+
3
+ module Trailblazer::Test
4
+ class Integration < Capybara::Rails::TestCase
5
+ end
6
+ end
@@ -1,5 +1,5 @@
1
- module Trailblazer
2
- module Rails
3
- VERSION = "2.1.1"
4
- end
5
- end
1
+ module Trailblazer
2
+ module Rails
3
+ VERSION = "2.1.2"
4
+ end
5
+ end
@@ -1,27 +1,27 @@
1
- lib = File.expand_path('../lib', __FILE__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'trailblazer/rails/version'
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "trailblazer-rails"
7
- spec.version = Trailblazer::Rails::VERSION
8
- spec.authors = ["Nick Sutterer"]
9
- spec.email = ["apotonick@gmail.com"]
10
-
11
- spec.summary = %q{Convenient Rails support for Trailblazer.}
12
- spec.homepage = "http://trailblazer.to/gems/trailblazer/2.0/rails.html"
13
- spec.license = "MIT"
14
-
15
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test)/}) }
16
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
17
- spec.require_paths = ["lib"]
18
-
19
- spec.add_dependency "trailblazer", ">= 2.1.0.beta1", "< 2.2.0"
20
- spec.add_dependency "trailblazer-loader", ">= 0.1.0"
21
- spec.add_dependency "reform-rails", ">= 0.1.4", "< 0.2.0"
22
-
23
- spec.add_development_dependency "bundler", "~> 1.10"
24
- spec.add_development_dependency "rake", "~> 10.0"
25
- spec.add_development_dependency "minitest"
26
- spec.add_development_dependency "rubocop"
27
- end
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'trailblazer/rails/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "trailblazer-rails"
7
+ spec.version = Trailblazer::Rails::VERSION
8
+ spec.authors = ["Nick Sutterer"]
9
+ spec.email = ["apotonick@gmail.com"]
10
+
11
+ spec.summary = %q{Convenient Rails support for Trailblazer.}
12
+ spec.homepage = "http://trailblazer.to/gems/trailblazer/2.0/rails.html"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test)/}) }
16
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_dependency "trailblazer", ">= 2.1.0.beta1", "< 2.2.0"
20
+ spec.add_dependency "trailblazer-loader", ">= 0.1.0"
21
+ spec.add_dependency "reform-rails", ">= 0.1.4", "< 0.2.0"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.10"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "minitest"
26
+ spec.add_development_dependency "rubocop"
27
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trailblazer-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-05 00:00:00.000000000 Z
11
+ date: 2018-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trailblazer
@@ -144,6 +144,8 @@ files:
144
144
  - lib/trailblazer/rails/controller.rb
145
145
  - lib/trailblazer/rails/form.rb
146
146
  - lib/trailblazer/rails/railtie.rb
147
+ - lib/trailblazer/rails/railtie/extend_application_controller.rb
148
+ - lib/trailblazer/rails/railtie/loader.rb
147
149
  - lib/trailblazer/rails/test/integration.rb
148
150
  - lib/trailblazer/rails/version.rb
149
151
  - trailblazer-rails.gemspec
@@ -167,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
169
  version: '0'
168
170
  requirements: []
169
171
  rubyforge_project:
170
- rubygems_version: 2.6.11
172
+ rubygems_version: 2.6.14.1
171
173
  signing_key:
172
174
  specification_version: 4
173
175
  summary: Convenient Rails support for Trailblazer.