readthis 2.0.1 → 2.0.2

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: 700f5ebcb3e2678df42015c78f8551dea7701b69
4
- data.tar.gz: ba0cecc09026672821eec2456b27ad25eaab96e6
3
+ metadata.gz: 96757292ab53002644528d813c7100a0f9162cbe
4
+ data.tar.gz: cd567c4a99b251982d9ecd23abeb328a40574531
5
5
  SHA512:
6
- metadata.gz: c63dd6dacbee0a89a929adae2aa8ca6235685a88ad609933bddbf1fc8920b4c56296a7644e117e969068706e8baa6871f65c2b49c15d3c29135afb0e5e7f4949
7
- data.tar.gz: b27ed96ac4a660322f908da4680d2e463042343e7131ba2b6bfa65bce7bc050b0d7c533be28170f644e521eb44feeef952f7a1cedbc1fce9ec70d5ebd158e63a
6
+ metadata.gz: ea89804bbc66cc15c8c3f605b9c918624ee9a5e1a64da125c81b6ae6e6964a906374c564a931a2fa41ccc86463f6084e55a28f88c514bf56f8aa81f534fb4985
7
+ data.tar.gz: eda30ec91065ccb9dfb5ef3e47a79b7eac16fdc6896674793dee7f95beac5d6ba32fef8d1d7c28e70f96ef8f050236c43678b6fc3ca5afabf84e8fb9cb220b83
@@ -389,8 +389,8 @@ module Readthis
389
389
  end
390
390
 
391
391
  def write_entity(key, value, store, options)
392
- namespaced = namespaced_key(key, options)
393
- dumped = entity.dump(value, options)
392
+ namespaced = encode(namespaced_key(key, options))
393
+ dumped = encode(entity.dump(value, options))
394
394
 
395
395
  if (expiration = options[:expires_in])
396
396
  store.setex(namespaced, coerce_expiration(expiration), dumped)
@@ -411,6 +411,12 @@ module Readthis
411
411
  Float(expires_in).ceil
412
412
  end
413
413
 
414
+ def encode(string)
415
+ string = string.frozen? ? string.dup : string
416
+
417
+ string.force_encoding(Encoding::BINARY)
418
+ end
419
+
414
420
  def instrument(name, key)
415
421
  if self.class.notifications
416
422
  name = "cache_#{name}.active_support"
@@ -14,7 +14,7 @@ module Readthis
14
14
  when key.respond_to?(:to_param)
15
15
  key.to_param
16
16
  else
17
- key
17
+ key.to_s
18
18
  end
19
19
  end
20
20
 
@@ -1,3 +1,3 @@
1
1
  module Readthis
2
- VERSION = '2.0.1'.freeze
2
+ VERSION = '2.0.2'.freeze
3
3
  end
@@ -76,6 +76,12 @@ RSpec.describe Readthis::Cache do
76
76
 
77
77
  expect(cache.read('custom')).to eq('some-value')
78
78
  end
79
+
80
+ it 'stores russian symbols by russian key' do
81
+ cache.write('вгдмн', 'вгдмн')
82
+
83
+ expect(cache.read('вгдмн')).to eq('вгдмн')
84
+ end
79
85
  end
80
86
 
81
87
  describe '#read' do
@@ -32,5 +32,9 @@ RSpec.describe Readthis::Expanders do
32
32
 
33
33
  expect(expand(object)).to eq('thing')
34
34
  end
35
+
36
+ it 'ensures the result is a string' do
37
+ expect(expand(123)).to eq('123')
38
+ end
35
39
  end
36
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: readthis
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Parker Selbert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-27 00:00:00.000000000 Z
11
+ date: 2016-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis