tapyrus 0.3.7 → 0.3.8

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: 43313f996603ba95e2306d93b11ef457ce4a5547c90bb95cb691475c5870dc99
4
- data.tar.gz: 42db7fbe7c7349d0b59adda23521b778eb34fffbe4550de9ed90b32138300f05
3
+ metadata.gz: a3e914b632a65116abe3a180a3c2837c53bbf2ad54a7a1fa63bc9839dcd0a814
4
+ data.tar.gz: 8dcd409c60614775393251b3df42bb7757946fb3437b52df8d7fef88f13c9521
5
5
  SHA512:
6
- metadata.gz: c5eed2bd64fb3bb1f3a33458f6721ca270a29f63ddf1f73fe218ed78e8c8f1bddbe38457746b9771222170334e86ae6ce1218f19d076e53cebda7a3c89e7b4b9
7
- data.tar.gz: ceaf0750458c313f0e051524a1371d4bee6ca6b9a963e5512c0cec1f22c1526b9b846a54da9b112e9c7c0196cc2689a9a4bbf15b4ce03af2402d8f900a021bd1
6
+ metadata.gz: 4af0a5669afac3545347166f4c1bba763a1401aa0cd3176f60169427324c96c4d88e5c5938e33d319fc052e54e099cdee3af7624ddd243f94d3349ca1feb0fcb
7
+ data.tar.gz: 9be8065204ee310ddea4d3a5722f401a8d5aacb527624ee0f7693dbfa37bdd2126ace5541f1c94f9f428a227137264fcd405c79332997ecd526564c8530a7115
data/lib/tapyrus/ext.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  module Tapyrus
2
2
  module Ext
3
- autoload :JsonParser, "tapyrus/ext/json_parser"
4
-
5
3
  refine Object do
6
4
  def build_json
7
5
  self.is_a?(Array) ? "[#{self.map { |o| o.to_h.to_json }.join(",")}]" : to_h.to_json
@@ -1,5 +1,4 @@
1
1
  require "net/http"
2
- require "json/pure"
3
2
 
4
3
  module Tapyrus
5
4
  module RPC
@@ -115,13 +114,30 @@ module Tapyrus
115
114
  end
116
115
 
117
116
  def response_body2json(body)
118
- Tapyrus::Ext::JsonParser.new(
119
- body.gsub(/\\u([\da-fA-F]{4})/) do
120
- [$1].pack("H*").unpack("n*").pack("U*").encode("ISO-8859-1").force_encoding("UTF-8")
121
- end
122
- ).parse
117
+ json_data =
118
+ JSON.parse(
119
+ body.gsub(/\\u([\da-fA-F]{4})/) do
120
+ [$1].pack("H*").unpack("n*").pack("U*").encode("ISO-8859-1").force_encoding("UTF-8")
121
+ end
122
+ )
123
+ convert_floats_to_strings(json_data)
124
+ end
125
+
126
+ # Convert float value
127
+ def convert_floats_to_strings(obj)
128
+ case obj
129
+ when Float
130
+ obj.to_s
131
+ when Hash
132
+ obj.transform_values { |v| convert_floats_to_strings(v) }
133
+ when Array
134
+ obj.map { |item| convert_floats_to_strings(item) }
135
+ else
136
+ obj
137
+ end
123
138
  end
124
139
 
125
140
  module_function :response_body2json
141
+ module_function :convert_floats_to_strings
126
142
  end
127
143
  end
@@ -1,3 +1,3 @@
1
1
  module Tapyrus
2
- VERSION = "0.3.7"
2
+ VERSION = "0.3.8"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tapyrus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - azuchi
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-01-31 00:00:00.000000000 Z
10
+ date: 2025-03-17 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: ecdsa
@@ -370,7 +370,6 @@ files:
370
370
  - lib/tapyrus/errors.rb
371
371
  - lib/tapyrus/ext.rb
372
372
  - lib/tapyrus/ext/ecdsa.rb
373
- - lib/tapyrus/ext/json_parser.rb
374
373
  - lib/tapyrus/ext_key.rb
375
374
  - lib/tapyrus/jws.rb
376
375
  - lib/tapyrus/key.rb
@@ -491,7 +490,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
491
490
  - !ruby/object:Gem::Version
492
491
  version: '0'
493
492
  requirements: []
494
- rubygems_version: 3.6.2
493
+ rubygems_version: 3.6.3
495
494
  specification_version: 4
496
495
  summary: The implementation of Tapyrus Protocol for Ruby.
497
496
  test_files: []
@@ -1,44 +0,0 @@
1
- require "json/pure"
2
-
3
- module Tapyrus
4
- module Ext
5
- # Extension of JSON::Pure::Parser.
6
- # This class convert Float value to String value.
7
- class JsonParser < JSON::Pure::Parser
8
- def parse_value
9
- case
10
- when scan(FLOAT)
11
- self[1].to_s
12
- when scan(INTEGER)
13
- Integer(self[1])
14
- when scan(TRUE)
15
- true
16
- when scan(FALSE)
17
- false
18
- when scan(NULL)
19
- nil
20
- when !UNPARSED.equal?(string = parse_string)
21
- string
22
- when scan(ARRAY_OPEN)
23
- @current_nesting += 1
24
- ary = parse_array
25
- @current_nesting -= 1
26
- ary
27
- when scan(OBJECT_OPEN)
28
- @current_nesting += 1
29
- obj = parse_object
30
- @current_nesting -= 1
31
- obj
32
- when @allow_nan && scan(NAN)
33
- NaN
34
- when @allow_nan && scan(INFINITY)
35
- Infinity
36
- when @allow_nan && scan(MINUS_INFINITY)
37
- MinusInfinity
38
- else
39
- UNPARSED
40
- end
41
- end
42
- end
43
- end
44
- end