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 CHANGED
@@ -9,7 +9,8 @@ Gemfile.lock
9
9
  bin
10
10
  coverage*
11
11
  doc
12
- gemfiles
12
+ gemfiles/*.gemfile
13
+ gemfiles/*.gemfile.lock
13
14
  pkg
14
15
  rdoc
15
16
  rerun.txt
data/.travis.yml CHANGED
@@ -1,6 +1,10 @@
1
1
  rvm:
2
- - 1.8.7
2
+ - 1.8.7-p334
3
3
  - 1.9.1
4
4
  - 1.9.2
5
5
  - ruby-head
6
6
  - ree
7
+ gemfile:
8
+ - gemfiles/Gemfile.actionpack-3.0.x
9
+ - gemfiles/Gemfile.actionpack-3.1.x
10
+ script: "bundle exec rake spec"
data/Appraisals CHANGED
@@ -3,8 +3,7 @@ appraise "3.0" do
3
3
  gem "actionpack", "~> 3.0"
4
4
  end
5
5
 
6
- # Not yet supported
7
- # appraise "3.1.0.rc4" do
8
- # gem "i18n", "~> 0.6.0"
9
- # gem "actionpack", "~> 3.1.0.rc4"
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.1.0...master)
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.1.0/frames) provides
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
- actionpack ~> 3.0.9
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
@@ -1,6 +1,6 @@
1
1
  module RoutingFilterLocaleUnlessAPI
2
2
  # @private
3
3
  module Version
4
- STRING = "0.1.0"
4
+ STRING = "0.2.0"
5
5
  end
6
6
  end
@@ -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", "~> 3.0.9"
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
- routes.generate(params).should == '/fr/products/1'
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
- routes.generate(params).should == '/en/products/1'
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
- routes.generate(root).should == '/fr'
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
- routes.generate(params.merge(:format => 'xls')).should == '/fr/products/1.xls'
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
- routes.generate(root).should == '/'
81
+ generated_routes_with(root).should == '/'
82
82
  end
83
83
 
84
84
  it 'if the format XML is considered as api' do
85
- routes.generate(params.merge(:format => 'xml')).should == '/products/1.xml'
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
- routes.generate(params.merge(:format => 'json')).should == '/products/1.json'
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
- routes.generate(params.merge(:format => 'xls')).should == '/products/1.xls'
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
- routes.generate(params.merge(:format => :xml)).should == '/products/1.xml'
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
- routes.generate(params).should == '/fr/products/1'
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
- routes.generate(params.merge(:locale => 'en')).should == '/en/products/1'
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
- routes.generate(root.merge(:locale => 'fr')).should == '/fr'
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
- routes.generate(params.merge(:format => 'xls')).should == '/fr/products/1.xls'
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
- routes.generate(root.merge(:locale => 'en')).should == '/'
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
- routes.generate(params.merge(:format => 'xml')).should == '/products/1.xml'
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
- routes.generate(params.merge(:format => 'json')).should == '/products/1.json'
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
- routes.generate(params.merge(:format => 'xls')).should == '/products/1.xls'
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: 27
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.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-07-04 00:00:00 +03:00
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.6.2
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