tml 5.7.5 → 5.7.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f22472b3451faaa34531f1a366b002b3c0fcb6836a6511f249428bd696b3f913
4
- data.tar.gz: d0b282b91dc07cc90aa1542daa363d643aecb1ecef8ee50e982c02a819a96844
3
+ metadata.gz: 5b283d0f1375ff5f0609d372a147b301c6c1e900e29e5dbdd13e930c5a6bc69f
4
+ data.tar.gz: 11c154e67d9dcfb337839abecc69ba98fe55746851b8be45aaf0908901a7e606
5
5
  SHA512:
6
- metadata.gz: 5a7ac88acae16bf896ec80bd9b05e45843fb0975f6ba3ed8d6d7f525916930ab7efbf28cc0541413bdab9d230bff15a44357debbc32efee00cce6149b5be3050
7
- data.tar.gz: 4a5880962f6c461cafcb7c9f88343632db6eba4c870c048763e2b8277f6f8a7af3b62e83801bb6760f22bb8ccd13cc947304b7dca9b06716ff326c4e54aa0ce4
6
+ metadata.gz: '03965562121f10a108a594cd59368960c9ecb091b38b1bf95dd187ef58f7ae26d60cfcd73d02dd45ff76753c08eb41db3c53ccfa12671f3787df621358b5fa4b'
7
+ data.tar.gz: 9efdb8e5fefc0074477a054170d6127d5830e4700114909700f441d9c974276c08c0a568eb53d2162acdd7a8adabc4653e0aa792d1669a470464a53b3afe503f
data/README.md CHANGED
@@ -8,6 +8,7 @@ TML Library For Ruby
8
8
  [![Coverage Status](https://coveralls.io/repos/translationexchange/tml-ruby/badge.png?branch=master)](https://coveralls.io/r/translationexchange/tml-ruby?branch=master)
9
9
  [![Dependency Status](https://www.versioneye.com/user/projects/54c1457a6c00352081000416/badge.svg?style=flat)](https://www.versioneye.com/user/projects/54c1457a6c00352081000416)
10
10
  [![Gem Version](https://badge.fury.io/rb/tml.svg)](http://badge.fury.io/rb/tml)
11
+ [![Open Source Helpers](https://www.codetriage.com/translationexchange/tml-ruby/badges/users.svg)](https://www.codetriage.com/translationexchange/tml-ruby)
11
12
 
12
13
  TML library for Ruby is a set of classes that provide translation functionality for any Ruby based application.
13
14
  The library uses Translation Markup Language that allows you to encode complex language structures in simple, yet powerful forms.
@@ -110,9 +110,29 @@ class Tml::Api::Client < Tml::Base
110
110
  Tml.logger.info("Cache Version: #{Tml.cache.version}")
111
111
  end
112
112
 
113
+ def cdn_host
114
+ @cdn_host ||= URI.join(application.cdn_host, '/').to_s
115
+ end
116
+
117
+ def get_cdn_path(key, opts = {})
118
+ base_path = URI(application.cdn_host).path
119
+ base_path += '/' unless base_path.last == '/'
120
+
121
+ adjusted_path = "#{base_path}#{application.key}/"
122
+
123
+ if key == 'version'
124
+ adjusted_path += "#{key}.json"
125
+ else
126
+ adjusted_path += "#{Tml.cache.version.to_s}/#{key}.json#{opts[:uncompressed] ? '' : '.gz'}"
127
+ end
128
+
129
+ pp adjusted_path
130
+ adjusted_path
131
+ end
132
+
113
133
  # cdn_connection
114
134
  def cdn_connection
115
- @cdn_connection ||= Faraday.new(:url => application.cdn_host) do |faraday|
135
+ @cdn_connection ||= Faraday.new(:url => cdn_host) do |faraday|
116
136
  faraday.request(:url_encoded) # form-encode POST params
117
137
  faraday.adapter(Faraday.default_adapter) # make requests with Net::HTTP
118
138
  end
@@ -125,20 +145,14 @@ class Tml::Api::Client < Tml::Base
125
145
  end
126
146
 
127
147
  response = nil
128
- cdn_path = "/#{application.key}"
129
-
130
- if key == 'version'
131
- cdn_path += "/#{key}.json"
132
- else
133
- cdn_path += "/#{Tml.cache.version.to_s}/#{key}.json#{opts[:uncompressed] ? '' : '.gz'}"
134
- end
148
+ cdn_path = get_cdn_path(key, opts)
135
149
 
136
150
  trace_api_call(cdn_path, params, opts.merge(:host => application.cdn_host)) do
137
151
  begin
138
152
  response = cdn_connection.get do |request|
139
153
  prepare_request(request, cdn_path, params, opts)
140
154
  end
141
- rescue Exception => ex
155
+ rescue => ex
142
156
  Tml.logger.error("Failed to execute request: #{ex.message[0..255]}")
143
157
  return nil
144
158
  end
@@ -31,7 +31,7 @@
31
31
  #++
32
32
 
33
33
  module Tml
34
- VERSION = '5.7.5'
34
+ VERSION = '5.7.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.7.5
4
+ version: 5.7.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: 2017-11-28 00:00:00.000000000 Z
11
+ date: 2018-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday