http_store 0.3.21 → 0.3.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/http_store/helpers/storable.rb +10 -12
- data/lib/http_store/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6861b1ab065bdf7cd09eba47888a353164d0b9ab9d114204908e73b0b4bc6e7
|
4
|
+
data.tar.gz: 4f283da493a1fc04ee9788e88e40ca61fe164c3d05cdff2417ff402afe29e18b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 824835258a3b4837e8bdf9615e63efab5ea4ae3670daecb4e85f594ed65b16f7250199b21e9cda0b1566bf872b8c33d6fa29f081f11058b3948ad42b98ba8a03
|
7
|
+
data.tar.gz: 13606e6d3791edbae8cb345f7a73efc9de3c66572fa1416b682ed221334e10369a6a9c5528938464032a96400e83cc788d0ee3dafa4521bd9b476acced09cfdd
|
data/Gemfile.lock
CHANGED
@@ -28,10 +28,9 @@ module HttpStore
|
|
28
28
|
@meta.parent_id = storeable_record.id if use_cache?
|
29
29
|
@storeable_record = HttpStore.config.store_class.new(gen_storable_meta)
|
30
30
|
@storeable_record.save!
|
31
|
-
rescue
|
32
|
-
|
33
|
-
|
34
|
-
p 'zzzz' * 200
|
31
|
+
rescue ActiveRecord::StatementInvalid
|
32
|
+
@storeable_record.response = Digest::SHA1.hexdigest(@storeable_record.response)
|
33
|
+
@storeable_record.save!
|
35
34
|
end
|
36
35
|
|
37
36
|
def use_cache?
|
@@ -41,9 +40,14 @@ module HttpStore
|
|
41
40
|
def gen_storable_meta
|
42
41
|
@meta.slice(*HttpStore::STORE_KEYS).map do |k, v|
|
43
42
|
storable_v = storable(v)
|
44
|
-
storable_v = storable_v.to_json[0..STRING_LIMIT_SIZE] if v.is_a?(Hash) || v.is_a?(Array)
|
45
43
|
|
46
|
-
|
44
|
+
begin
|
45
|
+
storable_v = storable_v.to_json[0..STRING_LIMIT_SIZE] if v.is_a?(Hash) || v.is_a?(Array)
|
46
|
+
|
47
|
+
[k, storable_v]
|
48
|
+
rescue JSON::GeneratorError
|
49
|
+
[k, storable_v.to_s[0..STRING_LIMIT_SIZE]]
|
50
|
+
end
|
47
51
|
end.to_h
|
48
52
|
end
|
49
53
|
|
@@ -64,15 +68,9 @@ module HttpStore
|
|
64
68
|
end
|
65
69
|
|
66
70
|
def storable_string(str)
|
67
|
-
p str.encoding.name
|
68
|
-
p 'xxx' * 200
|
69
|
-
|
70
71
|
str = str.clone.encode('UTF-8')
|
71
72
|
raise EncodingError unless str.encoding.name == 'UTF-8'
|
72
73
|
|
73
|
-
p str.encoding.name
|
74
|
-
p 'yyyy' * 200
|
75
|
-
|
76
74
|
str.length > STRING_LIMIT_SIZE ? { digest: Digest::SHA1.hexdigest(str), origin: str[0..1000] } : str
|
77
75
|
rescue EncodingError
|
78
76
|
{ digest: Digest::SHA1.hexdigest(str) }
|
data/lib/http_store/version.rb
CHANGED