routing_filter_locale_unless_api 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/.travis.yml +5 -1
- data/Appraisals +4 -5
- data/Changelog.md +8 -1
- data/README.md +4 -2
- data/gemfiles/Gemfile.actionpack-3.0.x +10 -0
- data/gemfiles/Gemfile.actionpack-3.1.x +10 -0
- data/lib/routing_filter_locale_unless_api/filter/locale_unless_api.rb +2 -2
- data/lib/routing_filter_locale_unless_api/version.rb +1 -1
- data/routing_filter_locale_unless_api.gemspec +1 -1
- data/spec/routing_filter_locale_unless_api/filter/locale_unless_api_spec.rb +24 -17
- metadata +8 -8
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Appraisals
CHANGED
@@ -3,8 +3,7 @@ appraise "3.0" do
|
|
3
3
|
gem "actionpack", "~> 3.0"
|
4
4
|
end
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
# end
|
6
|
+
appraise "3.1.0" do
|
7
|
+
gem "i18n", "~> 0.6.0"
|
8
|
+
gem "actionpack", "~> 3.1.0"
|
9
|
+
end
|
data/Changelog.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
### Dev
|
2
2
|
|
3
|
-
[full changelog](https://github.com/ZenCocoon/routing_filter_locale_unless_api/compare/v0.
|
3
|
+
[full changelog](https://github.com/ZenCocoon/routing_filter_locale_unless_api/compare/v0.2.0...master)
|
4
|
+
|
5
|
+
### 0.2.0 / 2011-09-13
|
6
|
+
|
7
|
+
[full changelog](https://github.com/ZenCocoon/routing_filter_locale_unless_api/compare/v0.1.0...v0.2.0)
|
8
|
+
|
9
|
+
* Enhancements
|
10
|
+
* Add support for actionpack 3.1.*
|
4
11
|
|
5
12
|
### 0.1.0 / 2011-07-04
|
6
13
|
|
data/README.md
CHANGED
@@ -16,7 +16,7 @@ It will not add the locale parameter as a url fragment if:
|
|
16
16
|
|
17
17
|
## Documentation
|
18
18
|
|
19
|
-
The [RDoc](http://rubydoc.info/gems/routing_filter_locale_unless_api/0.
|
19
|
+
The [RDoc](http://rubydoc.info/gems/routing_filter_locale_unless_api/0.2.0/frames) provides
|
20
20
|
additional information for contributors and/or extenders.
|
21
21
|
|
22
22
|
All of the documentation is open source and a work in progress. If you find it
|
@@ -26,7 +26,9 @@ tracker](https://github.com/ZenCocoon/routing_filter_locale_unless_api/issues).
|
|
26
26
|
|
27
27
|
## Requirements
|
28
28
|
|
29
|
-
|
29
|
+
Notice: Tests currently failing under Ruby 1.8.7-p352, Ruby 1.8.7-p334 works properly so as Ruby 1.9.1, 1.9.2
|
30
|
+
|
31
|
+
actionpack >= 3.0.9
|
30
32
|
i18n >= 0.5.0
|
31
33
|
routing-filter ~> 0.2.3
|
32
34
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "http://rubygems.org"
|
4
|
+
|
5
|
+
gem "ruby-prof", "~> 0.9.2", :platforms=>[:mri_18, :mri_19]
|
6
|
+
gem "rb-fsevent", "~> 0.3.9", :platforms=>[:mri_18, :mri_19]
|
7
|
+
gem "actionpack", "~> 3.0"
|
8
|
+
gem "i18n", "~> 0.5.0"
|
9
|
+
|
10
|
+
gemspec :path=>"../"
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "http://rubygems.org"
|
4
|
+
|
5
|
+
gem "ruby-prof", "~> 0.9.2", :platforms=>[:mri_18, :mri_19]
|
6
|
+
gem "rb-fsevent", "~> 0.3.9", :platforms=>[:mri_18, :mri_19]
|
7
|
+
gem "actionpack", "~> 3.1.0"
|
8
|
+
gem "i18n", "~> 0.6.0"
|
9
|
+
|
10
|
+
gemspec :path=>"../"
|
@@ -71,8 +71,8 @@ module RoutingFilterLocaleUnlessAPI
|
|
71
71
|
|
72
72
|
format = params[:format] # save the current format
|
73
73
|
locale = params.delete(:locale) # extract the passed :locale option
|
74
|
-
locale = I18n.locale if locale.nil? # default to I18n.locale when locale is nil (could also be false)
|
75
74
|
locale = nil unless valid_locale?(locale) # reset to no locale when locale is not valid
|
75
|
+
locale = I18n.locale if locale.nil? # default to I18n.locale when locale is nil (could also be false)
|
76
76
|
|
77
77
|
args << params
|
78
78
|
|
@@ -107,7 +107,7 @@ module RoutingFilterLocaleUnlessAPI
|
|
107
107
|
#
|
108
108
|
# @return [Boolean]
|
109
109
|
def root_path?(path)
|
110
|
-
path == '/'
|
110
|
+
(path.is_a?(Array) ? path.first : path) == '/'
|
111
111
|
end
|
112
112
|
|
113
113
|
# Returns true if it should prepend the locale
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.rdoc_options = "--charset=UTF-8"
|
19
19
|
s.require_path = "lib"
|
20
20
|
|
21
|
-
s.add_dependency "actionpack", "
|
21
|
+
s.add_dependency "actionpack", ">= 3.0.9"
|
22
22
|
s.add_dependency "i18n", ">= 0.5.0"
|
23
23
|
s.add_dependency "routing-filter", "~> 0.2.3"
|
24
24
|
|
@@ -58,45 +58,45 @@ module RoutingFilterLocaleUnlessAPI::Filter
|
|
58
58
|
|
59
59
|
context "prepends the segments /:locale to the generated path" do
|
60
60
|
it 'if the current locale is not the default locale' do
|
61
|
-
|
61
|
+
generated_routes_with(params).should == '/fr/products/1'
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'if the current locale is the default locale' do
|
65
65
|
I18n.locale = 'en'
|
66
|
-
|
66
|
+
generated_routes_with(params).should == '/en/products/1'
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'if the current locale is not the default locale and with root url' do
|
70
|
-
|
70
|
+
generated_routes_with(root).should == '/fr'
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'if the format XLS is not considered as api' do
|
74
|
-
|
74
|
+
generated_routes_with(params.merge(:format => 'xls')).should == '/fr/products/1.xls'
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
78
|
context "does not prepend the segments /:locale to the generated path" do
|
79
79
|
it 'if the current locale is the default locale and with root url' do
|
80
80
|
I18n.locale = 'en'
|
81
|
-
|
81
|
+
generated_routes_with(root).should == '/'
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'if the format XML is considered as api' do
|
85
|
-
|
85
|
+
generated_routes_with(params.merge(:format => 'xml')).should == '/products/1.xml'
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'if the format JSON is considered as api' do
|
89
|
-
|
89
|
+
generated_routes_with(params.merge(:format => 'json')).should == '/products/1.json'
|
90
90
|
end
|
91
91
|
|
92
92
|
it 'if the format XLS is considered as api' do
|
93
93
|
RoutingFilter::LocaleUnlessApi.api_formats = %w( xml json xls )
|
94
|
-
|
94
|
+
generated_routes_with(params.merge(:format => 'xls')).should == '/products/1.xls'
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
98
|
it 'should work with format as symbol' do
|
99
|
-
|
99
|
+
generated_routes_with(params.merge(:format => :xml)).should == '/products/1.xml'
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
@@ -105,41 +105,48 @@ module RoutingFilterLocaleUnlessAPI::Filter
|
|
105
105
|
|
106
106
|
context "prepends the segments /:locale to the generated path" do
|
107
107
|
it 'if the given locale is not the default locale' do
|
108
|
-
|
108
|
+
generated_routes_with(params).should == '/fr/products/1'
|
109
109
|
end
|
110
110
|
|
111
111
|
it 'if the given locale is the default locale' do
|
112
|
-
|
112
|
+
generated_routes_with(params.merge(:locale => 'en')).should == '/en/products/1'
|
113
113
|
end
|
114
114
|
|
115
115
|
it 'if the given locale is not the default locale and with root url' do
|
116
|
-
|
116
|
+
generated_routes_with(root.merge(:locale => 'fr')).should == '/fr'
|
117
117
|
end
|
118
118
|
|
119
119
|
it 'if a given locale and the format XLS is not considered as api' do
|
120
|
-
|
120
|
+
generated_routes_with(params.merge(:format => 'xls')).should == '/fr/products/1.xls'
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
124
|
context "does not prepend the segments /:locale to the generated path" do
|
125
125
|
it 'if a given locale is the default locale and with the root url' do
|
126
|
-
|
126
|
+
generated_routes_with(root.merge(:locale => 'en')).should == '/'
|
127
127
|
end
|
128
128
|
|
129
129
|
it 'if a given locale and the format XML is considered as api' do
|
130
|
-
|
130
|
+
generated_routes_with(params.merge(:format => 'xml')).should == '/products/1.xml'
|
131
131
|
end
|
132
132
|
|
133
133
|
it 'if a given locale and the format JSON is considered as api' do
|
134
|
-
|
134
|
+
generated_routes_with(params.merge(:format => 'json')).should == '/products/1.json'
|
135
135
|
end
|
136
136
|
|
137
137
|
it 'if a given locale and the format XLS is considered as api' do
|
138
138
|
RoutingFilter::LocaleUnlessApi.api_formats = %w( xml json xls )
|
139
|
-
|
139
|
+
generated_routes_with(params.merge(:format => 'xls')).should == '/products/1.xls'
|
140
140
|
end
|
141
141
|
end
|
142
142
|
end
|
143
143
|
end
|
144
|
+
|
145
|
+
private
|
146
|
+
|
147
|
+
def generated_routes_with(params)
|
148
|
+
url = routes.generate(params)
|
149
|
+
url.is_a?(Array) ? url.first : url
|
150
|
+
end
|
144
151
|
end
|
145
152
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: routing_filter_locale_unless_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "S\xC3\xA9bastien Grosjean"
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
19
|
-
default_executable:
|
18
|
+
date: 2011-09-14 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: actionpack
|
@@ -24,7 +23,7 @@ dependencies:
|
|
24
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
24
|
none: false
|
26
25
|
requirements:
|
27
|
-
- -
|
26
|
+
- - ">="
|
28
27
|
- !ruby/object:Gem::Version
|
29
28
|
hash: 21
|
30
29
|
segments:
|
@@ -212,13 +211,14 @@ files:
|
|
212
211
|
- License.txt
|
213
212
|
- README.md
|
214
213
|
- Rakefile
|
214
|
+
- gemfiles/Gemfile.actionpack-3.0.x
|
215
|
+
- gemfiles/Gemfile.actionpack-3.1.x
|
215
216
|
- lib/routing_filter_locale_unless_api.rb
|
216
217
|
- lib/routing_filter_locale_unless_api/filter/locale_unless_api.rb
|
217
218
|
- lib/routing_filter_locale_unless_api/version.rb
|
218
219
|
- routing_filter_locale_unless_api.gemspec
|
219
220
|
- spec/routing_filter_locale_unless_api/filter/locale_unless_api_spec.rb
|
220
221
|
- spec/spec_helper.rb
|
221
|
-
has_rdoc: true
|
222
222
|
homepage: https://github.com/ZenCocoon/routing_filter_locale_unless_api
|
223
223
|
licenses: []
|
224
224
|
|
@@ -248,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
248
248
|
requirements: []
|
249
249
|
|
250
250
|
rubyforge_project:
|
251
|
-
rubygems_version: 1.
|
251
|
+
rubygems_version: 1.8.10
|
252
252
|
signing_key:
|
253
253
|
specification_version: 3
|
254
254
|
summary: routing filter that add locale unless XML or JSON, or root_url with default locale
|