proc 0.14.0 → 0.15.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: 4fd5089ba0458dc13c198de1322bfc510a54157ef0ec49f957efa730b6de768e
4
- data.tar.gz: d4c05363b54d8ae4607890b9ab552eb9ba3fc486c39251dcaac028aee29e21b7
3
+ metadata.gz: 9c4e2f8e75f833c305540a05b7a5fb4b401f954296a68e8bd06dabf89be7042d
4
+ data.tar.gz: d254fb835c6d38bae8a7d5c2232f50cd05387ba7324280d1ba3c1761dec4525f
5
5
  SHA512:
6
- metadata.gz: 11793b5496575f947eb481b53732310b47d6a5fa5601e0826cc2dcc5f79fec498712abeaf14c9be82c683da519e1b9c785b7265e8d1f86e0027178aae6a606f6
7
- data.tar.gz: c24ea2e3ef4337788c13cd53b373815e621c2cac9b504015672206c7e57dc7f9cef18b4deb94563eab0f4c9a536802f693687433b5cb21cb98222c2ced48b7db
6
+ metadata.gz: 022c5d8baf6791533e5d5407831a512e922f0013df71da6f35b4595f5c9ee6fc4a85cb01e909a9c9d9c2113a50be0a5818fe8a81ab3169d74fb2a0230b41912e
7
+ data.tar.gz: 41656a469f4b6505578ff2ecc0da00b77f3178904d8167964e4bdb6adbdcc9346230b9b9a1e1501be649993e7e475437a6727f83d4e1786d75fafb7036798f29
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [v0.15.0](https://github.com/metabahn/proc/releases/tag/2022-01-13)
2
+
3
+ *released on 2022-01-13*
4
+
5
+ * `dep` [#22](https://github.com/metabahn/proc/pull/22) Update dependencies ([bryanp](https://github.com/bryanp))
6
+ * `chg` [#20](https://github.com/metabahn/proc/pull/20) Rename client `request_count` to `count` ([bryanp](https://github.com/bryanp))
7
+ * `chg` [#16](https://github.com/metabahn/proc/pull/16) Update Ruby client to use proc.run ([bryanp](https://github.com/bryanp))
8
+
1
9
  ## [v0.14.0](https://github.com/metabahn/proc/releases/tag/2021-09-22)
2
10
 
3
11
  *released on 2021-09-22*
data/lib/proc/callable.rb CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  class Proc
4
4
  class Callable < Composer::Callable
5
+ inspects :@client
6
+
5
7
  def initialize(proc, client:, **kwargs)
6
8
  @client = client
7
9
 
data/lib/proc/client.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "core/async"
4
4
  require "core/global"
5
+ require "core/inspect"
5
6
 
6
7
  require "http"
7
8
  require "msgpack"
@@ -76,6 +77,8 @@ class Proc
76
77
 
77
78
  include ::Is::Async
78
79
  include ::Is::Global
80
+ include ::Is::Inspectable
81
+ inspects :@scheme, :@host, ::Core::Inspect::Inspection.new(name: :@authorization, resolver: :safe_authorization), :@count
79
82
 
80
83
  # [public] The configured authorization.
81
84
  #
@@ -91,7 +94,7 @@ class Proc
91
94
 
92
95
  # [public] The number of requests this client has performed.
93
96
  #
94
- attr_reader :request_count
97
+ attr_reader :count
95
98
 
96
99
  attr_reader :response
97
100
 
@@ -100,11 +103,11 @@ class Proc
100
103
  "content-type" => "application/vnd.proc+msgpack"
101
104
  }.freeze
102
105
 
103
- def initialize(authorization = ::Proc::Client.authorization, scheme: "https", host: "api.proc.dev")
106
+ def initialize(authorization = ::Proc::Client.authorization, scheme: "https", host: "proc.run")
104
107
  @authorization = authorization
105
108
  @scheme = scheme
106
109
  @host = host
107
- @request_count = 0
110
+ @count = 0
108
111
 
109
112
  @__base_url = "#{@scheme}://#{host}"
110
113
  @__headers = {
@@ -217,10 +220,31 @@ class Proc
217
220
  end
218
221
  end
219
222
 
223
+ IGNORE_MISSING = %i[
224
+ ].freeze
225
+
226
+ KERNEL_DELEGATE = %i[
227
+ class
228
+ instance_variables
229
+ instance_variable_get
230
+ instance_variable_set
231
+ object_id
232
+ public_send
233
+ respond_to?
234
+ ].freeze
235
+
220
236
  # [public] Allows callable contexts to be built through method lookups.
221
237
  #
222
- def method_missing(name, input = input_omitted = true, *, **arguments)
223
- if input_omitted
238
+ def method_missing(name, input = input_omitted = true, *parameters, **arguments, &block)
239
+ if IGNORE_MISSING.include?(name)
240
+ super
241
+ elsif KERNEL_DELEGATE.include?(name)
242
+ if input_omitted
243
+ ::Kernel.instance_method(name).bind_call(self, *parameters, **arguments, &block)
244
+ else
245
+ ::Kernel.instance_method(name).bind_call(self, input, *parameters, **arguments, &block)
246
+ end
247
+ elsif input_omitted
224
248
  ::Proc::Callable.new(name, client: self, arguments: arguments)
225
249
  else
226
250
  ::Proc::Callable.new(name, client: self, input: input, arguments: arguments)
@@ -238,6 +262,13 @@ class Proc
238
262
  end
239
263
  alias_method :arg, :argument
240
264
 
265
+ # [public] Returns a partial representation of the authorization that is safe to include in logs.
266
+ #
267
+ def safe_authorization
268
+ return unless @authorization
269
+ "#{@authorization[0..7]}...#{@authorization[-5..]}"
270
+ end
271
+
241
272
  private def build_uri(proc)
242
273
  ::File.join(@__base_url, proc.to_s.split(".").join("/"))
243
274
  end
@@ -246,16 +277,18 @@ class Proc
246
277
  case value
247
278
  when ::Symbol
248
279
  ["@@", value.to_s, {}]
249
- when ::Proc::Composer::Argument, ::Proc::Callable, ::Proc::Composition
250
- value.serialize
251
280
  else
252
- ["%%", value]
281
+ if value.respond_to?(:serialize)
282
+ value.serialize
283
+ else
284
+ ["%%", value]
285
+ end
253
286
  end
254
287
  end
255
288
 
256
289
  private def get_payload(proc:, body:)
257
290
  await {
258
- @request_count += 1
291
+ @count += 1
259
292
 
260
293
  response = ::HTTP.headers(@__headers).post(build_uri(proc), body: ::MessagePack.pack(body))
261
294
 
@@ -2,6 +2,8 @@
2
2
 
3
3
  class Proc
4
4
  class Composition < Composer::Composition
5
+ inspects :@client
6
+
5
7
  def initialize(client:, **kwargs)
6
8
  @client = client
7
9
 
@@ -1,9 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "core/inspect"
4
+
3
5
  class Proc
4
6
  class Enumerator
5
7
  include Enumerable
6
8
 
9
+ include Is::Inspectable
10
+ inspects :@values
11
+
7
12
  attr_reader :values, :next_block
8
13
 
9
14
  def initialize(values, &next_block)
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.14.0"
4
+ VERSION = "0.15.0"
5
5
 
6
6
  # [public]
7
7
  #
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.14.0
4
+ version: 0.15.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-09-23 00:00:00.000000000 Z
11
+ date: 2022-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: core-async
@@ -16,28 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.6'
19
+ version: '0.10'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.6'
26
+ version: '0.10'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: core-global
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.0'
33
+ version: '0.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.0'
40
+ version: '0.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: core-inspect
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.1'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: http
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -115,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
129
  - !ruby/object:Gem::Version
116
130
  version: '0'
117
131
  requirements: []
118
- rubygems_version: 3.2.22
132
+ rubygems_version: 3.3.3
119
133
  signing_key:
120
134
  specification_version: 4
121
135
  summary: Proc client library.