proc 0.1.0 → 0.1.1

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: 0f07ae5d056122c93826012896beb760372534d7c2c83193674580517ff31f86
4
- data.tar.gz: 5cd335938ec4121d5170c27518678d81c27dd3b65ff6b0235be72213e05613e2
3
+ metadata.gz: 63fefe7d8d6f97ef667ca24f07ef5f38b402c6982d783582d6ea869dbfc67c76
4
+ data.tar.gz: ceaeee3d8d634ba9d9ba6771266554e8dc7b8662b819751520658b0e657dbfa8
5
5
  SHA512:
6
- metadata.gz: '08b92c4b033fe05dea3a0db6321c5cea4ce5f8ce3587e3f1b7902b295e7778f95a433e84652f12d71f3eff0e60d2bc53d584cce308bd307e32b54f76ed3213e3'
7
- data.tar.gz: ef90d03381df7f8f016460cc83f15c14b3b1f9768dd5078588e85591e61d46df628fd63fd7e804d6d7e1975c7dd9749642f4b51ecaa5bf1e7c19896f64155d72
6
+ metadata.gz: 1c44c09c6526286bbcc8e67fefd1c2d13cb5dec65b4471452eb07c9845f36e8c2aa92dcd7c5080ff7070a2a1228b6f3667c7d9616f35e37ba7d14ec9f882ac22
7
+ data.tar.gz: a38fe68ec69ed2b086741d46728245d3351fe58ed26c956fcb9ec67257e9089b9e2e383a8551530bed293188f6e14ca9799ebaf57859163bf1b9fbd0bfb26f82
@@ -25,7 +25,7 @@ class Proc
25
25
  end
26
26
 
27
27
  def >>(other)
28
- composed = Composition.new(client: @client)
28
+ composed = Composition.new(client: @client, input: @input)
29
29
  composed << self
30
30
  composed << other
31
31
  composed
@@ -79,12 +79,12 @@ class Proc
79
79
  }.merge(DEFAULT_HEADERS)
80
80
 
81
81
  begin
82
- response = super(:post, build_uri(proc), headers: headers, body: Oj.dump(body, mode: :json), task: task)
82
+ response = super(:post, build_uri(proc), headers: headers, body: Oj.dump(body, mode: :custom), task: task)
83
83
 
84
84
  @remaining = response.headers["x-rate-limit-remaining"].to_s.to_i
85
85
  @resets_at = Time.at(response.headers["x-rate-limit-reset"].to_s.to_i)
86
86
 
87
- payload = Oj.load(response.read, mode: :strict)
87
+ payload = Oj.load(response.read, mode: :compat)
88
88
  rescue => error
89
89
  raise Proc::Unavailable, error.message
90
90
  ensure
@@ -2,9 +2,10 @@
2
2
 
3
3
  class Proc
4
4
  class Composition
5
- def initialize(client:)
5
+ def initialize(client:, input:, callables: [])
6
6
  @client = client
7
- @callables = []
7
+ @input = input
8
+ @callables = callables
8
9
  end
9
10
 
10
11
  def initialize_copy(_)
@@ -12,7 +13,11 @@ class Proc
12
13
  end
13
14
 
14
15
  def call(input = input_omitted = true, **arguments)
15
- @client.call("exec", input_omitted ? @callables.first.input : input, proc: serialize)
16
+ @client.call("exec", input_omitted ? @input : input, proc: serialized_calls)
17
+ end
18
+
19
+ def with(input = input_omitted = true)
20
+ self.class.new(client: @client, input: input_omitted ? @input : input, callables: @callables.dup)
16
21
  end
17
22
 
18
23
  def >>(other)
@@ -26,6 +31,15 @@ class Proc
26
31
  end
27
32
 
28
33
  def serialize
34
+ {
35
+ "{}" => {
36
+ "<<" => @input,
37
+ "[]" => serialized_calls
38
+ }
39
+ }
40
+ end
41
+
42
+ def serialized_calls
29
43
  @callables.map { |callable|
30
44
  [callable.proc, callable.serialized_arguments]
31
45
  }
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Proc
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
 
6
6
  def self.version
7
7
  VERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Powell