relax2 0.1.0 → 0.1.1

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: f3ced21a4e66c7b6eee62f684be2f4960bf10512f9d6618414f5dd6bc750f41a
4
- data.tar.gz: 94c2ebd8799612e6dbd780ff5e2eecb65810c4a1b50ec883098ff4e4e7611647
3
+ metadata.gz: b1d4754cf78cfd9cd14ad07199bf060cb7acc8a42f9a0421ad1e9dc6cc0e6e28
4
+ data.tar.gz: ac42d0f018143b035d0a63be94f7e4bdbdff0e3a15712e04b18551bf33453f33
5
5
  SHA512:
6
- metadata.gz: 7d102b5eb07a687e9fbd92bb9297246d980c0f0101299124a64ed561d1316e351d3e150e72d174846b39fccfc63768580e3db1fc567daa8a7a63548b519165ef
7
- data.tar.gz: 76a6bec28e312cafb5ca718aa3109930142fe26dde56cb509613c8ceda521d582357c0a62a3b559ac1458e3bbcbb5e91d72662ac6cb1309b9822583880b2e19b
6
+ metadata.gz: c90cf246bda20a707020e8f2b08764b457e0d22d3a8fe758c16e80f3a00ba3facd7f328b5a4e8f2290810e66fae4bbea4661f708b3c5fa7cc4ea597600d7e4fa
7
+ data.tar.gz: 62e13d0fe05f8091773f0ea6db7471e20686af49980b2c10707355db9e5068aa997b1a7c087787ae13f0ead4bd4e28f03df3528595c5732336049a907d6be147
data/README.md CHANGED
@@ -8,56 +8,20 @@ require 'relax2'
8
8
 
9
9
  base_url 'https://petstore.swagger.io/v2'
10
10
 
11
- interceptor -> (request, perform_request) do
12
- puts request.body
13
- response = perform_request.call(request)
14
- puts response.body
15
- response
16
- end
11
+ interceptor :json_request
12
+ interceptor :print_response
17
13
  ```
18
14
 
19
15
  Then enjoy your API calls.
20
16
 
21
17
  ```
22
18
  % ruby petstore.rb GET /pet/2
23
- {
24
- "id": 2,
25
- "category": {
26
- "id": 5,
27
- "name": "Angel"
28
- },
29
- "name": "DOG",
30
- "tags": [
31
- {
32
- "id": 1,
33
- "name": "Armanda Hirthe"
34
- }
35
- ],
36
- "status": "available"
37
- }
19
+ {"id":2,"name":"doggie","photoUrls":[],"tags":[],"status":"available"}
38
20
  ```
39
21
 
40
22
  ```
41
- % ruby petstore.rb PUT /pet/2
42
- {
43
- "name": "NEW DOG"
44
- }
45
-
46
- {
47
- "id": 2,
48
- "category": {
49
- "id": 5,
50
- "name": "Angel"
51
- },
52
- "name": "NEW DOG",
53
- "tags": [
54
- {
55
- "id": 1,
56
- "name": "Armanda Hirthe"
57
- }
58
- ],
59
- "status": "available"
60
- }
23
+ $ echo '{"id": 2, "name": "NEW DOG", "status": "unavailable"}' | ruby petstore.rb PUT /pet
24
+ {"id":2,"name":"NEW DOG","photoUrls":[],"tags":[],"status":"unavailable"}
61
25
  ```
62
26
 
63
27
  If you want to create more detailed client, use the modular style with `Relax2::Base`.
@@ -78,12 +42,13 @@ class ExampleApi < Relax2::Base
78
42
  end
79
43
  end
80
44
 
45
+ # Request manually
81
46
  request = Relax2::Request.from_string('GET /hogehoge q=xx USER-Agent: Hoge/1.23')
82
47
  response = ExampleApi.call(request)
83
- ```
84
-
85
-
86
48
 
49
+ # or, simply work with CLI args :)
50
+ ExampleApi.run
51
+ ```
87
52
 
88
53
  ## Installation
89
54
 
@@ -95,6 +60,17 @@ gem 'relax2'
95
60
 
96
61
  and then `bundle install`
97
62
 
63
+ ## References
64
+
65
+ ### Examples
66
+
67
+ * Example of relax2 for [Android Management API](https://developers.google.com/android/management): https://github.com/YusukeIwaki/relax2-androidmanagement-api
68
+
69
+ ### Other langs
70
+
71
+ * rakuda[https://github.com/YusukeIwaki/rakuda]: Dart implementation. Good for distributing in-house API client tool.
72
+ * [@zatsu/core](https://github.com/YusukeIwaki/zatsu-core): Node.js implementation. Useful for distribution with npx.
73
+
98
74
  ## Development
99
75
 
100
76
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -12,8 +12,8 @@ module Relax2
12
12
  lines = []
13
13
  lines << "#{request.http_method} #{request.path}"
14
14
  if @print_headers
15
- request.headers.each do |header|
16
- lines << "#{header.name}: #{header.value}"
15
+ request.headers.each do |name, value|
16
+ lines << "#{name}: #{value}"
17
17
  end
18
18
  end
19
19
 
@@ -42,8 +42,8 @@ module Relax2
42
42
  lines << "HTTP #{response.status}" if @print_status
43
43
 
44
44
  if @print_headers
45
- response.headers.each do |header|
46
- lines << "#{header.name}: #{header.value}"
45
+ response.headers.each do |name, value|
46
+ lines << "#{name}: #{value}"
47
47
  end
48
48
  end
49
49
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Relax2
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relax2
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
  - YusukeIwaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-18 00:00:00.000000000 Z
11
+ date: 2022-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler