tr8n_client_sdk 3.2.3 → 3.2.4

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: b1f8b6538d43509ecfd11b6153371c54e153eca5
4
- data.tar.gz: 32beb12f88d7dd8b16ea9e66dbb4f882f1d5b9f1
3
+ metadata.gz: a430fd6d3363d71807fa76e4714576232ab7e700
4
+ data.tar.gz: c8cde0b647c66310f119bb533deb7aa375549651
5
5
  SHA512:
6
- metadata.gz: aadb32a0a3610db0859c5cb049dba6b1d3844986ec5985f789dba37f8c68bd28e811f8d1315860bb4f478ae939e502288ad406a5fbe2c69eb1a1c3bcb5a8966a
7
- data.tar.gz: 4af105edf554a27952a0079545b020aa2544716a3ac948dbbe5a05e2197fbd740e1b2ceacf5b0fa2916df3c513b1cc9ec55c977c5bbe62724bb2c5c82eed7912
6
+ metadata.gz: b4764c1074158103a77c61f2a8d157fd5a12a53e80b86446b98d0b7d5ef96dd864f3e9e60dd2ebb969c1b3d6f8a06a4a5713ab59a3a055fbfd614d03b8727951
7
+ data.tar.gz: e0dd79cbf38762b3d20500c142c6a5ac71133f992aecd6fec02bb37bc12fc0f69e0646b9014013d5e56d54d923c5b58fccf93fcc766669005c1566d4c12b0701
@@ -25,11 +25,11 @@
25
25
  </script>
26
26
  <select id="tr8n_language_selector" onchange="tr8n_change_locale(this)" style="<%=opts[:style]%>" class="<%=opts[:class]%>">
27
27
  <% tr8n_application.languages.each do |lang| %>
28
- <option value="<%=lang.locale%>" <%="selected" if lang.locale == tr8n_current_locale %>>
28
+ <option dir='ltr' value="<%=lang.locale%>" <%="selected" if lang.locale == tr8n_current_locale %>>
29
29
  <% if opts[:language] == :native %>
30
30
  <%= lang.native_name %>
31
31
  <% elsif opts[:language] == :english %>
32
- <%= lang.english_name %>
32
+ <%= lang.english_name %>
33
33
  <% else %>
34
34
  <%= lang.name %>
35
35
  <% end %>
@@ -0,0 +1,100 @@
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 'dalli' if defined?(Dalli)
34
+
35
+ class Tr8n::CacheAdapters::Rails < Tr8n::Cache
36
+
37
+ def initialize
38
+ Tr8n.logger.info("Initializing Rails cache...")
39
+ @cache = Rails.cache
40
+ end
41
+
42
+ def cache_name
43
+ @cache.class.name
44
+ end
45
+
46
+ def read_only?
47
+ false
48
+ end
49
+
50
+ def fetch(key, opts = {})
51
+ miss = false
52
+ data = @cache.fetch(versioned_key(key, opts)) do
53
+ info("Cache miss: #{key}")
54
+ miss = true
55
+ if block_given?
56
+ yield
57
+ else
58
+ nil
59
+ end
60
+ end
61
+ info("Cache hit: #{key}") unless miss
62
+ data
63
+ rescue Exception => ex
64
+ warn("Failed to retrieve data: #{ex.message}")
65
+ return nil unless block_given?
66
+ yield
67
+ end
68
+
69
+ def store(key, data, opts = {})
70
+ info("Cache store: #{key}")
71
+ @cache.write(versioned_key(key, opts), data)
72
+ data
73
+ rescue Exception => ex
74
+ warn("Failed to store data: #{ex.message}")
75
+ key
76
+ end
77
+
78
+ def delete(key, opts = {})
79
+ info("Cache delete: #{key}")
80
+ @cache.delete(versioned_key(key, opts))
81
+ key
82
+ rescue Exception => ex
83
+ warn("Failed to delete data: #{ex.message}")
84
+ key
85
+ end
86
+
87
+ def exist?(key, opts = {})
88
+ data = @cache.fetch(versioned_key(key, opts))
89
+ not data.nil?
90
+ rescue Exception => ex
91
+ warn("Failed to check if key exists: #{ex.message}")
92
+ false
93
+ end
94
+
95
+ def clear(opts = {})
96
+ info("Cache clear")
97
+ rescue Exception => ex
98
+ warn("Failed to clear cache: #{ex.message}")
99
+ end
100
+ end
@@ -24,6 +24,7 @@
24
24
  require "tr8n_client_sdk/railtie"
25
25
  require "tr8n_client_sdk/engine"
26
26
  require "tr8n_core"
27
+ require "tr8n/cache_adapters/rails"
27
28
 
28
29
  module Tr8nClientSdk
29
30
 
@@ -22,5 +22,5 @@
22
22
  #++
23
23
 
24
24
  module Tr8nClientSdk
25
- VERSION = "3.2.3"
25
+ VERSION = '3.2.4'
26
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tr8n_client_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.3
4
+ version: 3.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Berkovich
@@ -54,6 +54,7 @@ files:
54
54
  - app/views/tr8n_client_sdk/tags/_scripts.html.erb
55
55
  - config/routes.rb
56
56
  - lib/tasks/tr8n_client_sdk.rake
57
+ - lib/tr8n/cache_adapters/rails.rb
57
58
  - lib/tr8n_client_sdk.rb
58
59
  - lib/tr8n_client_sdk/engine.rb
59
60
  - lib/tr8n_client_sdk/extensions/action_common_methods.rb