trailblazer-rails 1.0.9 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75dc8012bc26b4744c1e9d9bbbac1a9c48bb2dfbb2a2fcc3666cb90dbf5bb98c
4
- data.tar.gz: 448a1646c41e7b061a75466201fd2dfc39a792952ef57c71d744854bafe7b894
3
+ metadata.gz: db779c924f25b07c73639fafabed8bb50358d608d4b431ae4442bcd41a8e9ac2
4
+ data.tar.gz: c8638b5f985eee0365c133a67b78fdc27573ce3e73ce05e905e7ad3ae2773d28
5
5
  SHA512:
6
- metadata.gz: 4d6b74c528958964c57ec7a01d071f46800ac6788419be2c968901132a3acd7a7baac93df43d86913bca100072b213280761b94c0733deaf414649ced759d827
7
- data.tar.gz: f2cc72a1e83d51bdb5045fb5cfd4a6fde0b9fb6b7e9312b2eb96bcc3058aa815a475d10958828b5291a8e252d1e3ee9ac30dcb72d49d2ac0aa6d7fb347e55a62
6
+ metadata.gz: bc3da31ae65846ddd42e9127f9825e02698ecb5df8759ba9faa797cca1ed2d95d71748e13877b26f2d5da9075954ccb2126aee8400188a37b3f1b94fe9b1bee5
7
+ data.tar.gz: ee91cb041f488ab42032a7be71592767be0a00d0827b0797483ddff2e8bf57785871a6d032846e59852aa68dccba2bb6cd7b238939535d3ff17572c4bff1d1a6
data/.gitignore CHANGED
@@ -1,12 +1,12 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- test/**/*.log
11
- test/**/db/*.sqlite3
12
- test/**/Gemfile.lock
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ test/**/*.log
11
+ test/**/db/*.sqlite3
12
+ test/**/Gemfile.lock
@@ -0,0 +1,101 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+ Layout/CaseIndentation:
4
+ IndentOneStep: true
5
+ Layout/FirstArrayElementLineBreak:
6
+ Enabled: true
7
+ Layout/FirstHashElementLineBreak:
8
+ Enabled: true
9
+ Layout/FirstMethodArgumentLineBreak:
10
+ Enabled: true
11
+ Layout/FirstMethodParameterLineBreak:
12
+ Enabled: true
13
+ Layout/MultilineAssignmentLayout:
14
+ Enabled: true
15
+ EnforcedStyle: same_line
16
+ Layout/SpaceInsideHashLiteralBraces:
17
+ EnforcedStyle: no_space
18
+ Metrics/LineLength:
19
+ Max: 130
20
+ Metrics/ParameterLists:
21
+ Max: 5
22
+ Naming/VariableNumber:
23
+ EnforcedStyle: snake_case
24
+ Style/AndOr:
25
+ EnforcedStyle: conditionals
26
+ Style/AutoResourceCleanup:
27
+ Enabled: true
28
+ Style/CollectionMethods:
29
+ Enabled: true
30
+ Style/Documentation:
31
+ Enabled: false
32
+ Style/EmptyLiteral:
33
+ Enabled: false
34
+ Style/EmptyMethod:
35
+ EnforcedStyle: expanded
36
+ Style/FormatStringToken:
37
+ EnforcedStyle: template
38
+ Style/ImplicitRuntimeError:
39
+ Enabled: true
40
+ Style/MethodCalledOnDoEndBlock:
41
+ Enabled: true
42
+ Style/MethodDefParentheses:
43
+ EnforcedStyle: require_parentheses
44
+ Style/MissingElse:
45
+ Enabled: true
46
+ EnforcedStyle: case
47
+ Style/NumericLiterals:
48
+ Enabled: false
49
+ Style/OptionHash:
50
+ Enabled: true
51
+ Style/PercentLiteralDelimiters:
52
+ PreferredDelimiters:
53
+ "%w": "[]"
54
+ "%W": "[]"
55
+ "%i": "[]"
56
+ "%I": "[]"
57
+ "%r": "()"
58
+ Style/ReturnNil:
59
+ Enabled: true
60
+ Style/SafeNavigation:
61
+ Enabled: false
62
+ Style/Send:
63
+ Enabled: true
64
+ Style/SignalException:
65
+ EnforcedStyle: semantic
66
+ Style/StringLiterals:
67
+ EnforcedStyle: double_quotes
68
+ Style/StringLiteralsInInterpolation:
69
+ EnforcedStyle: double_quotes
70
+ Style/StringMethods:
71
+ Enabled: true
72
+ Style/SymbolArray:
73
+ Enabled: true
74
+ # this allows in rspec to have expect { } with multiple lines
75
+ Style/BlockDelimiters:
76
+ EnforcedStyle: braces_for_chaining
77
+ Layout/EndOfLine:
78
+ Enabled: false
79
+ # don't need these checks in test folders
80
+ Metrics/ModuleLength:
81
+ Exclude:
82
+ - "spec/**/*"
83
+ - "test/**/*"
84
+ Metrics/BlockLength:
85
+ Exclude:
86
+ - "spec/**/*"
87
+ - "test/**/*"
88
+ - "*.gemspec" # definitely not in the gemspec
89
+ Metrics/MethodLength:
90
+ Max: 20
91
+ Lint/UnreachableCode:
92
+ Description: 'Unreachable code.'
93
+ Enabled: false
94
+ Lint/Void:
95
+ Enabled: false
96
+ Layout/AlignHash:
97
+ EnforcedLastArgumentHashStyle: ignore_implicit
98
+ Metrics/AbcSize:
99
+ Max: 25
100
+ Style/LambdaCall:
101
+ Enabled: false
data/.rubocop.yml ADDED
@@ -0,0 +1,11 @@
1
+ inherit_from:
2
+ - https://raw.githubusercontent.com/trailblazer/meta/master/rubocop.yml
3
+
4
+ Style/ClassAndModuleChildren:
5
+ Enabled: false
6
+
7
+ Style/StringLiterals:
8
+ Enabled: false
9
+
10
+ Style/Send:
11
+ Enabled: false
data/.travis.yml CHANGED
@@ -1,17 +1,22 @@
1
- language: ruby
2
- matrix:
3
- include:
4
- - rvm: 2.3.1
5
- env: TEST_SUITE=rails4.2
6
- gemfile: test/rails4.2/Gemfile
7
- - rvm: 2.4.1
8
- env: TEST_SUITE=rails5.0
9
- gemfile: test/rails5.0/Gemfile
10
- - rvm: 2.4.1
11
- env: TEST_SUITE=rails5.1
12
- gemfile: test/rails5.1/Gemfile
13
- - rvm: 2.5.1
14
- env: TEST_SUITE=rails5.2
15
- gemfile: test/rails5.2/Gemfile
16
-
17
- script: cd test/$TEST_SUITE && bundle install && bundle exec rake test
1
+ sudo: false
2
+ language: ruby
3
+ cache: bundler
4
+ matrix:
5
+ include:
6
+ - rvm: 2.4.1
7
+ env: TEST_SUITE=rails4.2
8
+ gemfile: test/rails4.2/Gemfile
9
+
10
+ - rvm: 2.4.1
11
+ env: TEST_SUITE=rails5.0
12
+ gemfile: test/rails5.0/Gemfile
13
+
14
+ - rvm: 2.4.1
15
+ env: TEST_SUITE=rails5.1
16
+ gemfile: test/rails5.1/Gemfile
17
+
18
+ - rvm: 2.5.1
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
data/CHANGES.md CHANGED
@@ -1,111 +1,116 @@
1
- # 1.0.9
2
-
3
- * `Trailblazer::Rails::Railtie` divided in 2 modules:
4
- * `Loader` -> require_dependecy `concepts`
5
- * `ExtendApplicationController` -> include `run` and `render` in controllers
6
- * Remove Gemfile.lock in the test folders to make travis CI to work
7
-
8
- # 1.0.8
9
-
10
- * Fixed Circular dependency detected in rails 5.2
11
-
12
- # 1.0.7
13
-
14
- * Fixed typo error in use_loader config flag
15
-
16
- # 1.0.6 (revoked)
17
-
18
- * Introduce use_loader config flag
19
-
20
- # 1.0.5
21
-
22
- * Hook trailblazer application_controller initializer to finisher_hook
23
-
24
- # 1.0.4
25
-
26
- * Make `Railtie::extend_application_controller!` overwriteable via a module.
27
-
28
- # 1.0.3
29
-
30
- * Return the computed application controller constant from `Railtie::extend_application_controller!` to make `compat` code simpler.
31
-
32
- # 1.0.2
33
-
34
- * Allow configuring `ApplicationController` constant via `config.trailblazer.application_controller`.
35
-
36
- # 1.0.1
37
-
38
- * Allow using this gem without `cells,` by loading cells support only when the `cells` gem got detected. Thanks to @promisedlandt.
39
-
40
- # 1.0.0
41
-
42
- * Runs only with >= Trailblazer 2.0.0.
43
- * Removed `Controller#form`, `#present` and `#respond`. The latter is now [replaced with `Endpoint`](https://github.com/trailblazer/trailblazer-endpoint/). The only operation trigger is `Controller#run`.
44
- * Added support for explicit `render cell(Artist::Cell::Index, model)`.
45
- * Autoloading got replaced with explicit requires.
46
-
47
- # 0.4.0
48
-
49
- * Better engines support.
50
- * Fix `Responder#errors` by simply removing it and letting `Operation#errors` return the contract errors.
51
-
52
- # 0.3.2
53
-
54
- * Make it work with Rails 3.x, again.
55
-
56
- # 0.3.1
57
-
58
- * Fix loading of `reform-rails`.
59
-
60
- # 0.3.0
61
-
62
- * Require `reform-rails` as a static dependency. This simplifies the user's setup significantly.
63
- * Run the `Railtie` after `reform.form_extensions` and allow reform-rails to do its setup work, then load concepts.
64
-
65
- # 0.2.4
66
-
67
- * Require `trailblazer-loader-0.0.7`.
68
- * Fix sorting, model files are now always required first.
69
- * Manually include `Operation::Controller` in `ApplicationController` for every reload.
70
-
71
- # 0.2.3
72
-
73
- * Bump to `trailblazer-loader` 0.0.4.
74
-
75
- # 0.2.2
76
-
77
- * Remove cells loading code, this happens via trailblazer-loader now.
78
- * We now load the concept's model file if it exists.
79
-
80
- # 0.2.1
81
-
82
- * Require `trailblazer-loader`.
83
-
84
- # 0.2.0
85
-
86
- * Use `trailblazer-loader` for loading operations and associated files, now. Note that `operations.rb` now is `operation.rb` (hence the minor bump).
87
- * The `Operation::Controller` module is not included into `ApplicationController` automatically.
88
- * Added `Trailblazer::Test::Integration`.
89
-
90
- # 0.1.6
91
-
92
- * Fix `Controller#run`, which now returns the operation instance instead of the `Else` object.
93
-
94
- # 0.1.5
95
-
96
- * Treat all requests as `params` requests unless the operation has a representer mixed in. If you don't want that, you can override using `is_document: false`. This appears to be the smoothest solution for all. Thanks to @Scharrels for discussion.
97
- * In `Controller#form`, the options argument is now passed into `form.prepopulate!(options)`. This allows to use arbitrary options and the `options[:params]` for prepopulation. Thanks @sauy7 for discussion.
98
-
99
- # 0.1.4
100
-
101
- * Treat `:js` requests as non-document, too.
102
- * `Controller#form` now returns the form object and not the operation.
103
- * In `Controller`, `#form`, `#present`, `#run` and `#respond` now all have the same API: `run(constant, options)`. If you want to pass a custom params hash, use `run Comment::Create, params: {..}`.
104
-
105
- # 0.1.3
106
-
107
- * `Operation::contract` works properly with `Operation::ActiveModel` mixed in.
108
-
109
- # 0.1.2
110
-
111
- * First version running with Trailblazer 1.0.0.
1
+ # 1.0.10
2
+
3
+ * Reintroduced railtie dependency 4.x +
4
+ * Config flag use_loader renamed with enable_loader
5
+
6
+ # 1.0.9
7
+
8
+ * `Trailblazer::Rails::Railtie` divided in 2 modules:
9
+ * `Loader` -> require_dependecy `concepts`
10
+ * `ExtendApplicationController` -> include `run` and `render` in controllers
11
+ * Remove Gemfile.lock in the test folders to make travis CI to work
12
+
13
+ # 1.0.8
14
+
15
+ * Fixed Circular dependency detected in rails 5.2
16
+
17
+ # 1.0.7
18
+
19
+ * Fixed typo error in use_loader config flag
20
+
21
+ # 1.0.6 (revoked)
22
+
23
+ * Introduce use_loader config flag
24
+
25
+ # 1.0.5
26
+
27
+ * Hook trailblazer application_controller initializer to finisher_hook
28
+
29
+ # 1.0.4
30
+
31
+ * Make `Railtie::extend_application_controller!` overwriteable via a module.
32
+
33
+ # 1.0.3
34
+
35
+ * Return the computed application controller constant from `Railtie::extend_application_controller!` to make `compat` code simpler.
36
+
37
+ # 1.0.2
38
+
39
+ * Allow configuring `ApplicationController` constant via `config.trailblazer.application_controller`.
40
+
41
+ # 1.0.1
42
+
43
+ * Allow using this gem without `cells,` by loading cells support only when the `cells` gem got detected. Thanks to @promisedlandt.
44
+
45
+ # 1.0.0
46
+
47
+ * Runs only with >= Trailblazer 2.0.0.
48
+ * Removed `Controller#form`, `#present` and `#respond`. The latter is now [replaced with `Endpoint`](https://github.com/trailblazer/trailblazer-endpoint/). The only operation trigger is `Controller#run`.
49
+ * Added support for explicit `render cell(Artist::Cell::Index, model)`.
50
+ * Autoloading got replaced with explicit requires.
51
+
52
+ # 0.4.0
53
+
54
+ * Better engines support.
55
+ * Fix `Responder#errors` by simply removing it and letting `Operation#errors` return the contract errors.
56
+
57
+ # 0.3.2
58
+
59
+ * Make it work with Rails 3.x, again.
60
+
61
+ # 0.3.1
62
+
63
+ * Fix loading of `reform-rails`.
64
+
65
+ # 0.3.0
66
+
67
+ * Require `reform-rails` as a static dependency. This simplifies the user's setup significantly.
68
+ * Run the `Railtie` after `reform.form_extensions` and allow reform-rails to do its setup work, then load concepts.
69
+
70
+ # 0.2.4
71
+
72
+ * Require `trailblazer-loader-0.0.7`.
73
+ * Fix sorting, model files are now always required first.
74
+ * Manually include `Operation::Controller` in `ApplicationController` for every reload.
75
+
76
+ # 0.2.3
77
+
78
+ * Bump to `trailblazer-loader` 0.0.4.
79
+
80
+ # 0.2.2
81
+
82
+ * Remove cells loading code, this happens via trailblazer-loader now.
83
+ * We now load the concept's model file if it exists.
84
+
85
+ # 0.2.1
86
+
87
+ * Require `trailblazer-loader`.
88
+
89
+ # 0.2.0
90
+
91
+ * Use `trailblazer-loader` for loading operations and associated files, now. Note that `operations.rb` now is `operation.rb` (hence the minor bump).
92
+ * The `Operation::Controller` module is not included into `ApplicationController` automatically.
93
+ * Added `Trailblazer::Test::Integration`.
94
+
95
+ # 0.1.6
96
+
97
+ * Fix `Controller#run`, which now returns the operation instance instead of the `Else` object.
98
+
99
+ # 0.1.5
100
+
101
+ * Treat all requests as `params` requests unless the operation has a representer mixed in. If you don't want that, you can override using `is_document: false`. This appears to be the smoothest solution for all. Thanks to @Scharrels for discussion.
102
+ * In `Controller#form`, the options argument is now passed into `form.prepopulate!(options)`. This allows to use arbitrary options and the `options[:params]` for prepopulation. Thanks @sauy7 for discussion.
103
+
104
+ # 0.1.4
105
+
106
+ * Treat `:js` requests as non-document, too.
107
+ * `Controller#form` now returns the form object and not the operation.
108
+ * In `Controller`, `#form`, `#present`, `#run` and `#respond` now all have the same API: `run(constant, options)`. If you want to pass a custom params hash, use `run Comment::Create, params: {..}`.
109
+
110
+ # 0.1.3
111
+
112
+ * `Operation::contract` works properly with `Operation::ActiveModel` mixed in.
113
+
114
+ # 0.1.2
115
+
116
+ * First version running with Trailblazer 1.0.0.
data/LICENSE.txt CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2015 Nick Sutterer
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all 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,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Nick Sutterer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all 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,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,34 +1,34 @@
1
- # Trailblazer::Rails
2
-
3
- *Trailblazer in your Rails controllers.*
4
-
5
- [![Gitter Chat](https://badges.gitter.im/trailblazer/chat.svg)](https://gitter.im/trailblazer/chat)
6
- [![TRB Newsletter](https://img.shields.io/badge/TRB-newsletter-lightgrey.svg)](http://trailblazer.to/newsletter/)
7
- [![Build
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/cells)
10
-
11
- ## Overview
12
-
13
- `trailblazer-rails` helps you with the following.
14
-
15
- * Running operations in your controller actions.
16
- * Minimalistic integration tests ("smoke tests") to test controller/operation wiring.
17
- * Rendering cells instead of an ActionView in a controller action.
18
-
19
- Please refer to the [full documentation for more](http://trailblazer.to/gems/trailblazer/2.0/rails.html).
20
-
21
- ## Installation
22
-
23
- Add this line to your application's Gemfile:
24
-
25
- ```ruby
26
- gem 'trailblazer-rails'
27
- ```
28
-
29
- Note that the 1.x version only runs with TRB >= 2.0.0.
30
-
31
- ## License
32
-
33
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
34
-
1
+ # Trailblazer::Rails
2
+
3
+ *Trailblazer in your Rails controllers.*
4
+
5
+ [![Gitter Chat](https://badges.gitter.im/trailblazer/chat.svg)](https://gitter.im/trailblazer/chat)
6
+ [![TRB Newsletter](https://img.shields.io/badge/TRB-newsletter-lightgrey.svg)](http://trailblazer.to/newsletter/)
7
+ [![Build
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/cells)
10
+
11
+ ## Overview
12
+
13
+ `trailblazer-rails` helps you with the following.
14
+
15
+ * Running operations in your controller actions.
16
+ * Minimalistic integration tests ("smoke tests") to test controller/operation wiring.
17
+ * Rendering cells instead of an ActionView in a controller action.
18
+
19
+ Please refer to the [full documentation for more](http://trailblazer.to/gems/trailblazer/2.0/rails.html).
20
+
21
+ ## Installation
22
+
23
+ Add this line to your application's Gemfile:
24
+
25
+ ```ruby
26
+ gem 'trailblazer-rails'
27
+ ```
28
+
29
+ Note that the 1.x version only runs with TRB >= 2.0.0.
30
+
31
+ ## License
32
+
33
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
34
+
data/Rakefile CHANGED
@@ -7,4 +7,4 @@ Rake::TestTask.new(:test) do |t|
7
7
  t.test_files = FileList['test/**/*_test.rb']
8
8
  end
9
9
 
10
- task :default => :test
10
+ task default: :test
@@ -1,21 +1,22 @@
1
- module Trailblazer::Rails::Controller::Cell
2
- private
3
-
4
- module Render
5
- def render(cell=nil, options={}, *, &block)
6
- return super unless cell.kind_of?(::Cell::ViewModel)
7
- render_cell(cell, options)
8
- end
9
-
10
- def render_cell(cell, options)
11
- options = options.reverse_merge(layout: true)
12
-
13
- # render the cell.
14
- content = cell.()
15
-
16
- render( { html: content }.merge(options) )
17
- end
18
- end
19
-
20
- include Render
21
- end
1
+ module Trailblazer::Rails::Controller::Cell
2
+ private # rubocop:disable Lint/UselessAccessModifier
3
+
4
+ module Render
5
+ def render(cell = nil, options = {}, *, &block)
6
+ return super unless cell.kind_of?(::Cell::ViewModel) # rubocop:disable Style/ClassCheck
7
+
8
+ render_cell(cell, options)
9
+ end
10
+
11
+ def render_cell(cell, options)
12
+ options = options.reverse_merge(layout: true)
13
+
14
+ # render the cell.
15
+ content = cell.()
16
+
17
+ render({html: content}.merge(options))
18
+ end
19
+ end
20
+
21
+ include Render
22
+ end
@@ -1,43 +1,52 @@
1
- module Trailblazer::Rails
2
- module Controller
3
- def run(operation, params=self.params, *dependencies)
4
- result = operation.(
5
- _run_params(params),
6
- *_run_runtime_options(*dependencies)
7
- )
8
-
9
- @form = Trailblazer::Rails::Form.new(result["contract.default"], result["model"].class)
10
- @model = result["model"]
11
-
12
- yield(result) if result.success? && block_given?
13
-
14
- @_result = result
15
- end
16
-
17
- private
18
- # Override to tweak params. Not recommended.
19
- # Use a deserializer instead.
20
- def _run_params(params)
21
- params
22
- end
23
-
24
- # This is where we can inject Dry.RB containers and the like via dependencies.
25
- def _run_runtime_options(options={}, *dependencies)
26
- [_run_options(options), *dependencies]
27
- end
28
-
29
- # Override this to inject dependencies such as "current_user"
30
- # into the runtime options.
31
- def _run_options(options)
32
- options
33
- end
34
-
35
- module Result
36
- def result
37
- @_result
38
- end
39
- end
40
-
41
- include Result
42
- end
43
- end
1
+ module Trailblazer::Rails
2
+ module Controller
3
+ def run(operation, params = self.params, *dependencies)
4
+ result = operation.(
5
+ _run_params(params),
6
+ *_run_runtime_options(*dependencies)
7
+ )
8
+
9
+ _assign_trb_ivars(result)
10
+
11
+ yield(result) if result.success? && block_given?
12
+
13
+ @_result = result
14
+ end
15
+
16
+ private
17
+
18
+ # Override to tweak params. Not recommended.
19
+ # Use a deserializer instead.
20
+ def _run_params(params)
21
+ params
22
+ end
23
+
24
+ # This is where we can inject Dry.RB containers and the like via dependencies.
25
+ def _run_runtime_options(options = {}, *dependencies)
26
+ [_run_options(options), *dependencies]
27
+ end
28
+
29
+ # Override this to inject dependencies such as "current_user"
30
+ # into the runtime options.
31
+ def _run_options(options)
32
+ options
33
+ end
34
+
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
+ module Result
45
+ def result
46
+ @_result
47
+ end
48
+ end
49
+
50
+ include Result
51
+ end
52
+ end
@@ -1,29 +1,30 @@
1
- require "rails/railtie"
2
- require "trailblazer/loader"
3
- require "trailblazer/rails/railtie/loader"
4
- require "trailblazer/rails/railtie/extend_application_controller"
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
-
13
- include Loader
14
- include ExtendApplicationController
15
-
16
- private
17
-
18
- def reloader_class
19
- # Rails 5.0.0.rc1 says:
20
- # DEPRECATION WARNING: to_prepare is deprecated and will be removed from Rails 5.1
21
- # (use ActiveSupport::Reloader.to_prepare instead)
22
- if Gem.loaded_specs['activesupport'].version >= Gem::Version.new('5')
23
- ActiveSupport::Reloader
24
- else
25
- ActionDispatch::Reloader
26
- end
27
- end
28
- end
29
- end
1
+ require "rails/railtie"
2
+ require "trailblazer/loader"
3
+ require "trailblazer/rails/railtie/loader"
4
+ require "trailblazer/rails/railtie/extend_application_controller"
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.enable_loader ||= true
12
+ config.trailblazer.use_loader ||= true # TODO: remove with next release
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
@@ -1,28 +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 |app|
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
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,56 +1,63 @@
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
+ 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 the next version!
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 > 2.1.6"
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
@@ -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 = "1.0.9"
4
- end
5
- end
1
+ module Trailblazer
2
+ module Rails
3
+ VERSION = "1.0.10".freeze
4
+ end
5
+ end
@@ -1,31 +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|spec|features)/}) }
16
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
17
- spec.require_paths = ["lib"]
18
-
19
- spec.add_dependency "trailblazer", "~> 2.0.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 "actionpack", '>= 3.0.0' # Rails is optional.
27
- spec.add_development_dependency "sqlite3"
28
- # spec.add_development_dependency "responders"
29
-
30
- spec.add_development_dependency "multi_json"
31
- end
1
+ lib = File.expand_path('lib', __dir__)
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 = "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|spec|features)/}) }
16
+ spec.executables = spec.files.grep(%r(^exe/)) { |f| File.basename(f) }
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_dependency "railties", '>= 4.0.0'
20
+ spec.add_dependency "trailblazer", "~> 2.0.0"
21
+ spec.add_dependency "trailblazer-loader", ">= 0.1.0"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.10"
24
+ spec.add_development_dependency "minitest"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rubocop"
27
+ end
metadata CHANGED
@@ -1,63 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trailblazer-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: 1.0.10
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-06-06 00:00:00.000000000 Z
11
+ date: 2018-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: trailblazer
14
+ name: railties
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.0
19
+ version: 4.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.0
26
+ version: 4.0.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: trailblazer-loader
28
+ name: trailblazer
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.1.0
33
+ version: 2.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.1.0
40
+ version: 2.0.0
41
41
  - !ruby/object:Gem::Dependency
42
- name: reform-rails
42
+ name: trailblazer-loader
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 0.1.4
48
- - - "<"
49
- - !ruby/object:Gem::Version
50
- version: 0.2.0
47
+ version: 0.1.0
51
48
  type: :runtime
52
49
  prerelease: false
53
50
  version_requirements: !ruby/object:Gem::Requirement
54
51
  requirements:
55
52
  - - ">="
56
53
  - !ruby/object:Gem::Version
57
- version: 0.1.4
58
- - - "<"
59
- - !ruby/object:Gem::Version
60
- version: 0.2.0
54
+ version: 0.1.0
61
55
  - !ruby/object:Gem::Dependency
62
56
  name: bundler
63
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,20 +66,6 @@ dependencies:
72
66
  - - "~>"
73
67
  - !ruby/object:Gem::Version
74
68
  version: '1.10'
75
- - !ruby/object:Gem::Dependency
76
- name: rake
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: '10.0'
82
- type: :development
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - "~>"
87
- - !ruby/object:Gem::Version
88
- version: '10.0'
89
69
  - !ruby/object:Gem::Dependency
90
70
  name: minitest
91
71
  requirement: !ruby/object:Gem::Requirement
@@ -101,35 +81,21 @@ dependencies:
101
81
  - !ruby/object:Gem::Version
102
82
  version: '0'
103
83
  - !ruby/object:Gem::Dependency
104
- name: actionpack
105
- requirement: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- version: 3.0.0
110
- type: :development
111
- prerelease: false
112
- version_requirements: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - ">="
115
- - !ruby/object:Gem::Version
116
- version: 3.0.0
117
- - !ruby/object:Gem::Dependency
118
- name: sqlite3
84
+ name: rake
119
85
  requirement: !ruby/object:Gem::Requirement
120
86
  requirements:
121
- - - ">="
87
+ - - "~>"
122
88
  - !ruby/object:Gem::Version
123
- version: '0'
89
+ version: '10.0'
124
90
  type: :development
125
91
  prerelease: false
126
92
  version_requirements: !ruby/object:Gem::Requirement
127
93
  requirements:
128
- - - ">="
94
+ - - "~>"
129
95
  - !ruby/object:Gem::Version
130
- version: '0'
96
+ version: '10.0'
131
97
  - !ruby/object:Gem::Dependency
132
- name: multi_json
98
+ name: rubocop
133
99
  requirement: !ruby/object:Gem::Requirement
134
100
  requirements:
135
101
  - - ">="
@@ -150,6 +116,8 @@ extensions: []
150
116
  extra_rdoc_files: []
151
117
  files:
152
118
  - ".gitignore"
119
+ - ".rubocop-https---raw-githubusercontent-com-trailblazer-meta-master-rubocop-yml"
120
+ - ".rubocop.yml"
153
121
  - ".travis.yml"
154
122
  - CHANGES.md
155
123
  - Gemfile
@@ -167,7 +135,6 @@ files:
167
135
  - lib/trailblazer/rails/railtie/loader.rb
168
136
  - lib/trailblazer/rails/test/integration.rb
169
137
  - lib/trailblazer/rails/version.rb
170
- - trailblazer-rails-2.1.4.gem
171
138
  - trailblazer-rails.gemspec
172
139
  homepage: http://trailblazer.to/gems/trailblazer/2.0/rails.html
173
140
  licenses:
@@ -189,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
156
  version: '0'
190
157
  requirements: []
191
158
  rubyforge_project:
192
- rubygems_version: 2.7.3
159
+ rubygems_version: 2.7.7
193
160
  signing_key:
194
161
  specification_version: 4
195
162
  summary: Convenient Rails support for Trailblazer.
Binary file