trailblazer-compat 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/README.md +2 -1
- data/lib/trailblazer/1.1/rails.rb +1 -0
- data/lib/trailblazer/1.1/rails/railtie.rb +24 -11
- data/lib/trailblazer/compat.rb +5 -1
- data/lib/trailblazer/compat/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a87137cd62ece252507795dc3827decf12a7af0a
|
4
|
+
data.tar.gz: f125592d8350be4c655f4eb86b9c4a1b4e6ef323
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fe430099274c39dca277202863000c4613272f51db956ac48461c47d8683c627aa8ea2eae473f2b13ee42fd644378c109c5ffceb452844ca23acee856c15405
|
7
|
+
data.tar.gz: d6922d7858014f9ba381d056d19e85893ee5ee0877d994ea8a320e8a3f61ec329b4a5c3dfcebdd07e7cca4243358eb4d75a2550cae7c17ada439a4885d6a95e4
|
data/CHANGES.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# Trailblazer::Compat
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/trailblazer-compat.svg)](https://badge.fury.io/rb/trailblazer-compat)
|
2
3
|
|
3
4
|
This gem provides a seamless-er™ upgrade from TRB 1.1 to 2.x.
|
4
5
|
|
@@ -16,7 +17,7 @@ gem "trailblazer-compat"
|
|
16
17
|
In a Rails application, you also need to pull the 1.x line of the `trailblazer-rails` gem.
|
17
18
|
|
18
19
|
```ruby
|
19
|
-
gem "trailblazer-rails", ">= 1.0.
|
20
|
+
gem "trailblazer-rails", ">= 1.0.3"
|
20
21
|
```
|
21
22
|
|
22
23
|
## Upgrade Path / Overview
|
@@ -2,26 +2,39 @@ begin
|
|
2
2
|
require 'rails/railtie'
|
3
3
|
rescue LoadError
|
4
4
|
else
|
5
|
+
|
5
6
|
module Trailblazer::V1_1
|
6
7
|
class Railtie < ::Rails::Railtie
|
8
|
+
module ExtendApplicationController
|
9
|
+
def extend_application_controller!(app)
|
10
|
+
# this requires trailblazer-rails-1.0.3
|
11
|
+
application_controller = super
|
12
|
+
|
13
|
+
v2_Controller = Trailblazer::Rails::Controller
|
14
|
+
|
15
|
+
application_controller.class_eval do
|
16
|
+
include v2_Controller # if Trailblazer::Operation.const_defined?(:Controller) # from V2.
|
17
|
+
alias_method :run_v2, :run
|
18
|
+
include Trailblazer::V1_1::Operation::Controller
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
7
24
|
# This is to autoload Operation::Dispatch, etc. I'm simply assuming people find this helpful in Rails.
|
8
25
|
initializer "trailblazer.library_autoloading" do
|
9
26
|
require "trailblazer/1.1/autoloading"
|
10
27
|
end
|
11
28
|
|
12
|
-
initializer "trailblazer.application_controller" do
|
13
|
-
|
14
|
-
require "trailblazer/rails/railtie"
|
15
|
-
# this requires trailblazer-rails-1.0.0
|
16
|
-
V2_Controller = Trailblazer::Rails::Controller
|
29
|
+
initializer "trailblazer.application_controller.compat", before: "trailblazer.application_controller" do |app|
|
30
|
+
require "trailblazer/rails/railtie"
|
17
31
|
|
18
|
-
|
19
|
-
|
20
|
-
alias run_v2 run
|
21
|
-
include Trailblazer::V1_1::Operation::Controller
|
22
|
-
end
|
32
|
+
if Gem::Version.new(Trailblazer::Rails::VERSION) < Gem::Version.new("1.0.4")
|
33
|
+
raise "[Trailblazer-compat] Please update to trailblazer-rails 1.0.4 or above."
|
23
34
|
end
|
35
|
+
|
36
|
+
Trailblazer::Railtie.extend ExtendApplicationController
|
24
37
|
end
|
25
|
-
end
|
38
|
+
end # Railtie
|
26
39
|
end
|
27
40
|
end
|
data/lib/trailblazer/compat.rb
CHANGED
@@ -43,8 +43,12 @@ Trailblazer::NotAuthorizedError = Trailblazer::V1_1::NotAuthorizedError
|
|
43
43
|
Trailblazer::Operation.extend(Trailblazer::Compat::Version)
|
44
44
|
|
45
45
|
Trailblazer::V2::Operation::Nested.module_eval do
|
46
|
-
def self.nestable_object?(object)
|
46
|
+
def self.nestable_object?(object) # 2.0
|
47
47
|
# interestingly, with < we get a weird nil exception. bug in Ruby?
|
48
48
|
object.is_a?(Class) && object <= Trailblazer::V2::Operation
|
49
49
|
end
|
50
|
+
|
51
|
+
def self.operation_class # 2.1
|
52
|
+
Trailblazer::V2::Operation
|
53
|
+
end
|
50
54
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trailblazer-compat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.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: 2017-
|
11
|
+
date: 2017-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trailblazer
|
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
127
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.6.
|
128
|
+
rubygems_version: 2.6.12
|
129
129
|
signing_key:
|
130
130
|
specification_version: 4
|
131
131
|
summary: Use Trailblazer 1.1 and 2.x.
|