tml 4.4.2 → 4.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tml/config.rb +102 -86
  3. data/lib/tml/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c5b559306971c39fdd4df874f01174dd53af720f
4
- data.tar.gz: 64df8e8b2fabc6b1bdab21461b72f0ae0f373687
3
+ metadata.gz: 44adb9e80172d8023dcf8e7b3919a3be0ff499af
4
+ data.tar.gz: 08a06206541073c22a546ed0315cd4b4a54d0bc0
5
5
  SHA512:
6
- metadata.gz: 43033def0b0187721cb8c0020c5ca60958c62228c992ad11e23092c2872f5ad9118a6a8d159854475e5c3636183043b0f9181d021076423ed60a3859e973ae43
7
- data.tar.gz: acbcb86d03f2abf4c5d16a6af803228af8df3dfdb671f0453ca84a9d085d3ad7526c15d2e4d1b1b043b2d949cbc0aaa3ddbf31f05c79ba3297dd2465e66919b0
6
+ metadata.gz: 5208fe912e0d3b62291ae86b544f6048a096d8a681b3dc3ce33ae3dd074ba7bfd3dc9a3fcd5c02bb2cea4485a7864f26c3dc652bac00aef06ba64696d6e5df1f
7
+ data.tar.gz: d0f6454db79e4efa6bfa929698bdf93ceaa1ef5a80f65f67ac0b481380cc18c6718d36ed6346679ff4319ca3e916e98acc8aaf94f40a33b56d869f42470131b8
data/lib/tml/config.rb CHANGED
@@ -75,19 +75,27 @@ module Tml
75
75
  # The class can be extended with a different implementation, as long as the interface is supported
76
76
  class Config
77
77
  # Configuration Attributes
78
- attr_accessor :enabled, :default_locale, :default_level, :format, :application, :context_rules, :logger, :cache, :default_tokens, :localization
78
+ attr_accessor :enabled, :locale, :default_level, :format, :application, :context_rules, :logger, :cache, :default_tokens, :localization
79
79
 
80
80
  # Used by Rails and Sinatra extensions
81
81
  attr_accessor :current_locale_method, :current_user_method, :translator_options, :i18n_backend
82
+ attr_accessor :invalidator
82
83
 
83
84
  # Used for IRB only
84
85
  attr_accessor :submit_missing_keys_realtime
85
86
 
86
87
  def initialize
87
88
  @enabled = true
88
- @default_locale = 'en'
89
89
  @default_level = 0
90
90
  @format = :html
91
+ @subdomains = false
92
+
93
+ @locale = {
94
+ default: 'en',
95
+ method: 'current_locale',
96
+ subdomain: false,
97
+ extension: false
98
+ }
91
99
 
92
100
  # if running from IRB, make it default to TRUE
93
101
  @submit_missing_keys_realtime = (%w(irb pry).include?($0 || ''))
@@ -172,82 +180,90 @@ module Tml
172
180
  @default_tokens = {
173
181
  :html => {
174
182
  :data => {
175
- :ndash => "–", # –
176
- :mdash => "—", # —
177
- :iexcl => "¡", # ¡
178
- :iquest => "¿", # ¿
179
- :quot => """, # "
180
- :ldquo => "“", # “
181
- :rdquo => "”", # ”
182
- :lsquo => "‘", # ‘
183
- :rsquo => "’", # ’
184
- :laquo => "«", # «
185
- :raquo => "»", # »
186
- :nbsp => " ", # space
187
- :lsaquo => "‹", # ‹
188
- :rsaquo => "›", # ›
189
- :br => "<br/>", # line break
190
- :lbrace => "{",
191
- :rbrace => "}",
192
- :trade => "&trade;", # TM
183
+ :ndash => '&ndash;', # –
184
+ :mdash => '&mdash;', # —
185
+ :iexcl => '&iexcl;', # ¡
186
+ :iquest => '&iquest;', # ¿
187
+ :quot => '&quot;', # '
188
+ :ldquo => '&ldquo;', # “
189
+ :rdquo => '&rdquo;', # ”
190
+ :lsquo => '&lsquo;', # ‘
191
+ :rsquo => '&rsquo;', # ’
192
+ :laquo => '&laquo;', # «
193
+ :raquo => '&raquo;', # »
194
+ :nbsp => '&nbsp;', # space
195
+ :lsaquo => '&lsaquo;', # ‹
196
+ :rsaquo => '&rsaquo;', # ›
197
+ :br => '<br/>', # line break
198
+ :lbrace => '{',
199
+ :rbrace => '}',
200
+ :trade => '&trade;', # TM
193
201
  },
194
202
  :decoration => {
195
- :strong => "<strong>{$0}</strong>",
196
- :bold => "<strong>{$0}</strong>",
197
- :b => "<strong>{$0}</strong>",
198
- :em => "<em>{$0}</em>",
199
- :italic => "<i>{$0}</i>",
200
- :i => "<i>{$0}</i>",
203
+ :strong => '<strong>{$0}</strong>',
204
+ :bold => '<strong>{$0}</strong>',
205
+ :b => '<strong>{$0}</strong>',
206
+ :em => '<em>{$0}</em>',
207
+ :italic => '<i>{$0}</i>',
208
+ :i => '<i>{$0}</i>',
201
209
  :link => "<a href='{$href}'>{$0}</a>",
202
- :br => "<br>{$0}",
203
- :strike => "<strike>{$0}</strike>",
210
+ :br => '<br>{$0}',
211
+ :strike => '<strike>{$0}</strike>',
204
212
  :div => "<div id='{$id}' class='{$class}' style='{$style}'>{$0}</div>",
205
213
  :span => "<span id='{$id}' class='{$class}' style='{$style}'>{$0}</span>",
206
- :h1 => "<h1>{$0}</h1>",
207
- :h2 => "<h2>{$0}</h2>",
208
- :h3 => "<h3>{$0}</h3>",
214
+ :h1 => '<h1>{$0}</h1>',
215
+ :h2 => '<h2>{$0}</h2>',
216
+ :h3 => '<h3>{$0}</h3>',
209
217
  }
210
218
  },
211
219
  :text => {
212
220
  :data => {
213
- :ndash => "",
214
- :mdash => "-",
215
- :iexcl => "¡",
216
- :iquest => "¿",
217
- :quot => '"',
218
- :ldquo => "",
219
- :rdquo => "",
220
- :lsquo => "",
221
- :rsquo => "",
222
- :laquo => "«",
223
- :raquo => "»",
224
- :nbsp => " ",
225
- :lsaquo => "",
226
- :rsaquo => "",
227
- :br => "\n",
228
- :lbrace => "{",
229
- :rbrace => "}",
230
- :trade => "",
221
+ :ndash => '',
222
+ :mdash => '-',
223
+ :iexcl => '¡',
224
+ :iquest => '¿',
225
+ :quot => "'",
226
+ :ldquo => '',
227
+ :rdquo => '',
228
+ :lsquo => '',
229
+ :rsquo => '',
230
+ :laquo => '«',
231
+ :raquo => '»',
232
+ :nbsp => ' ',
233
+ :lsaquo => '',
234
+ :rsaquo => '',
235
+ :br => '\n',
236
+ :lbrace => '{',
237
+ :rbrace => '}',
238
+ :trade => '',
231
239
  },
232
240
  :decoration => {
233
- :strong => "{$0}",
234
- :bold => "{$0}",
235
- :b => "{$0}",
236
- :em => "{$0}",
237
- :italic => "{$0}",
238
- :i => "{$0}",
239
- :link => "{$0}:{$1}",
240
- :br => "\n{$0}",
241
- :strike => "{$0}",
242
- :div => "{$0}",
243
- :span => "{$0}",
244
- :h1 => "{$0}",
245
- :h2 => "{$0}",
246
- :h3 => "{$0}",
241
+ :strong => '{$0}',
242
+ :bold => '{$0}',
243
+ :b => '{$0}',
244
+ :em => '{$0}',
245
+ :italic => '{$0}',
246
+ :i => '{$0}',
247
+ :link => '{$0}:{$1}',
248
+ :br => '\n{$0}',
249
+ :strike => '{$0}',
250
+ :div => '{$0}',
251
+ :span => '{$0}',
252
+ :h1 => '{$0}',
253
+ :h2 => '{$0}',
254
+ :h3 => '{$0}',
247
255
  }
248
256
  }
249
257
  }
250
258
 
259
+ @invalidator ||= {
260
+ enabled: true,
261
+ path: '/tml/upgrade',
262
+ auth: lambda do |request|
263
+ request.params[:access_token] == application[:token]
264
+ end
265
+ }
266
+
251
267
  @localization = {
252
268
  :default_day_names => ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
253
269
  :default_abbr_day_names => ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
@@ -266,25 +282,25 @@ module Tml
266
282
  :date_time => '%m/%d/%Y at %H:%M', # 01/03/1010 at 5:30
267
283
  },
268
284
  :token_mapping => {
269
- "%a" => "{short_week_day_name}",
270
- "%A" => "{week_day_name}",
271
- "%b" => "{short_month_name}",
272
- "%B" => "{month_name}",
273
- "%p" => "{am_pm}",
274
- "%d" => "{days}",
275
- "%e" => "{day_of_month}",
276
- "%j" => "{year_days}",
277
- "%m" => "{months}",
278
- "%W" => "{week_num}",
279
- "%w" => "{week_days}",
280
- "%y" => "{short_years}",
281
- "%Y" => "{years}",
282
- "%l" => "{trimed_hour}",
283
- "%H" => "{full_hours}",
284
- "%I" => "{short_hours}",
285
- "%M" => "{minutes}",
286
- "%S" => "{seconds}",
287
- "%s" => "{since_epoch}"
285
+ '%a' => '{short_week_day_name}',
286
+ '%A' => '{week_day_name}',
287
+ '%b' => '{short_month_name}',
288
+ '%B' => '{month_name}',
289
+ '%p' => '{am_pm}',
290
+ '%d' => '{days}',
291
+ '%e' => '{day_of_month}',
292
+ '%j' => '{year_days}',
293
+ '%m' => '{months}',
294
+ '%W' => '{week_num}',
295
+ '%w' => '{week_days}',
296
+ '%y' => '{short_years}',
297
+ '%Y' => '{years}',
298
+ '%l' => '{trimed_hour}',
299
+ '%H' => '{full_hours}',
300
+ '%I' => '{short_hours}',
301
+ '%M' => '{minutes}',
302
+ '%S' => '{seconds}',
303
+ '%s' => '{since_epoch}'
288
304
  }
289
305
  }
290
306
  end
@@ -318,16 +334,16 @@ module Tml
318
334
  ## Application
319
335
  #########################################################
320
336
 
321
- #def default_locale
322
- # return Tml.session.application.default_locale if Tml.session.application
323
- # @default_locale
324
- #end
325
337
  #
326
338
  #def default_level
327
339
  # return Tml.session.application.default_level if Tml.session.application
328
340
  # @default_level
329
341
  #end
330
342
 
343
+ def default_locale
344
+ @locale[:default]
345
+ end
346
+
331
347
  def default_language
332
348
  @default_language ||= begin
333
349
  file = File.expand_path(File.join(File.dirname(__FILE__), '..', 'tml', 'languages', "#{Tml.config.default_locale}.json"))
data/lib/tml/version.rb CHANGED
@@ -30,5 +30,5 @@
30
30
  #++
31
31
 
32
32
  module Tml
33
- VERSION = '4.4.2'
33
+ VERSION = '4.4.3'
34
34
  end
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: 4.4.2
4
+ version: 4.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Berkovich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-11 00:00:00.000000000 Z
11
+ date: 2015-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday