tml 5.4.5 → 5.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 55a593dd10fe515d4bc86495de5df5bfc0174e74
4
- data.tar.gz: 3630a827b871144f534d4eb0e3f96b511fc0ca44
3
+ metadata.gz: cabb1d4b4e4a202fda309b2d0f140a1f4c91c58f
4
+ data.tar.gz: c332c1f7653cecbc6ac7b619fa3d9e00a4a1483d
5
5
  SHA512:
6
- metadata.gz: 487911fa7073003f1e73f95e74c134a801f742795dc2e7783e2c26c975a6a035d718826cfa6614a6f397cb23e899508aa140a0ceffe8466c152471b856393b5e
7
- data.tar.gz: 324205be9a2ae9d5d4a9ede6d178ffe0418333b39b1f60cad0de00d0d7f1d889579ec2a5ac8a77aaea2ad387ee553407bfe8545011cd23f9965176278fe0336b
6
+ metadata.gz: d64b807628e15e3d18cb7cacba69d1e4fd5407dd62fb35e27d37f04b48df82e50c12feec2e845c46ac0d97ee5796028b53b02eda76b3be2e763963ac83d82ccc
7
+ data.tar.gz: 1deca44da3cb162a4355aa4b4e17438f750852f1567c2c515682f3d913e37f4d9edbe460212175bd626c9a1da3fa6d245ad5d3e84378de7b75e694dcc6e73bc1
@@ -68,12 +68,12 @@ module Tml
68
68
  expires_at = version['t'] + version_check_interval
69
69
  if expires_at < Time.now.to_i
70
70
  Tml.logger.debug('Cache version is outdated, needs refresh')
71
- 'undefined'
72
- else
73
- delta = expires_at - Time.now.to_i
74
- Tml.logger.debug("Cache version is up to date, expires in #{delta}s")
75
- version['version']
71
+ return 'undefined'
76
72
  end
73
+
74
+ delta = expires_at - Time.now.to_i
75
+ Tml.logger.debug("Cache version is up to date, expires in #{delta}s")
76
+ version['version']
77
77
  end
78
78
 
79
79
  # fetches the version from the cache
@@ -289,19 +289,11 @@ module Tml
289
289
  }
290
290
  }
291
291
 
292
- @invalidator ||= {
293
- enabled: true,
294
- path: '/tml/upgrade',
295
- auth: lambda do |request|
296
- request.params[:access_token] == application[:token]
297
- end
298
- }
299
-
300
292
  @localization = {
301
- :default_day_names => ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
302
- :default_abbr_day_names => ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
303
- :default_month_names => ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
304
- :default_abbr_month_names => ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
293
+ :default_day_names => %w(Sunday Monday Tuesday Wednesday Thursday Friday Saturday),
294
+ :default_abbr_day_names => %w(Sun Mon Tue Wed Thu Fri Sat),
295
+ :default_month_names => %w(January February March April May June July August September October November December),
296
+ :default_abbr_month_names => %w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec),
305
297
  :custom_date_formats => {
306
298
  :default => '%m/%d/%Y', # 07/4/2008
307
299
  :short_numeric => '%m/%d', # 07/4
@@ -32,7 +32,7 @@
32
32
  class Array
33
33
 
34
34
  # translates an array of options for a select tag
35
- def tro(description = '', options = {})
35
+ def translate_options(description = '', options = {})
36
36
  return [] if empty?
37
37
 
38
38
  options = options.merge(:skip_decorations => true)
@@ -47,6 +47,7 @@ class Array
47
47
  end
48
48
  end
49
49
  end
50
+ alias_method :tro, :translate_options
50
51
 
51
52
  # translates and joins all elements
52
53
  def translate_and_join(separator = ', ', description = '', options = {})
@@ -46,7 +46,7 @@ module Tml
46
46
  key = opts[:key] || Tml.config.application[:key]
47
47
  host = opts[:host] || Tml.config.application[:host]
48
48
  cdn_host = opts[:cdn_host] || Tml.config.application[:cdn_host]
49
- token = opts[:access_token] || Tml.config.application[:token]
49
+ token = opts[:access_token] || opts[:token] || Tml.config.application[:token]
50
50
 
51
51
  Tml.cache.reset_version
52
52
 
@@ -102,7 +102,8 @@ module Tml
102
102
 
103
103
  def target_language
104
104
  target_locale = block_option(:target_locale)
105
- target_locale ? application.language(target_locale) : current_language
105
+ language = (target_locale ? application.language(target_locale) : current_language)
106
+ language || Tml.config.default_language
106
107
  end
107
108
 
108
109
  def inline_mode?
@@ -136,6 +136,7 @@ module Tml
136
136
  # :separator => ', ',
137
137
  # :joiner => 'and',
138
138
  # :remainder => lambda{|elements| tr("#{count||other}", :count => elements.size)},
139
+ # :translate => false,
139
140
  # :expandable => true,
140
141
  # :collapsable => true
141
142
  # })
@@ -254,7 +255,7 @@ module Tml
254
255
  def token_value_from_array_param(array, language, options)
255
256
  # if you provided an array, it better have some values
256
257
  if array.size < 2
257
- return error("Invalid value for array token #{full_name} in #{label}")
258
+ return sanitize(array[0], array[0], language, options.merge(:safe => false))
258
259
  end
259
260
 
260
261
  # if the first value of an array is an array handle it here
@@ -279,6 +280,11 @@ module Tml
279
280
  return sanitize(array[0].send(array[1]), array[0], language, options.merge(:safe => false))
280
281
  end
281
282
 
283
+ # if second param is a lambda
284
+ if array[1].is_a?(Proc)
285
+ return sanitize(array[1].call(array[0]), array[0], language, options.merge(:safe => false))
286
+ end
287
+
282
288
  error("Invalid value for array token #{full_name} in #{label}")
283
289
  end
284
290
 
@@ -103,7 +103,7 @@ class Tml::Tokens::Transform < Tml::Tokens::Data
103
103
  # transform: ["unsupported", {"male": "{$0}", "female": "{$1}", "other": "{$0}/{$1}"}]
104
104
  # results in: {"male": "Dorogoi", "female": "Dorogaya", "other": "Dorogoi/Dorogaya"}
105
105
  #
106
- # token: {actors:|| likes, like}
106
+ # token: {actors || likes, like}
107
107
  # transform: ["unsupported", {"one": "{$0}", "other": "{$1}"}]
108
108
  # results in: {"one": "likes", "other": "like"}
109
109
  def generate_value_map(params, context)
@@ -31,7 +31,7 @@
31
31
  #++
32
32
 
33
33
  module Tml
34
- VERSION = '5.4.5'
34
+ VERSION = '5.4.6'
35
35
 
36
36
  def self.full_version
37
37
  "tml-ruby v#{Tml::VERSION} (Faraday v#{Faraday::VERSION})"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tml
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.4.5
4
+ version: 5.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Berkovich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-04 00:00:00.000000000 Z
11
+ date: 2016-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday