air18n 0.1.47 → 0.1.48

Sign up to get free protection for your applications and to get access to all the features.
@@ -116,7 +116,15 @@ module Air18n
116
116
  @contextual_translation= x
117
117
  end
118
118
 
119
- # Returns OrderedHash mapping key => times looked up today or in the last week.
119
+ # The notion of which keys are still used are cached and never reloaded,
120
+ # except after this method is called.
121
+ def reset_notion_of_still_used_phrases
122
+ @priority.reset
123
+ @still_used_phrase_ids = nil
124
+ end
125
+
126
+ # Returns OrderedHash mapping key => times looked up today or in the last
127
+ # week.
120
128
  def still_used_keys_hash
121
129
  # If you want to test with the full allotment of still-used phrases from
122
130
  # production, do this on mainframe:
@@ -143,10 +151,12 @@ module Air18n
143
151
  key_to_phrase_id[record['key']] = record['id']
144
152
  end
145
153
 
146
- still_used_keys.map do |key|
154
+ raw_phrase_ids = still_used_keys.map do |key|
147
155
  LoggingHelper.error "Mystery phrase key: #{key}" if !key_to_phrase_id.include? key
148
156
  key_to_phrase_id[key]
149
157
  end
158
+
159
+ raw_phrase_ids.compact.uniq
150
160
  end
151
161
  end
152
162
 
@@ -14,6 +14,10 @@ module Air18n
14
14
  @key_usage
15
15
  end
16
16
 
17
+ def reset
18
+ @key_usage = {}
19
+ end
20
+
17
21
  def self.mock_priority(key_usage)
18
22
  @old_priority = I18n.priority
19
23
  mock_priority = Air18n::MockPriority.new(key_usage)
@@ -12,5 +12,9 @@ module Air18n
12
12
  def key_usage
13
13
  {}
14
14
  end
15
+
16
+ # Resets caches or anything else to empty state.
17
+ def reset
18
+ end
15
19
  end
16
20
  end
@@ -1,3 +1,3 @@
1
1
  module Air18n
2
- VERSION = "0.1.47"
2
+ VERSION = "0.1.48"
3
3
  end
@@ -61,6 +61,14 @@ describe Air18n do
61
61
  mock_priority.key_usage.should_not include('priority, key 3')
62
62
  end
63
63
  end
64
+
65
+ it 'should be able to reset notion of still-used phrases' do
66
+ Air18n::MockPriority.mock_priority({'still used reset 1' => 1}) do |mock_priority|
67
+ I18n.still_used_keys_hash['still used reset 1'].should == 1
68
+ I18n.reset_notion_of_still_used_phrases
69
+ I18n.still_used_keys_hash.should_not include('still_used reset 1')
70
+ end
71
+ end
64
72
  end
65
73
 
66
74
  context 'XSS attack detection integration test' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: air18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.47
4
+ version: 0.1.48
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2012-12-18 00:00:00.000000000 Z
16
+ date: 2013-01-03 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: i18n