fast_gettext 0.6.11 → 0.6.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ ['2', '3'].each do |version|
2
+ appraise "rails.#{version}" do
3
+ gem "rails", "~>#{version}.0"
4
+ end
5
+ end
data/Gemfile CHANGED
@@ -1,9 +1,10 @@
1
1
  source :rubygems
2
2
  gemspec
3
3
 
4
+ gem 'appraisal'
4
5
  gem 'rake'
5
6
  gem 'sqlite3'
6
- gem 'rspec', '~>2'
7
- gem 'activerecord', ENV['AR']
7
+ gem 'rspec'
8
+ gem 'activerecord'
8
9
  gem 'i18n'
9
10
  gem 'bump'
@@ -1,48 +1,52 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fast_gettext (0.6.11)
4
+ fast_gettext (0.6.12)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
- activemodel (3.2.7)
10
- activesupport (= 3.2.7)
9
+ activemodel (3.2.8)
10
+ activesupport (= 3.2.8)
11
11
  builder (~> 3.0.0)
12
- activerecord (3.2.7)
13
- activemodel (= 3.2.7)
14
- activesupport (= 3.2.7)
12
+ activerecord (3.2.8)
13
+ activemodel (= 3.2.8)
14
+ activesupport (= 3.2.8)
15
15
  arel (~> 3.0.2)
16
16
  tzinfo (~> 0.3.29)
17
- activesupport (3.2.7)
17
+ activesupport (3.2.8)
18
18
  i18n (~> 0.6)
19
19
  multi_json (~> 1.0)
20
+ appraisal (0.5.1)
21
+ bundler
22
+ rake
20
23
  arel (3.0.2)
21
- builder (3.0.0)
22
- bump (0.3.3)
24
+ builder (3.0.4)
25
+ bump (0.3.5)
23
26
  diff-lcs (1.1.3)
24
- i18n (0.6.0)
25
- multi_json (1.3.6)
26
- rake (0.9.2)
27
- rspec (2.6.0)
28
- rspec-core (~> 2.6.0)
29
- rspec-expectations (~> 2.6.0)
30
- rspec-mocks (~> 2.6.0)
31
- rspec-core (2.6.4)
32
- rspec-expectations (2.6.0)
33
- diff-lcs (~> 1.1.2)
34
- rspec-mocks (2.6.0)
27
+ i18n (0.6.1)
28
+ multi_json (1.3.7)
29
+ rake (0.9.2.2)
30
+ rspec (2.11.0)
31
+ rspec-core (~> 2.11.0)
32
+ rspec-expectations (~> 2.11.0)
33
+ rspec-mocks (~> 2.11.0)
34
+ rspec-core (2.11.1)
35
+ rspec-expectations (2.11.3)
36
+ diff-lcs (~> 1.1.3)
37
+ rspec-mocks (2.11.3)
35
38
  sqlite3 (1.3.6)
36
- tzinfo (0.3.33)
39
+ tzinfo (0.3.35)
37
40
 
38
41
  PLATFORMS
39
42
  ruby
40
43
 
41
44
  DEPENDENCIES
42
45
  activerecord
46
+ appraisal
43
47
  bump
44
48
  fast_gettext!
45
49
  i18n
46
50
  rake
47
- rspec (~> 2)
51
+ rspec
48
52
  sqlite3
data/Rakefile CHANGED
@@ -1,11 +1,13 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'bump/tasks'
3
+ require 'appraisal'
3
4
 
4
5
  task :default do
5
- ['~>2', '~>3'].each do |version|
6
- sh "export AR='#{version}' && (bundle check || bundle install) && bundle exec rspec spec"
7
- end
8
- sh "git checkout Gemfile.lock"
6
+ sh "bundle exec rake appraisal:install && bundle exec rake appraisal spec"
7
+ end
8
+
9
+ task :spec do
10
+ sh "rspec spec"
9
11
  end
10
12
 
11
13
  task :benchmark do
@@ -20,20 +22,3 @@ task :namespaces do
20
22
  puts `ruby benchmark/namespace/original.rb`
21
23
  puts `ruby benchmark/namespace/fast_gettext.rb`
22
24
  end
23
-
24
- # extracted from https://github.com/grosser/project_template
25
- rule /^version:bump:.*/ do |t|
26
- sh "git status | grep 'nothing to commit'" # ensure we are not dirty
27
- index = ['major', 'minor','patch'].index(t.name.split(':').last)
28
- file = 'lib/fast_gettext/version.rb'
29
-
30
- version_file = File.read(file)
31
- old_version, *version_parts = version_file.match(/(\d+)\.(\d+)\.(\d+)/).to_a
32
- version_parts[index] = version_parts[index].to_i + 1
33
- version_parts[2] = 0 if index < 2 # remove patch for minor
34
- version_parts[1] = 0 if index < 1 # remove minor for major
35
- new_version = version_parts * '.'
36
- File.open(file,'w'){|f| f.write(version_file.sub(old_version, new_version)) }
37
-
38
- sh "bundle && git add #{file} Gemfile.lock && git commit -m 'bump version to #{new_version}'"
39
- end
data/Readme.md CHANGED
@@ -127,7 +127,8 @@ since it runs in a different thread then e.g. controllers, so set them inside yo
127
127
  def set_locale
128
128
  FastGettext.available_locales = ['de','en',...]
129
129
  FastGettext.text_domain = 'frontend'
130
- session[:locale] = I18n.locale = FastGettext.set_locale(params[:locale] || session[:locale] || request.env['HTTP_ACCEPT_LANGUAGE'] || 'en')
130
+ FastGettext.set_locale(params[:locale] || session[:locale] || request.env['HTTP_ACCEPT_LANGUAGE'], :reset_on_unknown => true)
131
+ session[:locale] = I18n.locale = FastGettext.locale
131
132
  end
132
133
 
133
134
 
@@ -228,4 +229,4 @@ Mo/Po-file parsing from Masao Mutoh, see vendor/README
228
229
  [Michael Grosser](http://grosser.it)<br/>
229
230
  michael@grosser.it<br/>
230
231
  License: MIT<br/>
231
- [![Build Status](https://secure.travis-ci.org/grosser/fast_gettext.png)](http://travis-ci.org/grosser/fast_gettext)
232
+ [![Build Status](https://travis-ci.org/grosser/fast_gettext.png)](https://travis-ci.org/grosser/fast_gettext)
@@ -0,0 +1,14 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source :rubygems
4
+
5
+ gem "appraisal"
6
+ gem "rake"
7
+ gem "sqlite3"
8
+ gem "rspec"
9
+ gem "activerecord"
10
+ gem "i18n"
11
+ gem "bump"
12
+ gem "rails", "~>2.0"
13
+
14
+ gemspec :path=>"../"
@@ -0,0 +1,56 @@
1
+ PATH
2
+ remote: /Users/mgrosser/code/tools/fast_gettext
3
+ specs:
4
+ fast_gettext (0.6.11)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ actionmailer (2.3.14)
10
+ actionpack (= 2.3.14)
11
+ actionpack (2.3.14)
12
+ activesupport (= 2.3.14)
13
+ rack (~> 1.1.0)
14
+ activerecord (2.3.14)
15
+ activesupport (= 2.3.14)
16
+ activeresource (2.3.14)
17
+ activesupport (= 2.3.14)
18
+ activesupport (2.3.14)
19
+ appraisal (0.5.1)
20
+ bundler
21
+ rake
22
+ bump (0.3.5)
23
+ diff-lcs (1.1.3)
24
+ i18n (0.6.1)
25
+ rack (1.1.3)
26
+ rails (2.3.14)
27
+ actionmailer (= 2.3.14)
28
+ actionpack (= 2.3.14)
29
+ activerecord (= 2.3.14)
30
+ activeresource (= 2.3.14)
31
+ activesupport (= 2.3.14)
32
+ rake (>= 0.8.3)
33
+ rake (0.9.2.2)
34
+ rspec (2.11.0)
35
+ rspec-core (~> 2.11.0)
36
+ rspec-expectations (~> 2.11.0)
37
+ rspec-mocks (~> 2.11.0)
38
+ rspec-core (2.11.1)
39
+ rspec-expectations (2.11.3)
40
+ diff-lcs (~> 1.1.3)
41
+ rspec-mocks (2.11.3)
42
+ sqlite3 (1.3.6)
43
+
44
+ PLATFORMS
45
+ ruby
46
+
47
+ DEPENDENCIES
48
+ activerecord
49
+ appraisal
50
+ bump
51
+ fast_gettext!
52
+ i18n
53
+ rails (~> 2.0)
54
+ rake
55
+ rspec
56
+ sqlite3
@@ -0,0 +1,14 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source :rubygems
4
+
5
+ gem "appraisal"
6
+ gem "rake"
7
+ gem "sqlite3"
8
+ gem "rspec"
9
+ gem "activerecord"
10
+ gem "i18n"
11
+ gem "bump"
12
+ gem "rails", "~>3.0"
13
+
14
+ gemspec :path=>"../"
@@ -0,0 +1,112 @@
1
+ PATH
2
+ remote: /Users/mgrosser/code/tools/fast_gettext
3
+ specs:
4
+ fast_gettext (0.6.11)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ actionmailer (3.2.8)
10
+ actionpack (= 3.2.8)
11
+ mail (~> 2.4.4)
12
+ actionpack (3.2.8)
13
+ activemodel (= 3.2.8)
14
+ activesupport (= 3.2.8)
15
+ builder (~> 3.0.0)
16
+ erubis (~> 2.7.0)
17
+ journey (~> 1.0.4)
18
+ rack (~> 1.4.0)
19
+ rack-cache (~> 1.2)
20
+ rack-test (~> 0.6.1)
21
+ sprockets (~> 2.1.3)
22
+ activemodel (3.2.8)
23
+ activesupport (= 3.2.8)
24
+ builder (~> 3.0.0)
25
+ activerecord (3.2.8)
26
+ activemodel (= 3.2.8)
27
+ activesupport (= 3.2.8)
28
+ arel (~> 3.0.2)
29
+ tzinfo (~> 0.3.29)
30
+ activeresource (3.2.8)
31
+ activemodel (= 3.2.8)
32
+ activesupport (= 3.2.8)
33
+ activesupport (3.2.8)
34
+ i18n (~> 0.6)
35
+ multi_json (~> 1.0)
36
+ appraisal (0.5.1)
37
+ bundler
38
+ rake
39
+ arel (3.0.2)
40
+ builder (3.0.4)
41
+ bump (0.3.5)
42
+ diff-lcs (1.1.3)
43
+ erubis (2.7.0)
44
+ hike (1.2.1)
45
+ i18n (0.6.1)
46
+ journey (1.0.4)
47
+ json (1.7.5)
48
+ mail (2.4.4)
49
+ i18n (>= 0.4.0)
50
+ mime-types (~> 1.16)
51
+ treetop (~> 1.4.8)
52
+ mime-types (1.19)
53
+ multi_json (1.3.7)
54
+ polyglot (0.3.3)
55
+ rack (1.4.1)
56
+ rack-cache (1.2)
57
+ rack (>= 0.4)
58
+ rack-ssl (1.3.2)
59
+ rack
60
+ rack-test (0.6.2)
61
+ rack (>= 1.0)
62
+ rails (3.2.8)
63
+ actionmailer (= 3.2.8)
64
+ actionpack (= 3.2.8)
65
+ activerecord (= 3.2.8)
66
+ activeresource (= 3.2.8)
67
+ activesupport (= 3.2.8)
68
+ bundler (~> 1.0)
69
+ railties (= 3.2.8)
70
+ railties (3.2.8)
71
+ actionpack (= 3.2.8)
72
+ activesupport (= 3.2.8)
73
+ rack-ssl (~> 1.3.2)
74
+ rake (>= 0.8.7)
75
+ rdoc (~> 3.4)
76
+ thor (>= 0.14.6, < 2.0)
77
+ rake (0.9.2.2)
78
+ rdoc (3.12)
79
+ json (~> 1.4)
80
+ rspec (2.11.0)
81
+ rspec-core (~> 2.11.0)
82
+ rspec-expectations (~> 2.11.0)
83
+ rspec-mocks (~> 2.11.0)
84
+ rspec-core (2.11.1)
85
+ rspec-expectations (2.11.3)
86
+ diff-lcs (~> 1.1.3)
87
+ rspec-mocks (2.11.3)
88
+ sprockets (2.1.3)
89
+ hike (~> 1.2)
90
+ rack (~> 1.0)
91
+ tilt (~> 1.1, != 1.3.0)
92
+ sqlite3 (1.3.6)
93
+ thor (0.16.0)
94
+ tilt (1.3.3)
95
+ treetop (1.4.12)
96
+ polyglot
97
+ polyglot (>= 0.3.1)
98
+ tzinfo (0.3.35)
99
+
100
+ PLATFORMS
101
+ ruby
102
+
103
+ DEPENDENCIES
104
+ activerecord
105
+ appraisal
106
+ bump
107
+ fast_gettext!
108
+ i18n
109
+ rails (~> 3.0)
110
+ rake
111
+ rspec
112
+ sqlite3
@@ -121,15 +121,15 @@ module FastGettext
121
121
  end
122
122
 
123
123
  def locale=(new_locale)
124
- new_locale = best_locale_in(new_locale)
125
- self._locale = new_locale if new_locale
124
+ set_locale(new_locale)
126
125
  end
127
126
 
128
127
  # for chaining: puts set_locale('xx') == 'xx' ? 'applied' : 'rejected'
129
128
  # returns the current locale, not the one that was supplied
130
129
  # like locale=(), whoes behavior cannot be changed
131
- def set_locale(new_locale)
132
- self.locale = new_locale
130
+ def set_locale(new_locale, options={})
131
+ new_locale = best_locale_in(new_locale)
132
+ self._locale = new_locale if new_locale || options[:reset_on_unknown]
133
133
  locale
134
134
  end
135
135
 
@@ -1,3 +1,3 @@
1
1
  module FastGettext
2
- VERSION = Version = '0.6.11'
2
+ VERSION = Version = '0.6.12'
3
3
  end
@@ -168,6 +168,12 @@ describe 'Storage' do
168
168
  self.set_locale('en').should == 'de'
169
169
  end
170
170
 
171
+ it "set_locale resets to default with :reset_on_unknown" do
172
+ self.locale = 'de'
173
+ self.available_locales = ['fr']
174
+ self.set_locale('en', :reset_on_unknown => true).should == 'fr'
175
+ end
176
+
171
177
  {
172
178
  'Opera' => "de-DE,de;q=0.9,en;q=0.8",
173
179
  'Firefox' => "de-de,de;q=0.8,en-us;q=0.5,en;q=0.3",
@@ -7,8 +7,9 @@ require 'fast_gettext'
7
7
  # ---- revert to defaults
8
8
  RSpec.configure do |config|
9
9
  config.before do
10
- FastGettext.locale = 'de'
10
+ FastGettext.default_available_locales = nil
11
11
  FastGettext.available_locales = nil
12
+ FastGettext.locale = 'de'
12
13
  end
13
14
  end
14
15
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast_gettext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.11
5
4
  prerelease:
5
+ version: 0.6.12
6
6
  platform: ruby
7
7
  authors:
8
8
  - Michael Grosser
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-26 00:00:00.000000000 Z
12
+ date: 2012-12-20 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: michael@grosser.it
@@ -19,6 +19,7 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - .gitignore
21
21
  - .travis.yml
22
+ - Appraisals
22
23
  - CHANGELOG
23
24
  - Gemfile
24
25
  - Gemfile.lock
@@ -38,6 +39,10 @@ files:
38
39
  - examples/db/migration.rb
39
40
  - examples/missing_translation_logger.rb
40
41
  - fast_gettext.gemspec
42
+ - gemfiles/rails.2.gemfile
43
+ - gemfiles/rails.2.gemfile.lock
44
+ - gemfiles/rails.3.gemfile
45
+ - gemfiles/rails.3.gemfile.lock
41
46
  - lib/fast_gettext.rb
42
47
  - lib/fast_gettext/mo_file.rb
43
48
  - lib/fast_gettext/po_file.rb
@@ -104,23 +109,23 @@ rdoc_options: []
104
109
  require_paths:
105
110
  - lib
106
111
  required_ruby_version: !ruby/object:Gem::Requirement
107
- none: false
108
112
  requirements:
109
113
  - - ! '>='
110
114
  - !ruby/object:Gem::Version
111
115
  version: '0'
112
116
  segments:
113
117
  - 0
114
- hash: -1129641372544859423
115
- required_rubygems_version: !ruby/object:Gem::Requirement
118
+ hash: -4485904871753900151
116
119
  none: false
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
121
  requirements:
118
122
  - - ! '>='
119
123
  - !ruby/object:Gem::Version
120
124
  version: '0'
121
125
  segments:
122
126
  - 0
123
- hash: -1129641372544859423
127
+ hash: -4485904871753900151
128
+ none: false
124
129
  requirements: []
125
130
  rubyforge_project:
126
131
  rubygems_version: 1.8.24