reynard 0.0.8 → 0.0.9

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: fcfd5e665e0b3fcc8c593d81c15db9560e8abc0125e9a254aeb98d3f53b6fb8a
4
- data.tar.gz: 61d7d812f5b5eacf55c9be3fb6463cf1adafeb5e7935d2d0fc0b20a33a4a27b3
3
+ metadata.gz: ec98b52096f95c7c03aaa61a7f27555f5d595ab83ac15510e49fbdc600cbb3a0
4
+ data.tar.gz: e3fc7d6e0aa537ea08c727e89aec68b2e66986f5e4e1e53ebd6f74733bde6b8b
5
5
  SHA512:
6
- metadata.gz: 05a42b85120cb3e519c4fcc3bad7c23a17e5c1a007072b22843421619b1460dabf378750fc83eea406a44a3ec0e08c80b309d53bdce2da0df09d6f3a67643685
7
- data.tar.gz: d8e2ce1c77b097a4a3e4a64d8b3fd2d67bc0e8737307e9429452e4d794aedad7c34e7b44a76a1f4ac945f459a4f0497e67d354ebb37f2cb1fdece9e187981efd
6
+ metadata.gz: 2b18bf2403a99460ded8be2c85efc08b28ffa8616d35628dbdb0806f58613e426acf48eff05d6f0c74bc0e602ed9a0bb6bc69e3604818b6b7a1ba9f1c4f38848
7
+ data.tar.gz: c566c502480ff527e5e8a6451bebd5b8629c714fb41a27faa486a311fb8a20ee85aea14d1c89c211fe20e6dd63e768027d678593341178d89177cda3f24512df
data/README.md CHANGED
@@ -66,6 +66,20 @@ employee = reynard.
66
66
  execute
67
67
  ```
68
68
 
69
+ ## Mocking
70
+
71
+ You can mock Reynard requests by changing the HTTP implementation. The class **must** implement a single `request` method that accepts an URI and net/http request object. It **must** return a net/http response object or an object with the exact same interface.
72
+
73
+ ```ruby
74
+ Reynard.http = MyMock.new
75
+
76
+ class MyMock
77
+ def request(uri, net_http_request)
78
+ Net::HTTPResponse::CODE_TO_OBJ['404'].new('HTTP/1.1', '200', 'OK')
79
+ end
80
+ end
81
+ ```
82
+
69
83
  ## Copyright and other legal
70
84
 
71
85
  See LICENCE.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Reynard
4
- VERSION = '0.0.8'
4
+ VERSION = '0.0.9'
5
5
  end
data/lib/reynard.rb CHANGED
@@ -34,6 +34,14 @@ class Reynard
34
34
  @specification = Specification.new(filename: filename)
35
35
  end
36
36
 
37
+ # Assign an object that follows Reynard's internal request interface to mock requests or use a
38
+ # different HTTP client.
39
+ class << self
40
+ attr_writer :http
41
+ end
42
+
43
+ # Returns Reynard's global request interface. This is a global object to allow persistent
44
+ # connections, caching, and other features that need a persistent object in the process.
37
45
  def self.http
38
46
  @http ||= begin
39
47
  http = Net::HTTP::Persistent.new(name: 'Reynard')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reynard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manfred Stienstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-01 00:00:00.000000000 Z
11
+ date: 2021-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json