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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e3ecccd71c5367524c82782ce1ddac70fe326f39f2357704be8ef59b27e5943
4
- data.tar.gz: 2fb39abc81ee407414b47f2043968ec58d5fa42593d8137e5de861ce6d8d04ef
3
+ metadata.gz: a6861b1ab065bdf7cd09eba47888a353164d0b9ab9d114204908e73b0b4bc6e7
4
+ data.tar.gz: 4f283da493a1fc04ee9788e88e40ca61fe164c3d05cdff2417ff402afe29e18b
5
5
  SHA512:
6
- metadata.gz: 10982d75255d69580a46657c3dda18410bbfc1a86d8fe163cb43950a6f5ce3675ece13f7980116a806f95c8e73aaf4a32946f5715568a805153acda1e54a7731
7
- data.tar.gz: abeda91adc7daa9a1febbcb9998f2bbed1c0e97acd1a06a79c3de8c163c71bb7b89b875a967386a1fe75955a886a22539ff0c81ac761d50ccd684ee4b1f1598f
6
+ metadata.gz: 824835258a3b4837e8bdf9615e63efab5ea4ae3670daecb4e85f594ed65b16f7250199b21e9cda0b1566bf872b8c33d6fa29f081f11058b3948ad42b98ba8a03
7
+ data.tar.gz: 13606e6d3791edbae8cb345f7a73efc9de3c66572fa1416b682ed221334e10369a6a9c5528938464032a96400e83cc788d0ee3dafa4521bd9b476acced09cfdd
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- http_store (0.3.21)
4
+ http_store (0.3.22)
5
5
  activerecord (>= 5.0, < 6.1)
6
6
  hashie (~> 3.0)
7
7
  rails (>= 5, < 7)
@@ -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
- p @storeable_record.response.class
33
- p @storeable_record.response.encoding.name
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
- [k, storable_v]
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) }
@@ -1,3 +1,3 @@
1
1
  module HttpStore
2
- VERSION = "0.3.21"
2
+ VERSION = "0.3.22"
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.21
4
+ version: 0.3.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - black