tr8n_core 4.0.7 → 4.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/lib/tr8n/api_client.rb +28 -18
  4. data/lib/tr8n/application.rb +37 -64
  5. data/lib/tr8n/cache.rb +8 -41
  6. data/lib/tr8n/cache_adapters/file.rb +1 -2
  7. data/lib/tr8n/cache_adapters/memcache.rb +2 -2
  8. data/lib/tr8n/cache_adapters/redis.rb +2 -2
  9. data/lib/tr8n/config.rb +48 -13
  10. data/lib/tr8n/decorators/html.rb +3 -10
  11. data/lib/tr8n/language.rb +25 -112
  12. data/lib/tr8n/language_case.rb +1 -1
  13. data/lib/tr8n/session.rb +2 -9
  14. data/lib/tr8n/source.rb +12 -44
  15. data/lib/tr8n/{tokens/data_tokenizer.rb → tokenizers/data.rb} +4 -3
  16. data/lib/tr8n/{tokens/decoration_tokenizer.rb → tokenizers/decoration.rb} +6 -5
  17. data/lib/tr8n/tokenizers/dom.rb +346 -0
  18. data/lib/tr8n/tokens/data.rb +15 -22
  19. data/lib/tr8n/tokens/transform.rb +24 -12
  20. data/lib/tr8n/translation_key.rb +6 -29
  21. data/lib/tr8n/utils.rb +5 -0
  22. data/lib/tr8n_core/version.rb +1 -1
  23. data/lib/tr8n_core.rb +7 -26
  24. metadata +30 -100
  25. data/lib/tr8n/cache_adapters/cdb.rb +0 -87
  26. data/lib/tr8n/tokens/hidden.rb +0 -57
  27. data/spec/application_spec.rb +0 -52
  28. data/spec/base_spec.rb +0 -19
  29. data/spec/cache/adapters/file_spec.rb +0 -32
  30. data/spec/cache/adapters/memcache_spec.rb +0 -15
  31. data/spec/cache/generators/file_generator_spec.rb +0 -30
  32. data/spec/config_spec.rb +0 -32
  33. data/spec/decorator_spec.rb +0 -12
  34. data/spec/decorators/base_spec.rb +0 -14
  35. data/spec/decorators/default_spec.rb +0 -12
  36. data/spec/decorators/html_spec.rb +0 -50
  37. data/spec/ext/array_spec.rb +0 -12
  38. data/spec/ext/hash_spec.rb +0 -15
  39. data/spec/ext/string_spec.rb +0 -10
  40. data/spec/fixtures/application.json +0 -112
  41. data/spec/fixtures/languages/en-US.json +0 -1424
  42. data/spec/fixtures/languages/es.json +0 -291
  43. data/spec/fixtures/languages/ru.json +0 -582
  44. data/spec/fixtures/translations/ru/basic.json +0 -56
  45. data/spec/fixtures/translations/ru/counters.json +0 -43
  46. data/spec/fixtures/translations/ru/genders.json +0 -171
  47. data/spec/fixtures/translations/ru/last_names.txt +0 -200
  48. data/spec/fixtures/translations/ru/names.json +0 -1
  49. data/spec/fixtures/translations/ru/names.txt +0 -458
  50. data/spec/language_case_rule_spec.rb +0 -57
  51. data/spec/language_case_spec.rb +0 -58
  52. data/spec/language_context_rule_spec.rb +0 -75
  53. data/spec/language_context_spec.rb +0 -333
  54. data/spec/language_spec.rb +0 -615
  55. data/spec/logger_spec.rb +0 -15
  56. data/spec/rules_engine/evaluator_spec.rb +0 -150
  57. data/spec/rules_engine/parser_spec.rb +0 -31
  58. data/spec/source_spec.rb +0 -13
  59. data/spec/spec_helper.rb +0 -101
  60. data/spec/tokens/data_spec.rb +0 -114
  61. data/spec/tokens/data_tokenizer_spec.rb +0 -29
  62. data/spec/tokens/decoration_tokenizer_spec.rb +0 -81
  63. data/spec/tokens/hidden_spec.rb +0 -24
  64. data/spec/tokens/method_spec.rb +0 -84
  65. data/spec/tokens/transform_spec.rb +0 -50
  66. data/spec/translation_key_spec.rb +0 -96
  67. data/spec/translation_spec.rb +0 -24
  68. data/spec/utils_spec.rb +0 -62
@@ -81,18 +81,18 @@ module Tr8n
81
81
  "#{name}::#{keys.join('::')}"
82
82
  end
83
83
 
84
- def context_for_language(language, opts = {})
84
+ def context_for_language(language)
85
85
  if context_keys.any?
86
- ctx = language.context_by_keyword(context_keys.first)
86
+ language.context_by_keyword(context_keys.first)
87
87
  else
88
- ctx = language.context_by_token_name(short_name)
89
- end
90
-
91
- unless opts[:silent]
92
- raise Tr8n::Exception.new("Unknown context for a token: #{full_name} in #{language.locale}") unless ctx
88
+ language.context_by_token_name(short_name)
93
89
  end
90
+ end
94
91
 
95
- ctx
92
+ # Utility method for errors
93
+ def error(msg, return_token = true)
94
+ Tr8n.logger.error(msg)
95
+ return_token ? full_name : label
96
96
  end
97
97
 
98
98
  ##############################################################################
@@ -252,8 +252,7 @@ module Tr8n
252
252
  def token_value_from_array_param(array, language, options)
253
253
  # if you provided an array, it better have some values
254
254
  if array.size < 2
255
- Tr8n.logger.error("Invalid value for array token #{full_name} in #{label}")
256
- return full_name
255
+ return error("Invalid value for array token #{full_name} in #{label}")
257
256
  end
258
257
 
259
258
  # if the first value of an array is an array handle it here
@@ -270,8 +269,7 @@ module Tr8n
270
269
  return sanitize(Tr8n::Utils.hash_value(array[0], array[1]), array[0], language, options.merge(:safe => false))
271
270
  end
272
271
 
273
- Tr8n.logger.error("Invalid value for array token #{full_name} in #{label}")
274
- return full_name
272
+ return error("Invalid value for array token #{full_name} in #{label}")
275
273
  end
276
274
 
277
275
  # if second param is symbol, invoke the method on the object with the remaining values
@@ -279,8 +277,7 @@ module Tr8n
279
277
  return sanitize(array[0].send(array[1]), array[0], language, options.merge(:safe => false))
280
278
  end
281
279
 
282
- Tr8n.logger.error("Invalid value for array token #{full_name} in #{label}")
283
- full_name
280
+ error("Invalid value for array token #{full_name} in #{label}")
284
281
  end
285
282
 
286
283
  ##############################################################################
@@ -308,8 +305,7 @@ module Tr8n
308
305
  end
309
306
 
310
307
  if object.nil?
311
- Tr8n.logger.error("Missing value for hash token #{full_name} in #{label}")
312
- return full_name
308
+ return error("Missing value for hash token #{full_name} in #{label}")
313
309
  end
314
310
 
315
311
  attr = Tr8n::Utils.hash_value(hash, :attribute) || Tr8n::Utils.hash_value(hash, :property)
@@ -319,8 +315,7 @@ module Tr8n
319
315
  return sanitize(Tr8n::Utils.hash_value(object, attr), object, language, options.merge(:safe => false))
320
316
  end
321
317
 
322
- Tr8n.logger.error("Missing value for hash token #{full_name} in #{label}")
323
- return full_name
318
+ return error("Missing value for hash token #{full_name} in #{label}")
324
319
  end
325
320
 
326
321
  sanitize(object.send(attr), object, language, options.merge(:safe => false))
@@ -383,13 +378,11 @@ module Tr8n
383
378
  object = Tr8n.config.default_token_value(key) if object.nil?
384
379
 
385
380
  if object.nil? and not context.key?(key)
386
- Tr8n.logger.error("Missing value for #{full_name} in #{label}")
387
- return label
381
+ return error("Missing value for #{full_name} in #{label}", false)
388
382
  end
389
383
 
390
384
  if object.nil? and not Tr8n::Config.allow_nil_token_values?
391
- Tr8n.logger.error("Token value is nil for #{full_name} in #{label}")
392
- return label
385
+ return error("Token value is nil for #{full_name} in #{label}", false)
393
386
  end
394
387
 
395
388
  return label.gsub(full_name, "") if object.nil?
@@ -118,24 +118,28 @@ class Tr8n::Tokens::Transform < Tr8n::Tokens::Data
118
118
  end
119
119
 
120
120
  unless context.token_mapping
121
- raise Tr8n::Exception.new("The token context #{context.keyword} does not support transformation for unnamed params: #{full_name}")
121
+ error("The token context #{context.keyword} does not support transformation for unnamed params: #{full_name}")
122
+ return nil
122
123
  end
123
124
 
124
125
  token_mapping = context.token_mapping
125
126
 
126
127
  # "unsupported"
127
128
  if token_mapping.is_a?(String)
128
- raise Tr8n::Exception.new("The token mapping #{token_mapping} does not support #{params.size} params: #{full_name}")
129
+ error("The token mapping #{token_mapping} does not support #{params.size} params: #{full_name}")
130
+ return nil
129
131
  end
130
132
 
131
133
  # ["unsupported", "unsupported", {}]
132
134
  if token_mapping.is_a?(Array)
133
135
  if params.size > token_mapping.size
134
- raise Tr8n::Exception.new("The token mapping #{token_mapping} does not support #{params.size} params: #{full_name}")
136
+ error("The token mapping #{token_mapping} does not support #{params.size} params: #{full_name}")
137
+ return nil
135
138
  end
136
139
  token_mapping = token_mapping[params.size-1]
137
140
  if token_mapping.is_a?(String)
138
- raise Tr8n::Exception.new("The token mapping #{token_mapping} does not support #{params.size} params: #{full_name}")
141
+ error("The token mapping #{token_mapping} does not support #{params.size} params: #{full_name}")
142
+ return nil
139
143
  end
140
144
  end
141
145
 
@@ -148,7 +152,8 @@ class Tr8n::Tokens::Transform < Tr8n::Tokens::Data
148
152
  index = parts.first.gsub('$', '').to_i
149
153
 
150
154
  if params.size < index
151
- raise Tr8n::Exception.new("The index inside #{context.token_mapping} is out of bound: #{full_name}")
155
+ error("The index inside #{context.token_mapping} is out of bound: #{full_name}")
156
+ return nil
152
157
  end
153
158
 
154
159
  # apply settings cases
@@ -157,7 +162,8 @@ class Tr8n::Tokens::Transform < Tr8n::Tokens::Data
157
162
  parts[1..-1].each do |case_key|
158
163
  lcase = context.language.case_by_keyword(case_key)
159
164
  unless lcase
160
- raise Tr8n::Exception.new("Language case #{case_key} for context #{context.keyword} is not defined: #{full_name}")
165
+ error("Language case #{case_key} for context #{context.keyword} is not defined: #{full_name}")
166
+ return nil
161
167
  end
162
168
  value = lcase.apply(value)
163
169
  end
@@ -173,19 +179,25 @@ class Tr8n::Tokens::Transform < Tr8n::Tokens::Data
173
179
  object = self.class.token_object(context, key)
174
180
 
175
181
  unless object
176
- Tr8n.logger.error("Missing value for a token \"#{key}\" in \"#{label}\"")
177
- return label
182
+ return error("Missing value for a token \"#{key}\" in \"#{label}\"", false)
178
183
  end
179
184
 
180
185
  if piped_params.empty?
181
- Tr8n.logger.error("Piped params may not be empty for token \"#{key}\" in \"#{label}\"")
182
- return label
186
+ return error("Piped params may not be empty for token \"#{key}\" in \"#{label}\"", false)
183
187
  end
184
188
 
185
189
  language_context = context_for_language(language)
186
190
 
191
+ unless language_context
192
+ return error("Unknown context for a token: #{full_name} in #{language.locale}", false)
193
+ end
194
+
187
195
  piped_values = generate_value_map(piped_params, language_context)
188
196
 
197
+ unless piped_values
198
+ return error("Failed to generate value map for: #{full_name} in #{language.locale}", false)
199
+ end
200
+
189
201
  rule = language_context.find_matching_rule(object)
190
202
  return label unless rule
191
203
 
@@ -199,13 +211,13 @@ class Tr8n::Tokens::Transform < Tr8n::Tokens::Data
199
211
  substitution_value = []
200
212
  if displayed_in_translation?
