http_store 0.3.15 → 0.3.16

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
  SHA256:
3
- metadata.gz: ab2f3e80f1c8a6d5ffce3c6393ee4ec304986deb01396b5462f1d485191acd41
4
- data.tar.gz: cbff2df0c9d9c0fc84fd197de25ef7ed597425b45f754a8a8dfbaa0a35dce1c1
3
+ metadata.gz: 65a49997a9d1583a1ea4d2b2e9e4eb133afe174a6c1db1b301f756897e33ab38
4
+ data.tar.gz: 8dd16df5450d657e0c82b65e34a18b19360dcbe4cc8a5f1e4a500077b71487d6
5
5
  SHA512:
6
- metadata.gz: 252015a8e3e4d7bfc4bc5cb7602f9171d00e00c1b19296f2571e94c4c04344c13b5052bd90c0c83d9218f6893b7053c6d68e3839f47301ffd02687e72e336bcf
7
- data.tar.gz: 567b619a91c16a60d38da313e37d43f603a50018c221e88ff48e2b23cbd9bbe82afc36e1e45a3a2fb29a96905a4a29cf4c1562c6e41a7e9f902e7de388ae548a
6
+ metadata.gz: 398000288fe794bba74b4d0b6c9ef6c83ca44278dd895f43afc88293909365a17c5cb3cef058491a7ac3d0430b19760223558dbed5924b690f42878b45935e81
7
+ data.tar.gz: aa3cce3e5505bb6714d639e2f7062c6f514bfef1d1a1fd1640e925c125daa0127bb5243b5b79714e3952963fc39f443fa2c733cc58326ffba626dd430a8d9d0a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- http_store (0.3.15)
4
+ http_store (0.3.16)
5
5
  activerecord (>= 5.0, < 6.1)
6
6
  hashie (~> 3.0)
7
7
  rails (>= 5, < 7)
@@ -36,7 +36,10 @@ module HttpStore
36
36
 
37
37
  def gen_storable_meta
38
38
  @meta.slice(*HttpStore::STORE_KEYS).map do |k, v|
39
- [k, v.is_a?(Hash) || v.is_a?(Array) ? storable(v).to_json[0..STRING_LIMIT_SIZE] : v]
39
+ storable_v = storable(v)
40
+ storable_v = storable_v.to_json[0..STRING_LIMIT_SIZE] if v.is_a?(Hash) || v.is_a?(Array)
41
+
42
+ [k, storable_v]
40
43
  end.to_h
41
44
  end
42
45
 
@@ -50,12 +53,16 @@ module HttpStore
50
53
  json = JSON.parse(value) rescue nil
51
54
  json ? storable(json) : storable_string(value)
52
55
  else
53
- value.try(:to_h) || value.try(:to_a) || value
56
+ value
54
57
  end
55
58
  end
56
59
 
57
60
  def storable_string(str)
58
- str.length > STRING_LIMIT_SIZE ? { digest: Digest::SHA1.hexdigest(str), origin: str[0..1000] } : str
61
+ if str.encoding.name == "UTF-8"
62
+ str.length > STRING_LIMIT_SIZE ? { digest: Digest::SHA1.hexdigest(str), origin: str[0..1000] } : str
63
+ else
64
+ { digest: Digest::SHA1.hexdigest(str) }
65
+ end
59
66
  end
60
67
 
61
68
  def json_safe_parse(str)
@@ -1,3 +1,3 @@
1
1
  module HttpStore
2
- VERSION = "0.3.15"
2
+ VERSION = "0.3.16"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.15
4
+ version: 0.3.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - black