fast_gettext 0.6.10 → 0.6.11

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,10 +1,9 @@
1
1
  source :rubygems
2
2
  gemspec
3
3
 
4
- group :development do
5
- gem 'rake'
6
- gem 'sqlite3'
7
- gem 'rspec', '~>2'
8
- gem 'activerecord', ENV['AR']
9
- gem 'i18n'
10
- end
4
+ gem 'rake'
5
+ gem 'sqlite3'
6
+ gem 'rspec', '~>2'
7
+ gem 'activerecord', ENV['AR']
8
+ gem 'i18n'
9
+ gem 'bump'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fast_gettext (0.6.10)
4
+ fast_gettext (0.6.11)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -19,6 +19,7 @@ GEM
19
19
  multi_json (~> 1.0)
20
20
  arel (3.0.2)
21
21
  builder (3.0.0)
22
+ bump (0.3.3)
22
23
  diff-lcs (1.1.3)
23
24
  i18n (0.6.0)
24
25
  multi_json (1.3.6)
@@ -39,6 +40,7 @@ PLATFORMS
39
40
 
40
41
  DEPENDENCIES
41
42
  activerecord
43
+ bump
42
44
  fast_gettext!
43
45
  i18n
44
46
  rake
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'bundler/gem_tasks'
2
+ require 'bump/tasks'
2
3
 
3
4
  task :default do
4
5
  ['~>2', '~>3'].each do |version|
@@ -8,9 +9,9 @@ task :default do
8
9
  end
9
10
 
10
11
  task :benchmark do
11
- puts "Running on #{RUBY}"
12
+ puts "Running on #{RUBY_DESCRIPTION}"
12
13
  %w[baseline ideal fast_gettext original i18n_simple].each do |bench|
13
- puts `ruby benchmark/#{bench}.rb`
14
+ puts `ruby -I. benchmark/#{bench}.rb`
14
15
  puts ""
15
16
  end
16
17
  end
data/Readme.md CHANGED
@@ -222,6 +222,8 @@ Mo/Po-file parsing from Masao Mutoh, see vendor/README
222
222
  - [Dmitry Borodaenko](https://github.com/angdraug)
223
223
  - [Kouhei Sutou](https://github.com/kou)
224
224
  - [Hoang Nghiem](https://github.com/hoangnghiem)
225
+ - [Costa Shapiro](https://github.com/costa)
226
+ - [Jamie Dyer](https://github.com/kernow)
225
227
 
226
228
  [Michael Grosser](http://grosser.it)<br/>
227
229
  michael@grosser.it<br/>
data/benchmark/base.rb CHANGED
@@ -35,7 +35,11 @@ end
35
35
 
36
36
  def memory
37
37
  pid = Process.pid
38
- map = `pmap -d #{pid}`
38
+ if RUBY_PLATFORM.downcase.include?("darwin")
39
+ map = `vmmap #{pid}`
40
+ else
41
+ map = `pmap -d #{pid}`
42
+ end
39
43
  map.split("\n").last.strip.squeeze(' ').split(' ')[3].to_i - DEFAULTS[:memory]
40
44
  end
41
45
 
@@ -1,7 +1,8 @@
1
1
  require 'benchmark/base'
2
- require 'activesupport'
2
+ require 'active_support'
3
+
3
4
  I18n.backend = I18n::Backend::Simple.new
4
5
  I18n.load_path = ['benchmark/locale/de.yml']
5
6
  I18n.locale = :de
6
7
  puts "ActiveSupport I18n::Backend::Simple :"
7
- results_test{I18n.translate('activerecord.models.car')=='Auto'}
8
+ results_test{I18n.translate('activerecord.models.car')=='Auto'}
@@ -1,4 +1,4 @@
1
- # German translations for Ruby on Rails
1
+ # German translations for Ruby on Rails
2
2
  # by Clemens Kofler (clemens@railway.at)
3
3
 
4
4
  de:
@@ -13,8 +13,7 @@ de:
13
13
  abbr_day_names: [So, Mo, Di, Mi, Do, Fr, Sa]
14
14
  month_names: [~, Januar, Februar, März, April, Mai, Juni, Juli, August, September, Oktober, November, Dezember]
15
15
  abbr_month_names: [~, Jan, Feb, Mär, Apr, Mai, Jun, Jul, Aug, Sep, Okt, Nov, Dez]
16
- order: [ :day, :month, :year ]
17
-
16
+
18
17
  time:
19
18
  formats:
20
19
  default: "%A, %e. %B %Y, %H:%M Uhr"
@@ -24,7 +23,7 @@ de:
24
23
 
25
24
  am: "vormittags"
26
25
  pm: "nachmittags"
27
-
26
+
28
27
  datetime:
29
28
  distance_in_words:
30
29
  half_a_minute: 'eine halbe Minute'
@@ -60,7 +59,7 @@ de:
60
59
  over_x_years:
61
60
  one: 'mehr als 1 Jahr'
62
61
  other: 'mehr als {{count}} Jahre'
63
-
62
+
64
63
  number:
65
64
  format:
66
65
  precision: 2
@@ -70,9 +69,9 @@ de:
70
69
  format:
71
70
  unit: '€'
72
71
  format: '%n%u'
73
- separator:
74
- delimiter:
75
- precision:
72
+ separator:
73
+ delimiter:
74
+ precision:
76
75
  percentage:
77
76
  format:
78
77
  delimiter: ""
@@ -88,7 +87,7 @@ de:
88
87
  array:
89
88
  sentence_connector: "und"
90
89
  skip_last_comma: true
91
-
90
+
92
91
  activerecord:
93
92
  errors:
94
93
  template:
@@ -1,10 +1,13 @@
1
1
  require 'benchmark/base'
2
2
 
3
3
  begin
4
- gem 'gettext', '>=2.0.0'
4
+ gem 'gettext', '>=2.0.0'
5
5
  rescue LoadError
6
- $LOAD_PATH.unshift 'lib'
6
+ puts 'To run this benchmark, please install the gettext gem'
7
+ exit 1
7
8
  end
9
+
10
+ $LOAD_PATH.unshift 'lib'
8
11
  require 'gettext'
9
12
  include GetText
10
13
 
@@ -112,6 +112,10 @@ module FastGettext
112
112
  end
113
113
  end
114
114
 
115
+ def expire_cache_for(key)
116
+ current_cache.delete(key)
117
+ end
118
+
115
119
  def locale
116
120
  _locale || ( default_locale || (available_locales||[]).first || 'en' )
117
121
  end
@@ -3,4 +3,11 @@ class TranslationText < ActiveRecord::Base
3
3
  validates_presence_of :locale
4
4
  validates_uniqueness_of :locale, :scope=>:translation_key_id
5
5
  attr_accessible :text, :locale, :translation_key, :translation_key_id
6
+ after_update :expire_cache
7
+
8
+ protected
9
+
10
+ def expire_cache
11
+ FastGettext.expire_cache_for(translation_key.key)
12
+ end
6
13
  end
@@ -1,3 +1,3 @@
1
1
  module FastGettext
2
- VERSION = Version = '0.6.10'
2
+ VERSION = Version = '0.6.11'
3
3
  end
@@ -327,6 +327,16 @@ describe 'Storage' do
327
327
  end
328
328
  end
329
329
 
330
+ describe :expire_cache_for do
331
+ it "expires the cached key" do
332
+ should_receive(:current_repository).and_return 'xxx' => 'new string'
333
+ current_cache['xxx'] = 'old string'
334
+ cached_find('xxx').should == 'old string'
335
+ expire_cache_for('xxx')
336
+ cached_find('xxx').should == 'new string'
337
+ end
338
+ end
339
+
330
340
  describe FastGettext::Storage::NoTextDomainConfigured do
331
341
  it "shows what to do" do
332
342
  FastGettext::Storage::NoTextDomainConfigured.new.to_s.should =~ /FastGettext\.add_text_domain/
@@ -105,4 +105,10 @@ describe FastGettext::TranslationRepository::Db do
105
105
  translation.should be_accessible(:translation_key_id)
106
106
  translation.should_not be_accessible(:created_at)
107
107
  end
108
+
109
+ it "expires the cache when updated" do
110
+ FastGettext.should_receive(:expire_cache_for).with('car')
111
+ translation_text = create_translation 'car', 'Auto'
112
+ translation_text.update_attributes :text => 'Autobot'
113
+ end
108
114
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast_gettext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.10
4
+ version: 0.6.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-18 00:00:00.000000000 Z
12
+ date: 2012-10-26 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: michael@grosser.it
@@ -111,7 +111,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
111
  version: '0'
112
112
  segments:
113
113
  - 0
114
- hash: -1278908847002659361
114
+ hash: -1129641372544859423
115
115
  required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  version: '0'
121
121
  segments:
122
122
  - 0
123
- hash: -1278908847002659361
123
+ hash: -1129641372544859423
124
124
  requirements: []
125
125
  rubyforge_project:
126
126
  rubygems_version: 1.8.24