201
213
  substitution_value << token_value(Tr8n::Utils.hash_value(context, key), language, options)
202
- substitution_value << " "
214
+ substitution_value << ' '
203
215
  else
204
216
  value = value.gsub("##{short_name}#", token_value(Tr8n::Utils.hash_value(context, key), language, options))
205
217
  end
206
218
  substitution_value << value
207
219
 
208
- label.gsub(full_name, substitution_value.join(""))
220
+ label.gsub(full_name, substitution_value.join(''))
209
221
  end
210
222
 
211
223
  end
@@ -145,7 +145,7 @@ class Tr8n::TranslationKey < Tr8n::Base
145
145
  # Returns an array of decoration tokens from the translation key
146
146
  def decoration_tokens
147
147
  @decoration_tokens ||= begin
148
- dt = Tr8n::Tokens::DecorationTokenizer.new(label)
148
+ dt = Tr8n::Tokenizers::Decoration.new(label)
149
149
  dt.parse
150
150
  dt.tokens
151
151
  end
@@ -154,7 +154,7 @@ class Tr8n::TranslationKey < Tr8n::Base
154
154
  # Returns an array of data tokens from the translation key
155
155
  def data_tokens
156
156
  @data_tokens ||= begin
157
- dt = Tr8n::Tokens::DataTokenizer.new(label)
157
+ dt = Tr8n::Tokenizers::Data.new(label)
158
158
  dt.tokens
159
159
  end
160
160
  end
@@ -176,38 +176,15 @@ class Tr8n::TranslationKey < Tr8n::Base
176
176
  end
177
177
 
178
178
  def substitute_tokens(translated_label, token_values, language, options = {})
179
- if Tr8n::Tokens::DataTokenizer.required?(translated_label)
180
- translated_label = Tr8n::Tokens::DataTokenizer.new(translated_label, token_values, :allowed_tokens => data_tokens_names_map).substitute(language, options)
179
+ if Tr8n::Tokenizers::Data.required?(translated_label)
180
+ translated_label = Tr8n::Tokenizers::Data.new(translated_label, token_values, :allowed_tokens => data_tokens_names_map).substitute(language, options)
181
181
  end
182
182
 
183
- if Tr8n::Tokens::DecorationTokenizer.required?(translated_label)
184
- translated_label = Tr8n::Tokens::DecorationTokenizer.new(translated_label, token_values, :allowed_tokens => decoration_tokens).substitute
183
+ if Tr8n::Tokenizers::Decoration.required?(translated_label)
184
+ translated_label = Tr8n::Tokenizers::Decoration.new(translated_label, token_values, :allowed_tokens => decoration_tokens).substitute
185
185
  end
186
186
 
187
187
  translated_label
188
188
  end
189
189
 
190
- #######################################################################################################
191
- ## Cache Methods
192
- #######################################################################################################
193
-
194
- def self.cache_prefix
195
- 't@'
196
- end
197
-
198
- def self.cache_key(label, description, locale)
199
- "#{cache_prefix}_[#{locale}]_[#{generate_key(label, description)}]";
200
- end
201
-
202
- def to_cache_hash
203
- hash = to_hash(:id, :key, :label, :description, :locale, :level, :locked)
204
- if translations and translations.any?
205
- hash["translations"] = {}
206
- translations.each do |locale, locale_translations|
207
- hash["translations"][locale] = locale_translations.collect{|t| t.to_cache_hash}
208
- end
209
- end
210
- hash
211
- end
212
-
213
190
  end
data/lib/tr8n/utils.rb CHANGED
@@ -115,6 +115,11 @@ module Tr8n
115
115
  JSON.parse(Base64.decode64(payload))
116
116
  end
117
117
 
