tml 4.3.6 → 4.3.7

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: b305529c8b1fefe33c3d8ba0fd445566a6f7667a
4
- data.tar.gz: 1fe8c90ddcd2d26edc1b7e70894085cf3d8e6470
3
+ metadata.gz: 8c126c7ef27932c28af74a43593a02fcea2d2685
4
+ data.tar.gz: 0d0dee6459bfad414a1f7fd21863c2c66a239aac
5
5
  SHA512:
6
- metadata.gz: 1f8535261a61e58a53fa9bd5e6101ec13b80819adb79a58b89eb4c916fb0d58fa7555b5e359222b6999542b608ad4d638a38fa4a9a731b28993e0163ad842aeb
7
- data.tar.gz: 6c7af851ad4066fa6701704ba3ee06e36b3678d195e30acccbdbbb8cc933fef989c5488752b1fc3e7dd7ea82df660a531e1cee92402c6e495ed602a089be5c8f
6
+ metadata.gz: 8d99bae348d5a7e966c2f1e8b31a8605dff79c54abc6de099761488c42598ff83f4cfe258628e07f9bf3c5fdb41c7c72fbbf2366f5df16d54ebfc2b23fc205d6
7
+ data.tar.gz: f1cd165767e09da195f1fefff6f5d538003fc19d7248e4095b1408f4c6a045922cc80545c2731e043b015de392f1c1a3cdb7e226277be15abc1da07a8c31671f
@@ -64,6 +64,7 @@ class Tml::Application < Tml::Base
64
64
 
65
65
  def language(locale = nil)
66
66
  locale = nil if locale.strip == ''
67
+
67
68
  locale ||= default_locale || Tml.config.default_locale
68
69
  @languages_by_locale ||= {}
69
70
  @languages_by_locale[locale] ||= api_client.get(
@@ -32,6 +32,10 @@
32
32
 
33
33
  class Tml::CacheAdapters::File < Tml::Cache
34
34
 
35
+ def self.cache
36
+ @cache ||= {}
37
+ end
38
+
35
39
  def self.cache_path
36
40
  "#{Tml.config.cache[:path]}/#{Tml.config.cache[:version]}"
37
41
  end
@@ -50,13 +54,17 @@ class Tml::CacheAdapters::File < Tml::Cache
50
54
  end
51
55
 
52
56
  def fetch(key, opts = {})
53
- info("Fetching key: #{key}")
57
+ if self.class.cache[key]
58
+ info("Memory hit: #{key}")
59
+ return self.class.cache[key]
60
+ end
54
61
 
55
62
  path = self.class.file_path(key)
56
63
 
57
64
  if File.exists?(path)
58
65
  info("Cache hit: #{key}")
59
- return JSON.parse(File.read(path))
66
+ self.class.cache[key] = JSON.parse(File.read(path))
67
+ return self.class.cache[key]
60
68
  end
61
69
 
62
70
  info("Cache miss: #{key}")
@@ -29,7 +29,7 @@
29
29
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
30
  #++
31
31
 
32
- class Tml::Generators::Cache::Base
32
+ class Tml::Generators::Base
33
33
 
34
34
  attr_accessor :started_at, :finished_at
35
35
 
@@ -29,7 +29,7 @@
29
29
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
30
  #++
31
31
 
32
- class Tml::Generators::Cache::File < Tml::Generators::Cache::Base
32
+ class Tml::Generators::File < Tml::Generators::Base
33
33
 
34
34
  def cache_path
35
35
  @cache_path ||= begin
data/lib/tml/session.rb CHANGED
@@ -65,9 +65,7 @@ module Tml
65
65
 
66
66
  Tml.cache.reset_version
67
67
 
68
- self.application = Tml.memory.fetch(Tml::Application.cache_key) do
69
- Tml::Application.new(:host => host, :access_token => Tml::Session.access_token).fetch
70
- end
68
+ self.application = Tml::Application.new(:host => host, :access_token => Tml::Session.access_token).fetch
71
69
 
72
70
  if Tml.cache.read_only?
73
71
  self.class.access_token = self.application.access_token
data/lib/tml/version.rb CHANGED
@@ -30,5 +30,5 @@
30
30
  #++
31
31
 
32
32
  module Tml
33
- VERSION = '4.3.6'
33
+ VERSION = '4.3.7'
34
34
  end
data/lib/tml.rb CHANGED
@@ -37,13 +37,10 @@ module Tml
37
37
  module Rules end
38
38
  module Decorators end
39
39
  module CacheAdapters end
40
- module Generators
41
- module Cache
42
- end
43
- end
40
+ module Generators end
44
41
  end
45
42
 
46
- %w(tml/base.rb tml tml/api tml/rules_engine tml/tokens tml/tokenizers tml/decorators tml/cache_adapters tml/cache tml/cache/generators tml/ext tml/modules tml/generators/cache).each do |f|
43
+ %w(tml/base.rb tml tml/api tml/rules_engine tml/tokens tml/tokenizers tml/decorators tml/cache_adapters tml/cache tml/cache/generators tml/ext tml/modules tml/generators).each do |f|
47
44
  if f.index('.rb')
48
45
  require(File.expand_path(File.join(File.dirname(__FILE__), f)))
49
46
  next
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tml
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.6
4
+ version: 4.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Berkovich
@@ -56,7 +56,6 @@ files:
56
56
  - lib/tml/cache.rb
57
57
  - lib/tml/cache_adapters/file.rb
58
58
  - lib/tml/cache_adapters/memcache.rb
59
- - lib/tml/cache_adapters/memory.rb
60
59
  - lib/tml/cache_adapters/redis.rb
61
60
  - lib/tml/config.rb
62
61
  - lib/tml/decorators/base.rb
@@ -69,8 +68,8 @@ files:
69
68
  - lib/tml/ext/hash.rb
70
69
  - lib/tml/ext/string.rb
71
70
  - lib/tml/ext/time.rb
72
- - lib/tml/generators/cache/base.rb
73
- - lib/tml/generators/cache/file.rb
71
+ - lib/tml/generators/base.rb
72
+ - lib/tml/generators/file.rb
74
73
  - lib/tml/language.rb
75
74
  - lib/tml/language_case.rb
76
75
  - lib/tml/language_case_rule.rb
@@ -1,85 +0,0 @@
1
- # encoding: UTF-8
2
- #--
3
- # Copyright (c) 2015 Translation Exchange, Inc
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
- class Tml::CacheAdapters::Memory < Tml::Cache
34
-
35
- def self.cache
36
- @cache ||= {}
37
- end
38
-
39
- def self.clear_cache
40
- @cache = {}
41
- end
42
-
43
- def cache_name
44
- 'memory'
45
- end
46
-
47
- def fetch(key, opts = {})
48
- return yield if Tml.session.inline_mode?
49
- return yield unless Tml.cache.read_only?
50
-
51
- data = self.class.cache[key]
52
-
53
- if data
54
- info("Cache hit: #{key}")
55
- return data
56
- end
57
-
58
- info("Cache miss: #{key}")
59
-
60
- return nil unless block_given?
61
-
62
- data = yield
63
-
64
- store(key, data)
65
-
66
- data
67
- end
68
-
69
- def store(key, data, opts = {})
70
- self.class.cache[key] = data
71
- end
72
-
73
- def delete(key, opts = {})
74
- self.class.cache[key] = nil
75
- end
76
-
77
- def exist?(key, opts = {})
78
- not self.class.cache[key].nil?
79
- end
80
-
81
- def clear(opts = {})
82
- self.class.clear_cache
83
- end
84
-
85
- end