resteze 0.1.0 → 0.3.0
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 +4 -4
- data/.rubocop.yml +11 -1
- data/.ruby-version +1 -0
- data/Guardfile +0 -1
- data/README.md +59 -13
- data/assets/resteze.png +0 -0
- data/assets/resteze.svg +3 -0
- data/lib/resteze/api_module.rb +25 -0
- data/lib/resteze/api_resource.rb +70 -0
- data/lib/resteze/client.rb +242 -0
- data/lib/resteze/errors.rb +38 -0
- data/lib/resteze/list.rb +43 -0
- data/lib/resteze/list_object.rb +40 -0
- data/lib/resteze/middleware/raise_error.rb +17 -0
- data/lib/resteze/object.rb +73 -0
- data/lib/resteze/request.rb +14 -0
- data/lib/resteze/response.rb +52 -0
- data/lib/resteze/save.rb +35 -0
- data/lib/resteze/util.rb +54 -0
- data/lib/resteze/version.rb +1 -1
- data/lib/resteze.rb +122 -3
- metadata +20 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da5b0f1ce7cd3e8c2677b9fe22f2c67b755475ea464b25821fc71f4054629bb6
|
4
|
+
data.tar.gz: f8a4c6fa0bd2a169b7f8e818dacb14b11a0e6c69bebe49a6b77004a458351a9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c64c532a62d217fc2819c729fb684590ba0d29eb7ca2f83e9c1ee36a3b9db5e32bb2bc5ae082b3c94b6f0b783bc097b634e7668ad362c09cf1b150f7e607e55
|
7
|
+
data.tar.gz: 6c5c871ed49367a69b401d32409200234352348ab305a0084b0aab8c61b22921115268dd32724c896d1b2eded83c3632e2d62c3ec8371437d5675b4a7fbc9e84
|
data/.rubocop.yml
CHANGED
@@ -7,6 +7,9 @@ inherit_mode:
|
|
7
7
|
merge:
|
8
8
|
- Exclude
|
9
9
|
|
10
|
+
Layout/LineLength:
|
11
|
+
Max: 125
|
12
|
+
|
10
13
|
Metrics/ParameterLists:
|
11
14
|
Exclude:
|
12
15
|
- lib/resteze/errors.rb
|
@@ -25,9 +28,15 @@ Metrics/ClassLength:
|
|
25
28
|
- lib/resteze/client.rb
|
26
29
|
- test/**/*
|
27
30
|
|
31
|
+
Metrics/MethodLength:
|
32
|
+
Max: 15
|
33
|
+
|
28
34
|
Minitest/MultipleAssertions:
|
29
35
|
Max: 6
|
30
36
|
|
37
|
+
Style/Documentation:
|
38
|
+
Enabled: false
|
39
|
+
|
31
40
|
Style/FrozenStringLiteralComment:
|
32
41
|
Enabled: false
|
33
42
|
|
@@ -37,5 +46,6 @@ Style/StringLiterals:
|
|
37
46
|
|
38
47
|
AllCops:
|
39
48
|
NewCops: enable
|
49
|
+
TargetRubyVersion: 3.2
|
40
50
|
Exclude:
|
41
|
-
-
|
51
|
+
- "bin/*"
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.4.2
|
data/Guardfile
CHANGED
data/README.md
CHANGED
@@ -1,38 +1,84 @@
|
|
1
|
-
|
1
|
+
<div style="display: block; text-align: center;">
|
2
|
+
<img src="assets/resteze.svg" alt="Resteze API Ointment" width="128" style="margin: auto;">
|
3
|
+
</div>
|
2
4
|
|
3
|
-
|
5
|
+
[](https://github.com/rwx-services/resteze/actions/workflows/ci.yml)
|
4
6
|
|
5
|
-
|
7
|
+
---
|
8
|
+
|
9
|
+
Resteze is a Ruby library designed to simplify the creation of REST API client gems. It provides a flexible framework for defining API resources, handling requests and responses, managing configuration, and supporting common patterns like listing, saving, and error handling. Built on top of popular Ruby libraries such as Faraday, Hashie, and ActiveSupport, Resteze enables developers to quickly build robust, object-oriented clients for RESTful services, with features for custom resource paths, serialization, and thread-safe client management.
|
10
|
+
|
11
|
+
But Resteze isn't just for REST! Its resource-oriented design lets you give any API—SOAP, RPC, GraphQL, or even quirky legacy endpoints—a clean, resourceful feel. You can wrap non-RESTful APIs in familiar objects, organize calls as resource methods, and enjoy the same convenience and clarity, no matter how your backend is structured. Resteze helps you tame any API and make it feel right at home in Ruby.
|
6
12
|
|
7
13
|
## Installation
|
8
14
|
|
9
|
-
|
15
|
+
You can install Resteze from RubyGems or use it directly from source.
|
10
16
|
|
11
|
-
Install
|
17
|
+
### Install via RubyGems
|
18
|
+
|
19
|
+
Add Resteze to your application's Gemfile:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
bundle add resteze
|
23
|
+
```
|
24
|
+
|
25
|
+
Then run:
|
12
26
|
|
13
27
|
```bash
|
14
|
-
bundle
|
28
|
+
bundle install
|
15
29
|
```
|
16
30
|
|
17
|
-
|
31
|
+
Or install it directly with:
|
18
32
|
|
19
33
|
```bash
|
20
|
-
gem install
|
34
|
+
gem install resteze
|
21
35
|
```
|
22
36
|
|
23
37
|
## Usage
|
24
38
|
|
25
|
-
|
39
|
+
### Building an API Client with Resteze
|
40
|
+
|
41
|
+
To build an API client using Resteze, define a Ruby module for your API and include the `Resteze` concern. Then, create resource classes under your module that inherit from `ApiResource` and define properties for your API objects.
|
26
42
|
|
27
|
-
|
43
|
+
Here's a simple example:
|
28
44
|
|
29
|
-
|
45
|
+
```ruby
|
46
|
+
require 'resteze'
|
47
|
+
|
48
|
+
module MyCoolApi
|
49
|
+
include Resteze
|
50
|
+
|
51
|
+
# Configure your API client
|
52
|
+
configure do |config|
|
53
|
+
config.api_base = 'https://api.example.com/'
|
54
|
+
config.api_key = 'your-api-key'
|
55
|
+
config.logger = Logger.new($stdout)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Define a resource
|
59
|
+
class Widget < ApiResource
|
60
|
+
property :id
|
61
|
+
property :name
|
62
|
+
property :status
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Usage example
|
67
|
+
widget = MyCoolApi::Widget.retrieve(123)
|
68
|
+
puts widget.name
|
69
|
+
|
70
|
+
# List resources
|
71
|
+
widgets = MyCoolApi::Widget.list
|
72
|
+
widgets.each do |w|
|
73
|
+
puts w.id
|
74
|
+
end
|
75
|
+
```
|
30
76
|
|
31
|
-
|
77
|
+
You can define additional resources, customize paths, and add methods as needed. Resteze handles requests, responses, and error management for you, so you can focus on your API's business logic.
|
32
78
|
|
33
79
|
## Contributing
|
34
80
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
81
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rwx-services/resteze.
|
36
82
|
|
37
83
|
## License
|
38
84
|
|
data/assets/resteze.png
ADDED
Binary file
|