118
+ def self.split_sentences(paragraph)
119
+ sentence_regex = /[^.!?\s][^.!?]*(?:[.!?](?![\'"]?\s|$)[^.!?]*)*[.!?]?[\'"]?(?=\s|$)/
120
+ paragraph.match(sentence_regex)
121
+ end
122
+
118
123
  ######################################################################
119
124
  # Author: Iain Hecker
120
125
  # reference: http://github.com/iain/http_accept_language
@@ -30,5 +30,5 @@
30
30
  #++
31
31
 
32
32
  module Tr8nCore
33
- VERSION = "4.0.7"
33
+ VERSION = "4.0.9"
34
34
  end
data/lib/tr8n_core.rb CHANGED
@@ -38,35 +38,16 @@ module Tr8nCore
38
38
  end
39
39
 
40
40
  module Tr8n
41
- module Tokens
42
- end
43
-
44
- module Rules
45
- end
46
-
47
- module Decorators
48
- end
49
-
50
- module CacheAdapters
51
- end
41
+ module Tokens end
42
+ module Tokenizers end
43
+ module Rules end
44
+ module Decorators end
45
+ module CacheAdapters end
52
46
  end
53
47
 
54
- [
55
- "tr8n/base.rb",
56
- "tr8n",
57
- "tr8n/rules_engine",
58
- "tr8n/tokens",
59
- "tr8n/decorators",
60
- "tr8n/cache_adapters",
61
- "tr8n/cache",
62
- "tr8n/cache/generators",
63
- "tr8n_core/ext",
64
- "tr8n_core/modules",
65
- "tr8n_core/generators/cache",
66
- ].each do |f|
48
+ %w(tr8n/base.rb tr8n tr8n/rules_engine tr8n/tokens tr8n/tokenizers tr8n/decorators tr8n/cache_adapters tr8n/cache tr8n/cache/generators tr8n_core/ext tr8n_core/modules tr8n_core/generators/cache).each do |f|
67
49
  if f.index('.rb')
68
- file = File.expand_path(File.join(File.dirname(__FILE__), f))
69
- require(file)
50
+ require(File.expand_path(File.join(File.dirname(__FILE__), f)))
70
51
  next
71
52
  end
72
53
 
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tr8n_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.7
4
+ version: 4.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Berkovich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-21 00:00:00.000000000 Z
11
+ date: 2014-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '0.9'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '0.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: nokogiri
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
27
41
  description: Tr8n core classes that can be used by any Ruby framework
28
42
  email:
29
43
  - michael@tr8nhub.com
@@ -31,11 +45,13 @@ executables: []
31
45
  extensions: []
32
46
  extra_rdoc_files: []
33
47
  files:
48
+ - LICENSE
49
+ - README.md
50
+ - Rakefile
34
51
  - lib/tr8n/api_client.rb
35
52
  - lib/tr8n/application.rb
36
53
  - lib/tr8n/base.rb
37
54
  - lib/tr8n/cache.rb
38
- - lib/tr8n/cache_adapters/cdb.rb
39
55
  - lib/tr8n/cache_adapters/file.rb
40
56
  - lib/tr8n/cache_adapters/memcache.rb
41
57
  - lib/tr8n/cache_adapters/redis.rb
@@ -55,16 +71,17 @@ files:
55
71
  - lib/tr8n/rules_engine/parser.rb
56
72
  - lib/tr8n/session.rb
57
73
  - lib/tr8n/source.rb
74
+ - lib/tr8n/tokenizers/data.rb
75
+ - lib/tr8n/tokenizers/decoration.rb
76
+ - lib/tr8n/tokenizers/dom.rb
58
77
  - lib/tr8n/tokens/data.rb
59
- - lib/tr8n/tokens/data_tokenizer.rb
60
- - lib/tr8n/tokens/decoration_tokenizer.rb
61
- - lib/tr8n/tokens/hidden.rb
62
78
  - lib/tr8n/tokens/method.rb
63
79
  - lib/tr8n/tokens/transform.rb
64
80
  - lib/tr8n/translation.rb
65
81
  - lib/tr8n/translation_key.rb
66
82
  - lib/tr8n/translator.rb
67
83
  - lib/tr8n/utils.rb
84
+ - lib/tr8n_core.rb
68
85
  - lib/tr8n_core/ext/array.rb
69
86
  - lib/tr8n_core/ext/date.rb
70
87
  - lib/tr8n_core/ext/fixnum.rb
@@ -76,52 +93,6 @@ files:
76
93
  - lib/tr8n_core/generators/cache/file.rb
77
94
  - lib/tr8n_core/languages/en-US.json
78
95
  - lib/tr8n_core/version.rb
79
- - lib/tr8n_core.rb
80
- - LICENSE
81
- - Rakefile
82
- - README.md
83
- - spec/application_spec.rb
84
- - spec/base_spec.rb
85
- - spec/cache/adapters/file_spec.rb
86
- - spec/cache/adapters/memcache_spec.rb
87
- - spec/cache/generators/file_generator_spec.rb
88
- - spec/config_spec.rb
89
- - spec/decorator_spec.rb
90
- - spec/decorators/base_spec.rb
91
- - spec/decorators/default_spec.rb
92
- - spec/decorators/html_spec.rb
93
- - spec/ext/array_spec.rb
94
- - spec/ext/hash_spec.rb
95
- - spec/ext/string_spec.rb
96
- - spec/fixtures/application.json
97
- - spec/fixtures/languages/en-US.json
98
- - spec/fixtures/languages/es.json
99
- - spec/fixtures/languages/ru.json
100
- - spec/fixtures/translations/ru/basic.json
101
- - spec/fixtures/translations/ru/counters.json
102
- - spec/fixtures/translations/ru/genders.json
103
- - spec/fixtures/translations/ru/last_names.txt
104
- - spec/fixtures/translations/ru/names.json
105
- - spec/fixtures/translations/ru/names.txt
106
- - spec/language_case_rule_spec.rb
107
- - spec/language_case_spec.rb
108
- - spec/language_context_rule_spec.rb
109
- - spec/language_context_spec.rb
110
- - spec/language_spec.rb
111
- - spec/logger_spec.rb
112
- - spec/rules_engine/evaluator_spec.rb
113
- - spec/rules_engine/parser_spec.rb
114
- - spec/source_spec.rb
115
- - spec/spec_helper.rb
116
- - spec/tokens/data_spec.rb
117
- - spec/tokens/data_tokenizer_spec.rb
118
- - spec/tokens/decoration_tokenizer_spec.rb
119
- - spec/tokens/hidden_spec.rb
120
- - spec/tokens/method_spec.rb
121
- - spec/tokens/transform_spec.rb
122
- - spec/translation_key_spec.rb
123
- - spec/translation_spec.rb
124
- - spec/utils_spec.rb
125
96
  homepage: https://github.com/tr8n/tr8n_ruby_core
126
97
  licenses:
127
98
  - MIT-LICENSE
@@ -142,50 +113,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
113
  version: '0'
143
114
  requirements: []
144
115
  rubyforge_project:
145
- rubygems_version: 2.0.3
116
+ rubygems_version: 2.4.1
146
117
  signing_key:
147
118
  specification_version: 4
148
119
  summary: Tr8n Core Classes
149
- test_files:
150
- - spec/application_spec.rb
151
- - spec/base_spec.rb
152
- - spec/cache/adapters/file_spec.rb
153
- - spec/cache/adapters/memcache_spec.rb
154
- - spec/cache/generators/file_generator_spec.rb
155
- - spec/config_spec.rb
156
- - spec/decorator_spec.rb
157
- - spec/decorators/base_spec.rb
158
- - spec/decorators/default_spec.rb
159
- - spec/decorators/html_spec.rb
160
- - spec/ext/array_spec.rb
161
- - spec/ext/hash_spec.rb
162
- - spec/ext/string_spec.rb
163
- - spec/fixtures/application.json
164
- - spec/fixtures/languages/en-US.json
165
- - spec/fixtures/languages/es.json
166
- - spec/fixtures/languages/ru.json
167
- - spec/fixtures/translations/ru/basic.json
168
- - spec/fixtures/translations/ru/counters.json
169
- - spec/fixtures/translations/ru/genders.json
170
- - spec/fixtures/translations/ru/last_names.txt
171
- - spec/fixtures/translations/ru/names.json
172
- - spec/fixtures/translations/ru/names.txt
173
- - spec/language_case_rule_spec.rb
174
- - spec/language_case_spec.rb
175
- - spec/language_context_rule_spec.rb
176
- - spec/language_context_spec.rb
177
- - spec/language_spec.rb
178
- - spec/logger_spec.rb
179
- - spec/rules_engine/evaluator_spec.rb
180
- - spec/rules_engine/parser_spec.rb
181
- - spec/source_spec.rb
182
- - spec/spec_helper.rb
183
- - spec/tokens/data_spec.rb
184
- - spec/tokens/data_tokenizer_spec.rb
185
- - spec/tokens/decoration_tokenizer_spec.rb
186
- - spec/tokens/hidden_spec.rb
187
- - spec/tokens/method_spec.rb
188
- - spec/tokens/transform_spec.rb
189
- - spec/translation_key_spec.rb
190
- - spec/translation_spec.rb
191
- - spec/utils_spec.rb
120
+ test_files: []
121
+ has_rdoc:
@@ -1,87 +0,0 @@
1
- # encoding: UTF-8
2
- #--
3
- # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
- #
5
- # _______ _ _ _ ______ _
6
- # |__ __| | | | | (_) | ____| | |
7
- # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
- # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
- # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
- # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
- # __/ |
12
- # |___/
13
- # Permission is hereby granted, free of charge, to any person obtaining
14
- # a copy of this software and associated documentation files (the
15
- # "Software"), to deal in the Software without restriction, including
16
- # without limitation the rights to use, copy, modify, merge, publish,
17
- # distribute, sublicense, and/or sell copies of the Software, and to
18
- # permit persons to whom the Software is furnished to do so, subject to
19
- # the following conditions:
20
- #
21
- # The above copyright notice and this permission notice shall be
22
- # included in all copies or substantial portions of the Software.
23
- #
24
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31
- #++
32
-
33
- require 'libcdb' if defined?(LibCDB)
34
-
35
- class Tr8n::CacheAdapters::Cdb < Tr8n::Cache
36
-
37
- def initialize
38
- @cache = LibCDB::CDB.open(cache_path)
39
- end
40
-
41
- def cache_name
42
- "cdb"
43
- end
44
-
45
- def self.cache_path
46
- "#{Tr8n.config.cache[:path]}/cdb/current.cdb"
47
- end
48
-
49
- def cached_by_source?
50
- false
51
- end
52
-
53
- def fetch(key, opts = {})
54
- data = @cache[key]
55
- if data
56
- info("Cache hit: #{key}")
57
- return deserialize_object(key, data)
58
- end
59
-
60
- info("Cache miss: #{key}")
61
-
62
- return nil unless block_given?
63
-
64
- yield
65
- rescue Exception => ex
66
- warn("Failed to retrieve data: #{ex.message}")
67
- return nil unless block_given?
68
- yield
69
- end
70
-
71
- def store(key, data, opts = {})
72
- warn("This is a readonly cache")
73
- end
74
-
75
- def delete(key, opts = {})
76
- warn("This is a readonly cache")
77
- end
78
-
79
- def exist?(key, opts = {})
80
- @cache[key]
81
- end
82
-
83
- def clear(opts = {})
84
- warn("This is a readonly cache")
85
- end
86
-
87
- end
@@ -1,57 +0,0 @@
1
- # encoding: UTF-8
2
- #--
3
- # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
- #
5
- # _______ _ _ _ ______ _
6
- # |__ __| | | | | (_) | ____| | |
7
- # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
- # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
- # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
- # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
- # __/ |
12
- # |___/
13
- # Permission is hereby granted, free of charge, to any person obtaining
14
- # a copy of this software and associated documentation files (the
15
- # "Software"), to deal in the Software without restriction, including
16
- # without limitation the rights to use, copy, modify, merge, publish,
17
- # distribute, sublicense, and/or sell copies of the Software, and to
18
- # permit persons to whom the Software is furnished to do so, subject to
19
- # the following conditions:
20
- #
21
- # The above copyright notice and this permission notice shall be
22
- # included in all copies or substantial portions of the Software.
23
- #
24
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31
- #++
32
-
33
- #######################################################################
34
- #
35
- # Hidden Token Forms:
36
- #
37
- # {_he_she}
38
- # {_posted__items}
39
- #
40
- # '_' escaped as '/'
41
- # '__' escaped as '__'
42
- #
43
- # Hidden tokens cannot have rules and are there for default language
44
- # substitutions only
45
- #
46
- #######################################################################
47
-
48
- class Tr8n::Tokens::Hidden < Tr8n::Tokens::Data
49
- def self.expression
50
- /(\{_[\w]+\})/
51
- end
52
-
53
- def allowed_in_translation?
54
- false
55
- end
56
-
57
- end