multiview 0.1.1 → 0.1.2
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 +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +27 -3
- data/LICENSE.txt +1 -1
- data/README.md +9 -6
- data/gemfiles/rails-4.1 +6 -0
- data/gemfiles/rails-4.2 +6 -0
- data/gemfiles/rails-5.0 +6 -0
- data/gemfiles/rails-5.1 +6 -0
- data/lib/multiview/manager.rb +8 -1
- data/lib/multiview/version.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9c81beca7267f95b2d01112d07991f845bf6986
|
4
|
+
data.tar.gz: 11835b806d0724d21b91b3c72f4d6c74b3f749ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74add043ec97f56b08796d66247bc79e0594a7fd47fc08d4e2759d686249f11dd49cfe0e388892df754200cdbefce4a83e848a8b992dea889051116d0d957066
|
7
|
+
data.tar.gz: c1373eb0e59c7780da535a4f3073437ddaa1043bdf564b928d2d5493386b36b79889892b3195998d49ba0a3f1128769c888911ca2bda5044562b967371ec096d
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,5 +1,29 @@
|
|
1
|
-
sudo:
|
1
|
+
sudo: enable
|
2
|
+
dist: trusty
|
2
3
|
language: ruby
|
4
|
+
|
5
|
+
cache: bundler
|
6
|
+
|
3
7
|
rvm:
|
4
|
-
- 2.
|
5
|
-
|
8
|
+
- 2.1.10
|
9
|
+
- 2.2.7
|
10
|
+
- 2.3.4
|
11
|
+
- 2.4.1
|
12
|
+
|
13
|
+
gemfile:
|
14
|
+
- gemfiles/rails-4.1
|
15
|
+
- gemfiles/rails-4.2
|
16
|
+
- gemfiles/rails-5.0
|
17
|
+
- gemfiles/rails-5.1
|
18
|
+
|
19
|
+
matrix:
|
20
|
+
exclude:
|
21
|
+
- {rvm: '2.1.10', gemfile: 'gemfiles/rails-5.0'}
|
22
|
+
- {rvm: '2.1.10', gemfile: 'gemfiles/rails-5.1'}
|
23
|
+
- {rvm: '2.4.1', gemfile: 'gemfiles/rails-4.1'}
|
24
|
+
|
25
|
+
before_install:
|
26
|
+
- gem install bundler --no-doc
|
27
|
+
|
28
|
+
script: bundle exec rspec
|
29
|
+
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
Support multiple versions for Rails views
|
4
4
|
|
5
|
+
[](https://travis-ci.org/xiejiangzhi/multiview)
|
6
|
+
|
5
7
|
|
6
8
|
## Installation
|
7
9
|
|
@@ -18,7 +20,7 @@ And then execute:
|
|
18
20
|
|
19
21
|
## Usage
|
20
22
|
|
21
|
-
###
|
23
|
+
### Example Project
|
22
24
|
|
23
25
|
`app/controllers/topics_controller.rb`
|
24
26
|
|
@@ -61,12 +63,13 @@ $multiview = Multiview::Manager.new({
|
|
61
63
|
|
62
64
|
### Redispatch request by filter of controller
|
63
65
|
|
64
|
-
When get `/topics`, should redispatch to V2::TopicsController
|
66
|
+
When get `/topics`, should redispatch to `V2::TopicsController#index`, rether than `TopicsController#index`
|
67
|
+
If delete `V2::TopicsController` or change that config `{'topics' => nil}`, it will call `TopicsController#index`
|
65
68
|
|
66
69
|
```
|
67
70
|
class ApplicationController < ActionController::Base
|
68
71
|
before_aciton :set_view_version_filter
|
69
|
-
|
72
|
+
.
|
70
73
|
def set_view_version_filter
|
71
74
|
$multiview.redispatch(self)
|
72
75
|
|
@@ -75,7 +78,7 @@ class ApplicationController < ActionController::Base
|
|
75
78
|
|
76
79
|
# if exist V3::XxxController, should to call V3::XxxController
|
77
80
|
# if not, should to call XxxController and prepend v3 views path
|
78
|
-
# when you
|
81
|
+
# when you only want to change something for views, you should not to create V3::XxxController for the version, just to make a view folder `app/views/v3/xxx`
|
79
82
|
# $multiview.redispatch(self, params[:controller], params[:action], 'v3')
|
80
83
|
end
|
81
84
|
end
|
@@ -126,7 +129,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
126
129
|
|
127
130
|
## Contributing
|
128
131
|
|
129
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
132
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/xiejiangzhi/multiview. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
130
133
|
|
131
134
|
## License
|
132
135
|
|
@@ -134,4 +137,4 @@ The gem is available as open source under the terms of the [MIT License](http://
|
|
134
137
|
|
135
138
|
## Code of Conduct
|
136
139
|
|
137
|
-
Everyone interacting in the Multiview project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
140
|
+
Everyone interacting in the Multiview project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/xiejiangzhi/multiview/blob/master/CODE_OF_CONDUCT.md).
|
data/gemfiles/rails-4.1
ADDED
data/gemfiles/rails-4.2
ADDED
data/gemfiles/rails-5.0
ADDED
data/gemfiles/rails-5.1
ADDED
data/lib/multiview/manager.rb
CHANGED
@@ -33,7 +33,8 @@ module Multiview
|
|
33
33
|
version ||= find_version(controller_path)
|
34
34
|
return unless version
|
35
35
|
|
36
|
-
|
36
|
+
result = try_dispatch(controller.request.env, controller_path, action_name, version)
|
37
|
+
if result
|
37
38
|
res = controller.response
|
38
39
|
status, headers, body = result
|
39
40
|
res.status = status
|
@@ -50,6 +51,7 @@ module Multiview
|
|
50
51
|
versions_map[path.to_sym]
|
51
52
|
end
|
52
53
|
|
54
|
+
|
53
55
|
private
|
54
56
|
|
55
57
|
def load_version_view(controller, version)
|
@@ -57,5 +59,10 @@ module Multiview
|
|
57
59
|
Rails.logger.warn("[Multiview] Prepend view path app/views/#{version}")
|
58
60
|
controller.prepend_view_path(Rails.root.join("app/views/#{version}"))
|
59
61
|
end
|
62
|
+
|
63
|
+
def try_dispatch(env, path, action, version)
|
64
|
+
return if env['multiview']
|
65
|
+
dispatch(env, path, action, version)
|
66
|
+
end
|
60
67
|
end
|
61
68
|
end
|
data/lib/multiview/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multiview
|
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
|
- Jon Xie
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -97,6 +97,10 @@ files:
|
|
97
97
|
- Rakefile
|
98
98
|
- bin/console
|
99
99
|
- bin/setup
|
100
|
+
- gemfiles/rails-4.1
|
101
|
+
- gemfiles/rails-4.2
|
102
|
+
- gemfiles/rails-5.0
|
103
|
+
- gemfiles/rails-5.1
|
100
104
|
- lib/multiview.rb
|
101
105
|
- lib/multiview/manager.rb
|
102
106
|
- lib/multiview/version.rb
|
@@ -121,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
125
|
version: '0'
|
122
126
|
requirements: []
|
123
127
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.
|
128
|
+
rubygems_version: 2.4.5.2
|
125
129
|
signing_key:
|
126
130
|
specification_version: 4
|
127
131
|
summary: Support multiple versions for Rails view.
|