trailblazer-rails 1.0.11 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -2
- data/.ruby-version +1 -0
- data/.travis.yml +1 -11
- data/CHANGES.md +3 -26
- data/LICENSE.txt +1 -1
- data/README.md +2 -2
- data/Rakefile +1 -1
- data/lib/trailblazer/rails/cell.rb +4 -5
- data/lib/trailblazer/rails/controller.rb +6 -18
- data/lib/trailblazer/rails/railtie.rb +68 -7
- data/lib/trailblazer/rails/test/integration.rb +1 -1
- data/lib/trailblazer/rails/version.rb +1 -1
- data/trailblazer-rails.gemspec +8 -8
- metadata +28 -33
- data/.rubocop-https---raw-githubusercontent-com-trailblazer-meta-master-rubocop-yml +0 -114
- data/.rubocop.yml +0 -11
- data/lib/trailblazer/rails/railtie/extend_application_controller.rb +0 -28
- data/lib/trailblazer/rails/railtie/loader.rb +0 -63
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7bf10b78c1fcf973a62ffa500b0008dfe73f1cc2
|
4
|
+
data.tar.gz: f729f62ecac32f615119f651109a2e6de4cf0bc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a467dce46aa9e21f6824ba09db844ad0363bfa0f47dbd31e2988275401b5d5f763f2c05be5d8cc8a79bdd693d9579a64833b9ff2b9deb14010dde882c86c80e3
|
7
|
+
data.tar.gz: 0ee7f00cce0d332f93166e4613c6cfa869b3f10b2837fe7ee6d8eb1be09255d468c68da2dfcf71379c3ac1f93d2a49474c8f2ea6f3226e0302334caa413bb663
|
data/.gitignore
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.4.1
|
data/.travis.yml
CHANGED
@@ -1,12 +1,6 @@
|
|
1
|
-
sudo: false
|
2
1
|
language: ruby
|
3
|
-
cache: bundler
|
4
2
|
matrix:
|
5
3
|
include:
|
6
|
-
- rvm: 2.4.1
|
7
|
-
env: TEST_SUITE=rails4.2
|
8
|
-
gemfile: test/rails4.2/Gemfile
|
9
|
-
|
10
4
|
- rvm: 2.4.1
|
11
5
|
env: TEST_SUITE=rails5.0
|
12
6
|
gemfile: test/rails5.0/Gemfile
|
@@ -15,8 +9,4 @@ matrix:
|
|
15
9
|
env: TEST_SUITE=rails5.1
|
16
10
|
gemfile: test/rails5.1/Gemfile
|
17
11
|
|
18
|
-
|
19
|
-
env: TEST_SUITE=rails5.2
|
20
|
-
gemfile: test/rails5.2/Gemfile
|
21
|
-
|
22
|
-
script: cd test/$TEST_SUITE && bundle install && bundle exec rake test
|
12
|
+
script: cd test/$TEST_SUITE && bundle exec rake test
|
data/CHANGES.md
CHANGED
@@ -1,30 +1,7 @@
|
|
1
|
-
#
|
1
|
+
# 2.0.0
|
2
2
|
|
3
|
-
*
|
4
|
-
|
5
|
-
# 1.0.10
|
6
|
-
|
7
|
-
* Reintroduced railtie dependency 4.x +
|
8
|
-
* Config flag use_loader renamed with enable_loader
|
9
|
-
|
10
|
-
# 1.0.9
|
11
|
-
|
12
|
-
* `Trailblazer::Rails::Railtie` divided in 2 modules:
|
13
|
-
* `Loader` -> require_dependecy `concepts`
|
14
|
-
* `ExtendApplicationController` -> include `run` and `render` in controllers
|
15
|
-
* Remove Gemfile.lock in the test folders to make travis CI to work
|
16
|
-
|
17
|
-
# 1.0.8
|
18
|
-
|
19
|
-
* Fixed Circular dependency detected in rails 5.2
|
20
|
-
|
21
|
-
# 1.0.7
|
22
|
-
|
23
|
-
* Fixed typo error in use_loader config flag
|
24
|
-
|
25
|
-
# 1.0.6 (revoked)
|
26
|
-
|
27
|
-
* Introduce use_loader config flag
|
3
|
+
* Support Trailblazer 2.1.0+
|
4
|
+
* Drop support for older version of Trailblazer
|
28
5
|
|
29
6
|
# 1.0.5
|
30
7
|
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
[![TRB Newsletter](https://img.shields.io/badge/TRB-newsletter-lightgrey.svg)](http://trailblazer.to/newsletter/)
|
7
7
|
[![Build
|
8
8
|
Status](https://travis-ci.org/trailblazer/trailblazer-rails.svg)](https://travis-ci.org/trailblazer/trailblazer-rails)
|
9
|
-
[![Gem Version](https://badge.fury.io/rb/trailblazer-rails.svg)](http://badge.fury.io/rb/
|
9
|
+
[![Gem Version](https://badge.fury.io/rb/trailblazer-rails.svg)](http://badge.fury.io/rb/trailblazer-rails)
|
10
10
|
|
11
11
|
## Overview
|
12
12
|
|
@@ -26,7 +26,7 @@ Add this line to your application's Gemfile:
|
|
26
26
|
gem 'trailblazer-rails'
|
27
27
|
```
|
28
28
|
|
29
|
-
Note that the
|
29
|
+
Note that the 2.x version only runs with TRB >= 2.1.0.
|
30
30
|
|
31
31
|
## License
|
32
32
|
|
data/Rakefile
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
module Trailblazer::Rails::Controller::Cell
|
2
|
-
private
|
2
|
+
private
|
3
3
|
|
4
4
|
module Render
|
5
|
-
def render(cell
|
6
|
-
return super unless cell.kind_of?(::Cell::ViewModel)
|
7
|
-
|
5
|
+
def render(cell=nil, options={}, *, &block)
|
6
|
+
return super unless cell.kind_of?(::Cell::ViewModel)
|
8
7
|
render_cell(cell, options)
|
9
8
|
end
|
10
9
|
|
@@ -14,7 +13,7 @@ module Trailblazer::Rails::Controller::Cell
|
|
14
13
|
# render the cell.
|
15
14
|
content = cell.()
|
16
15
|
|
17
|
-
render({html: content}.merge(options))
|
16
|
+
render( { html: content }.merge(options) )
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
@@ -1,20 +1,17 @@
|
|
1
1
|
module Trailblazer::Rails
|
2
2
|
module Controller
|
3
|
-
def run(operation, params
|
4
|
-
result = operation.(
|
5
|
-
_run_params(params),
|
6
|
-
*_run_runtime_options(*dependencies)
|
7
|
-
)
|
3
|
+
def run(operation, params=self.params, *dependencies)
|
4
|
+
result = operation.({params: _run_params(params) }.merge(*_run_runtime_options(*dependencies)))
|
8
5
|
|
9
|
-
|
6
|
+
@model = result[:model]
|
7
|
+
@form = Trailblazer::Rails::Form.new( result[ "contract.default" ], @model.class )
|
10
8
|
|
11
9
|
yield(result) if result.success? && block_given?
|
12
10
|
|
13
11
|
@_result = result
|
14
12
|
end
|
15
13
|
|
16
|
-
|
17
|
-
|
14
|
+
private
|
18
15
|
# Override to tweak params. Not recommended.
|
19
16
|
# Use a deserializer instead.
|
20
17
|
def _run_params(params)
|
@@ -22,7 +19,7 @@ module Trailblazer::Rails
|
|
22
19
|
end
|
23
20
|
|
24
21
|
# This is where we can inject Dry.RB containers and the like via dependencies.
|
25
|
-
def _run_runtime_options(options
|
22
|
+
def _run_runtime_options(options={}, *dependencies)
|
26
23
|
[_run_options(options), *dependencies]
|
27
24
|
end
|
28
25
|
|
@@ -32,15 +29,6 @@ module Trailblazer::Rails
|
|
32
29
|
options
|
33
30
|
end
|
34
31
|
|
35
|
-
def _assign_trb_ivars(result)
|
36
|
-
@model = result["model"]
|
37
|
-
@form = _wrap_with_trb_form(result["contract.default"], @model.class)
|
38
|
-
end
|
39
|
-
|
40
|
-
def _wrap_with_trb_form(form, model)
|
41
|
-
Trailblazer::Rails::Form.new(form, model)
|
42
|
-
end
|
43
|
-
|
44
32
|
module Result
|
45
33
|
def result
|
46
34
|
@_result
|
@@ -1,17 +1,65 @@
|
|
1
1
|
require "rails/railtie"
|
2
2
|
require "trailblazer/loader"
|
3
|
-
require "trailblazer/rails/railtie/loader"
|
4
|
-
require "trailblazer/rails/railtie/extend_application_controller"
|
5
3
|
|
6
4
|
module Trailblazer
|
7
5
|
class Railtie < ::Rails::Railtie
|
8
6
|
config.trailblazer = ActiveSupport::OrderedOptions.new
|
9
7
|
## Accept also an Array of controllers
|
10
|
-
config.trailblazer.application_controller ||=
|
11
|
-
config.trailblazer.
|
8
|
+
config.trailblazer.application_controller ||= 'ActionController::Base'
|
9
|
+
config.trailblazer.use_loader ||= true
|
12
10
|
|
13
|
-
|
14
|
-
|
11
|
+
def self.load_concepts(app)
|
12
|
+
# Loader.new.(insert: [ModelFile, before: Loader::AddConceptFiles]) { |file| require_dependency("#{app.root}/#{file}") }
|
13
|
+
load_for(app)
|
14
|
+
|
15
|
+
engines.each { |engine| load_for(engine) }
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.engines
|
19
|
+
if Gem::Version.new(::Rails.version) >= Gem::Version.new("4.1")
|
20
|
+
::Rails.application.railties.find_all { |tie| tie.is_a?(::Rails::Engine) }
|
21
|
+
else
|
22
|
+
::Rails.application.railties.engines
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.load_for(app)
|
27
|
+
Loader.new.(prepend: AllModelFiles, root: app.root) { |file| require_dependency(file) }
|
28
|
+
end
|
29
|
+
|
30
|
+
# This is to autoload Operation::Dispatch, etc. I'm simply assuming people find this helpful in Rails.
|
31
|
+
initializer "trailblazer.library_autoloading" do
|
32
|
+
end
|
33
|
+
|
34
|
+
# thank you, http://stackoverflow.com/a/17573888/465070
|
35
|
+
initializer 'trailblazer.install', after: "reform.form_extensions" do |app|
|
36
|
+
# the trb autoloading has to be run after initializers have been loaded, so we can tweak inclusion of features in
|
37
|
+
# initializers.
|
38
|
+
if config.trailblazer.use_loader
|
39
|
+
reloader_class.to_prepare do
|
40
|
+
Trailblazer::Railtie.load_concepts(app)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
initializer "trailblazer.application_controller", before: "finisher_hook" do |app|
|
46
|
+
reloader_class.to_prepare do
|
47
|
+
ActiveSupport.on_load(:action_controller) do |app|
|
48
|
+
Trailblazer::Railtie.extend_application_controller!(app)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Prepend model file, before the concept files like operation.rb get loaded.
|
54
|
+
ModelFile = ->(input, options) do
|
55
|
+
model = "app/models/#{options[:name]}.rb"
|
56
|
+
File.exist?(model) ? [model]+input : input
|
57
|
+
end
|
58
|
+
|
59
|
+
# Load all model files before any TRB files.
|
60
|
+
AllModelFiles = ->(input, options) do
|
61
|
+
Dir.glob("#{options[:root]}/app/models/**/*.rb") + input
|
62
|
+
end
|
15
63
|
|
16
64
|
private
|
17
65
|
|
@@ -19,11 +67,24 @@ module Trailblazer
|
|
19
67
|
# Rails 5.0.0.rc1 says:
|
20
68
|
# DEPRECATION WARNING: to_prepare is deprecated and will be removed from Rails 5.1
|
21
69
|
# (use ActiveSupport::Reloader.to_prepare instead)
|
22
|
-
if Gem.loaded_specs[
|
70
|
+
if Gem.loaded_specs['activesupport'].version >= Gem::Version.new('5')
|
23
71
|
ActiveSupport::Reloader
|
24
72
|
else
|
25
73
|
ActionDispatch::Reloader
|
26
74
|
end
|
27
75
|
end
|
76
|
+
|
77
|
+
module ExtendApplicationController
|
78
|
+
def extend_application_controller!(app)
|
79
|
+
controllers = Array(::Rails.application.config.trailblazer.application_controller).map{ |x| x.to_s }
|
80
|
+
if controllers.include? app.to_s
|
81
|
+
app.send :include, Trailblazer::Rails::Controller
|
82
|
+
app.send :include, Trailblazer::Rails::Controller::Cell if defined?(::Cell)
|
83
|
+
end
|
84
|
+
app
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
extend ExtendApplicationController
|
28
89
|
end
|
29
90
|
end
|
data/trailblazer-rails.gemspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
lib = File.expand_path('lib',
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
3
|
require 'trailblazer/rails/version'
|
4
4
|
|
@@ -8,20 +8,20 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["Nick Sutterer"]
|
9
9
|
spec.email = ["apotonick@gmail.com"]
|
10
10
|
|
11
|
-
spec.summary =
|
11
|
+
spec.summary = %q{Convenient Rails support for Trailblazer.}
|
12
12
|
spec.homepage = "http://trailblazer.to/gems/trailblazer/2.0/rails.html"
|
13
13
|
spec.license = "MIT"
|
14
14
|
|
15
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test
|
16
|
-
spec.executables = spec.files.grep(%r
|
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
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
|
-
spec.add_dependency "
|
20
|
-
spec.add_dependency "trailblazer", "~> 2.0.0"
|
19
|
+
spec.add_dependency "trailblazer", ">= 2.1.0.beta1", "< 2.2.0"
|
21
20
|
spec.add_dependency "trailblazer-loader", ">= 0.1.0"
|
21
|
+
spec.add_dependency "reform-rails", ">= 0.1.4", "< 0.2.0"
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.10"
|
24
|
-
spec.add_development_dependency "minitest"
|
25
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
-
spec.add_development_dependency "
|
25
|
+
spec.add_development_dependency "minitest"
|
26
|
+
|
27
27
|
end
|
metadata
CHANGED
@@ -1,57 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trailblazer-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
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-
|
11
|
+
date: 2018-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: trailblazer
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.1.0.beta1
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.2.0
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
29
|
+
version: 2.1.0.beta1
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.2.0
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: trailblazer
|
34
|
+
name: trailblazer-loader
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
|
-
- - "
|
37
|
+
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
39
|
+
version: 0.1.0
|
34
40
|
type: :runtime
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
|
-
- - "
|
44
|
+
- - ">="
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
46
|
+
version: 0.1.0
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
48
|
+
name: reform-rails
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
51
|
- - ">="
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.1.
|
53
|
+
version: 0.1.4
|
54
|
+
- - "<"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.2.0
|
48
57
|
type: :runtime
|
49
58
|
prerelease: false
|
50
59
|
version_requirements: !ruby/object:Gem::Requirement
|
51
60
|
requirements:
|
52
61
|
- - ">="
|
53
62
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.1.
|
63
|
+
version: 0.1.4
|
64
|
+
- - "<"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 0.2.0
|
55
67
|
- !ruby/object:Gem::Dependency
|
56
68
|
name: bundler
|
57
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,20 +78,6 @@ dependencies:
|
|
66
78
|
- - "~>"
|
67
79
|
- !ruby/object:Gem::Version
|
68
80
|
version: '1.10'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: minitest
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
81
|
- !ruby/object:Gem::Dependency
|
84
82
|
name: rake
|
85
83
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,7 +93,7 @@ dependencies:
|
|
95
93
|
- !ruby/object:Gem::Version
|
96
94
|
version: '10.0'
|
97
95
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
96
|
+
name: minitest
|
99
97
|
requirement: !ruby/object:Gem::Requirement
|
100
98
|
requirements:
|
101
99
|
- - ">="
|
@@ -116,8 +114,7 @@ extensions: []
|
|
116
114
|
extra_rdoc_files: []
|
117
115
|
files:
|
118
116
|
- ".gitignore"
|
119
|
-
- ".
|
120
|
-
- ".rubocop.yml"
|
117
|
+
- ".ruby-version"
|
121
118
|
- ".travis.yml"
|
122
119
|
- CHANGES.md
|
123
120
|
- Gemfile
|
@@ -131,8 +128,6 @@ files:
|
|
131
128
|
- lib/trailblazer/rails/controller.rb
|
132
129
|
- lib/trailblazer/rails/form.rb
|
133
130
|
- lib/trailblazer/rails/railtie.rb
|
134
|
-
- lib/trailblazer/rails/railtie/extend_application_controller.rb
|
135
|
-
- lib/trailblazer/rails/railtie/loader.rb
|
136
131
|
- lib/trailblazer/rails/test/integration.rb
|
137
132
|
- lib/trailblazer/rails/version.rb
|
138
133
|
- trailblazer-rails.gemspec
|
@@ -156,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
151
|
version: '0'
|
157
152
|
requirements: []
|
158
153
|
rubyforge_project:
|
159
|
-
rubygems_version: 2.
|
154
|
+
rubygems_version: 2.6.11
|
160
155
|
signing_key:
|
161
156
|
specification_version: 4
|
162
157
|
summary: Convenient Rails support for Trailblazer.
|
@@ -1,114 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
TargetRubyVersion: 2.5.0
|
3
|
-
DisplayCopNames: true
|
4
|
-
Layout/CaseIndentation:
|
5
|
-
IndentOneStep: true
|
6
|
-
Layout/FirstArrayElementLineBreak:
|
7
|
-
Enabled: true
|
8
|
-
Layout/FirstHashElementLineBreak:
|
9
|
-
Enabled: true
|
10
|
-
Layout/FirstMethodArgumentLineBreak:
|
11
|
-
Enabled: true
|
12
|
-
Layout/FirstMethodParameterLineBreak:
|
13
|
-
Enabled: true
|
14
|
-
Layout/MultilineAssignmentLayout:
|
15
|
-
Enabled: true
|
16
|
-
EnforcedStyle: same_line
|
17
|
-
Layout/SpaceInsideHashLiteralBraces:
|
18
|
-
EnforcedStyle: no_space
|
19
|
-
Metrics/LineLength:
|
20
|
-
Max: 130
|
21
|
-
Metrics/ParameterLists:
|
22
|
-
Max: 5
|
23
|
-
Naming/VariableNumber:
|
24
|
-
EnforcedStyle: snake_case
|
25
|
-
Style/AndOr:
|
26
|
-
EnforcedStyle: conditionals
|
27
|
-
Style/AutoResourceCleanup:
|
28
|
-
Enabled: true
|
29
|
-
Style/CollectionMethods:
|
30
|
-
Enabled: true
|
31
|
-
Style/Documentation:
|
32
|
-
Enabled: false
|
33
|
-
Style/EmptyLiteral:
|
34
|
-
Enabled: false
|
35
|
-
Style/EmptyMethod:
|
36
|
-
EnforcedStyle: expanded
|
37
|
-
Style/FormatStringToken:
|
38
|
-
EnforcedStyle: template
|
39
|
-
Style/ImplicitRuntimeError:
|
40
|
-
Enabled: true
|
41
|
-
Style/MethodCalledOnDoEndBlock:
|
42
|
-
Enabled: true
|
43
|
-
Style/MethodDefParentheses:
|
44
|
-
EnforcedStyle: require_parentheses
|
45
|
-
Style/MissingElse:
|
46
|
-
Enabled: true
|
47
|
-
EnforcedStyle: case
|
48
|
-
Style/NumericLiterals:
|
49
|
-
Enabled: false
|
50
|
-
Style/OptionHash:
|
51
|
-
Enabled: true
|
52
|
-
Style/PercentLiteralDelimiters:
|
53
|
-
PreferredDelimiters:
|
54
|
-
"%w": "[]"
|
55
|
-
"%W": "[]"
|
56
|
-
"%i": "[]"
|
57
|
-
"%I": "[]"
|
58
|
-
"%r": "()"
|
59
|
-
Style/ReturnNil:
|
60
|
-
Enabled: true
|
61
|
-
Style/SafeNavigation:
|
62
|
-
Enabled: false
|
63
|
-
Style/Send:
|
64
|
-
Enabled: true
|
65
|
-
Style/SignalException:
|
66
|
-
EnforcedStyle: semantic
|
67
|
-
Style/StringLiterals:
|
68
|
-
EnforcedStyle: double_quotes
|
69
|
-
Style/StringLiteralsInInterpolation:
|
70
|
-
EnforcedStyle: double_quotes
|
71
|
-
Style/StringMethods:
|
72
|
-
Enabled: true
|
73
|
-
Style/SymbolArray:
|
74
|
-
Enabled: true
|
75
|
-
# this allows in rspec to have expect { } with multiple lines
|
76
|
-
Style/BlockDelimiters:
|
77
|
-
EnforcedStyle: braces_for_chaining
|
78
|
-
Layout/EndOfLine:
|
79
|
-
Enabled: false
|
80
|
-
# don't need these checks in test folders
|
81
|
-
Metrics/ModuleLength:
|
82
|
-
Exclude:
|
83
|
-
- "spec/**/*"
|
84
|
-
- "test/**/*"
|
85
|
-
Metrics/BlockLength:
|
86
|
-
Exclude:
|
87
|
-
- "spec/**/*"
|
88
|
-
- "test/**/*"
|
89
|
-
- "*.gemspec" # definitely not in the gemspec
|
90
|
-
Metrics/MethodLength:
|
91
|
-
Max: 20
|
92
|
-
Lint/UnreachableCode:
|
93
|
-
Description: 'Unreachable code.'
|
94
|
-
Enabled: false
|
95
|
-
Lint/Void:
|
96
|
-
Enabled: false
|
97
|
-
Layout/AlignHash:
|
98
|
-
EnforcedLastArgumentHashStyle: ignore_implicit
|
99
|
-
Metrics/AbcSize:
|
100
|
-
Max: 25
|
101
|
-
Style/LambdaCall:
|
102
|
-
Enabled: false
|
103
|
-
# This to fix lots of failure in trailblazer-operation tests
|
104
|
-
Style/Semicolon:
|
105
|
-
Enabled: false
|
106
|
-
Naming/UncommunicativeMethodParamName:
|
107
|
-
Enabled: false
|
108
|
-
Style/ClassAndModuleChildren:
|
109
|
-
Enabled: false
|
110
|
-
Layout/LeadingCommentSpace:
|
111
|
-
Exclude:
|
112
|
-
- 'test/docs/**/*'
|
113
|
-
Layout/AlignHash:
|
114
|
-
EnforcedHashRocketStyle: table
|
data/.rubocop.yml
DELETED
@@ -1,28 +0,0 @@
|
|
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(&: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
|
@@ -1,63 +0,0 @@
|
|
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 # rubocop:disable Metrics/BlockLength
|
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.select { |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 = lambda do |input, options|
|
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 = lambda do |input, options|
|
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
|
-
|
48
|
-
# TODO: remove me in v1.1.0
|
49
|
-
if config.trailblazer.use_loader.to_s.present?
|
50
|
-
warn "DEPRECATION WARNING [trailblazer-rails]: please use config.trailblazer.enable_loader" \
|
51
|
-
" to enable/disable the loader, config.trailblazer.use_loader will be removed from version 1.1.0"
|
52
|
-
end
|
53
|
-
|
54
|
-
if config.trailblazer.enable_loader || config.trailblazer.use_loader
|
55
|
-
reloader_class.to_prepare do
|
56
|
-
Trailblazer::Railtie.load_concepts(app)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|