proc 0.8.1 → 0.9.0

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: e066afa0667795307f8627a3220f8bc3887c644b2679a45b9e044d7843ca4ed3
4
- data.tar.gz: a5775e58b9a2c7730242b9971d44f1d31d02eca4b5e6bc36ee2e5a712dc63537
3
+ metadata.gz: 46f47f39b1b2b4f495b59575a14f1d8df1d837eada9048562ed5455a3d0fbc06
4
+ data.tar.gz: e93f11f26736d3504fc4e025be2fece6e9dafad9e66d6fac4c2d362470d3b207
5
5
  SHA512:
6
- metadata.gz: 1c41c56fdfb839226790e7ad63c2fce4724b25b8fd61d79ac47adf2f4e9e9e673dea272a1ebc3e9ee1c1960a71a31a048f133efcc6544fcab92759716b7605bf
7
- data.tar.gz: 1c72579ebf19b7ac9a8f85641a4ced7637829e44f3259242d0cec76ced0daaac4180a1334d1711784c459bf9e21f0cecddda67b11fd08742fb63427188c184f4
6
+ metadata.gz: c82d1cb2697caf43077d2e1a909602401cb7bf8a8518be6f21d5160a38889d49aceb93d1d578c124ca8077dec21aa7e6b5fdec31ebb5e4137e64ab278e58e124
7
+ data.tar.gz: ca6f582486efebd0817b30228e997da049c482e7c5b42f08b52128e76534d3da19080aa995e0124d15e011677f5af066c0310a7a67671788cf44cffc040e62d5
data/lib/proc.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "proc/client"
4
+ require_relative "proc/version"
4
5
 
5
6
  class Proc
6
7
  def self.connect(authorization, **options)
data/lib/proc/client.rb CHANGED
@@ -1,7 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "async"
4
- require "oj"
4
+ require "msgpack"
5
+
6
+ require_relative "msgpack/types/decimal"
7
+ MessagePack::DefaultFactory.register_type(0x00, Proc::Msgpack::Types::Decimal)
8
+ MessagePack::DefaultFactory.register_type(-1, Time, packer: MessagePack::Time::Packer, unpacker: MessagePack::Time::Unpacker)
5
9
 
6
10
  require_relative "argument"
7
11
  require_relative "callable"
@@ -12,13 +16,6 @@ require_relative "http/client"
12
16
 
13
17
  Console.logger.off!
14
18
 
15
- Oj.default_options = {
16
- mode: :custom,
17
- bigdecimal_load: :auto,
18
- float_precision: 0,
19
- second_precision: 6
20
- }.freeze
21
-
22
19
  class Proc
23
20
  class Error < StandardError
24
21
  end
@@ -75,8 +72,8 @@ class Proc
75
72
  end
76
73
 
77
74
  DEFAULT_HEADERS = {
78
- "accept" => "application/vnd.proc+json",
79
- "content-type" => "application/vnd.proc+json"
75
+ "accept" => "application/vnd.proc+msgpack",
76
+ "content-type" => "application/vnd.proc+msgpack"
80
77
  }.freeze
81
78
 
82
79
  def call(proc = nil, input = Proc.undefined, **arguments, &block)
@@ -177,10 +174,10 @@ class Proc
177
174
  end
178
175
 
179
176
  private def get_payload(proc:, headers:, body:)
180
- @internal.call(:post, build_uri(proc), headers: headers, body: Oj.dump(body)) do |response|
177
+ @internal.call(:post, build_uri(proc), headers: headers, body: MessagePack.pack(body)) do |response|
181
178
  @remaining = response.headers["x-rate-limit-remaining"].to_s.to_i
182
179
  @resets_at = Time.at(response.headers["x-rate-limit-reset"].to_s.to_i)
183
- [response.status, response.headers, Oj.load(response.read)]
180
+ [response.status, response.headers, MessagePack.unpack(response.read)]
184
181
  end
185
182
  rescue
186
183
  raise Proc::Unavailable
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ class BigDecimal
4
+ def to_msgpack(packer)
5
+ if precision > 16
6
+ packer.write(Proc::Msgpack::Types::Decimal.new(self))
7
+ packer
8
+ else
9
+ to_f.to_msgpack(packer)
10
+ end
11
+ end
12
+ end
13
+
14
+ class Proc
15
+ module Msgpack
16
+ module Types
17
+ class Decimal
18
+ class << self
19
+ def from_msgpack_ext(data)
20
+ BigDecimal(data)
21
+ end
22
+ end
23
+
24
+ def initialize(value)
25
+ @value = value
26
+ end
27
+
28
+ def to_msgpack_ext
29
+ @value.to_s
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
data/lib/proc/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Proc
4
- VERSION = "0.8.1"
4
+ VERSION = "0.9.0"
5
5
 
6
6
  def self.version
7
7
  VERSION
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Powell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-02 00:00:00.000000000 Z
11
+ date: 2021-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-http
@@ -39,19 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.1.0
41
41
  - !ruby/object:Gem::Dependency
42
- name: oj
42
+ name: msgpack
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.11'
47
+ version: '1.4'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.11'
54
+ version: '1.4'
55
55
  description: Proc client library.
56
56
  email: bryan@metabahn.com
57
57
  executables: []
@@ -69,6 +69,7 @@ files:
69
69
  - lib/proc/http/client.rb
70
70
  - lib/proc/http/request.rb
71
71
  - lib/proc/http/response.rb
72
+ - lib/proc/msgpack/types/decimal.rb
72
73
  - lib/proc/version.rb
73
74
  homepage: https://proc.dev/
74
75
  licenses: