rest-service-client 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +236 -0
- data/Rakefile +12 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/rest-service-client.rb +2 -0
- data/lib/rest_service_client.rb +2 -0
- data/lib/restserviceclient/version.rb +7 -0
- data/lib/restserviceclient.rb +133 -0
- data/rest-service-client.gemspec +31 -0
- metadata +130 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 17f91adee05d2bc1fcc439e5d6b4efd3b6f85ed7
|
4
|
+
data.tar.gz: aad2cfb5854b352b654ee2c7cadb498210647043
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 298a23c415c2f7ca179294a68b83166a6ba5ae19c6e217ea8960e5335caa4b920fbcaa741681ee01cfbf26e9d58306b2f6531c4b665c6adb82c89f605fddf984
|
7
|
+
data.tar.gz: f7834c58f22fefe16b13b403a040949622162890300fdb7cbaf13750bfade6ca11e32ba824694140fe43c880223c2d97886fea3d39dd26a855ba951258918090
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_client
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.4.1
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at gravisbesya@list.ru. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Igor Bespalov
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,236 @@
|
|
1
|
+
# ServiceClient
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'rest-service-client'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install service-client
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
Add this line to top of your file
|
21
|
+
```ruby
|
22
|
+
require 'rest-service-client'
|
23
|
+
````
|
24
|
+
|
25
|
+
Create a class, include the RestServiceClient and configure your service
|
26
|
+
```ruby
|
27
|
+
class MyAwesomeService
|
28
|
+
include RestServiceClient
|
29
|
+
|
30
|
+
# Sets the host url
|
31
|
+
# You can use MyAwesomeService.new('https://jsonplaceholder.typicode.com')
|
32
|
+
# to set the host instead. Using host url via constructor has high priority.
|
33
|
+
host 'https://jsonplaceholder.typicode.com'
|
34
|
+
|
35
|
+
# Sets the default headers for every requests.
|
36
|
+
# Will be replaced using: MyAwesomeService.new.find_photo(id: 1, headers: { 'Authorization' => 'Bearer 123456' })
|
37
|
+
headers 'Authorization' => 'OAuth 1111|111'
|
38
|
+
|
39
|
+
# Sets the default params for every requests.
|
40
|
+
# Will be replaced using: MyAwesomeService.new.find_photo(id: 20)
|
41
|
+
params id: 10
|
42
|
+
|
43
|
+
# Configure endpoints:
|
44
|
+
# _httpmethod _method_name, _path
|
45
|
+
# "get :photos, '/photos'" provides an ability
|
46
|
+
# to make GET request to 'https://jsonplaceholder.typicode.com/photos'
|
47
|
+
# using MyAwesomeService.new.photos
|
48
|
+
# Supported: get, post, put, patch, delete
|
49
|
+
get :photos, '/photos'
|
50
|
+
|
51
|
+
# You can assign placeholders for params to path.
|
52
|
+
# Example: MyAwesomeService.new.find_photo(id: 1)
|
53
|
+
get :find_photo, '/photos/:id'
|
54
|
+
|
55
|
+
post :add_photo, '/photos'
|
56
|
+
put :update_photo, '/photos/:id'
|
57
|
+
patch :update_photo_data, '/photos/:id'
|
58
|
+
delete :delete_photo, '/photos/:id'
|
59
|
+
end
|
60
|
+
```
|
61
|
+
|
62
|
+
## Samples
|
63
|
+
|
64
|
+
### Simple Service
|
65
|
+
```ruby
|
66
|
+
class SimpleService
|
67
|
+
include RestServiceClient
|
68
|
+
|
69
|
+
host 'https://jsonplaceholder.typicode.com'
|
70
|
+
|
71
|
+
get :photo, '/photos/:id'
|
72
|
+
get :first_photo, '/photos/1'
|
73
|
+
get :second_photo, '/photos/2'
|
74
|
+
end
|
75
|
+
|
76
|
+
service = SimpleService.new
|
77
|
+
|
78
|
+
p service.first_photo['id']
|
79
|
+
# 1
|
80
|
+
|
81
|
+
p service.second_photo['id']
|
82
|
+
# 2
|
83
|
+
|
84
|
+
p service.photo(id: 10)['id']
|
85
|
+
# 10
|
86
|
+
|
87
|
+
```
|
88
|
+
|
89
|
+
### GET
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
class SimpleService
|
93
|
+
include RestServiceClient
|
94
|
+
host 'https://jsonplaceholder.typicode.com'
|
95
|
+
get :photo, '/photos/:id', { id: 1 }
|
96
|
+
end
|
97
|
+
|
98
|
+
service = SimpleService.new
|
99
|
+
p service.photo['id'] # 1
|
100
|
+
p service.photo(id: 2)['id'] # 2
|
101
|
+
```
|
102
|
+
|
103
|
+
```ruby
|
104
|
+
class SimpleService
|
105
|
+
include RestServiceClient
|
106
|
+
host 'https://jsonplaceholder.typicode.com'
|
107
|
+
|
108
|
+
get :first_photo, '/photos/1', {}, { Authentication: 'my-token' }
|
109
|
+
end
|
110
|
+
|
111
|
+
service = SimpleService.new
|
112
|
+
# Sends the request to 'https://jsonplaceholder.typicode.com/photos/1'
|
113
|
+
# includes Headers: { 'Authentication': 'my-token' }
|
114
|
+
p service.first_photo['albumId'] # 1
|
115
|
+
|
116
|
+
# Sends the request to 'https://jsonplaceholder.typicode.com/photos/1'
|
117
|
+
# includes Headers: {
|
118
|
+
# 'Authentication': 'my-token',
|
119
|
+
# 'AnotherHeaderKey': 'AnotherHeaderValue'
|
120
|
+
# }
|
121
|
+
another_headers = { AnotherHeaderKey: 'AnotherHeaderValue' }
|
122
|
+
photo = service.first_photo(headers: another_headers)
|
123
|
+
p photo['albumId'] # 1
|
124
|
+
|
125
|
+
```
|
126
|
+
|
127
|
+
### DELETE
|
128
|
+
```ruby
|
129
|
+
class SimpleService
|
130
|
+
include RestServiceClient
|
131
|
+
host 'https://jsonplaceholder.typicode.com'
|
132
|
+
delete :delete_photo, '/photos/:id'
|
133
|
+
end
|
134
|
+
|
135
|
+
service = SimpleService.new
|
136
|
+
service.delete_photo id: 1
|
137
|
+
```
|
138
|
+
|
139
|
+
### POST
|
140
|
+
```ruby
|
141
|
+
class SimpleService
|
142
|
+
include RestServiceClient
|
143
|
+
host 'https://jsonplaceholder.typicode.com'
|
144
|
+
post :add_photo, '/photos'
|
145
|
+
end
|
146
|
+
|
147
|
+
service = SimpleService.new
|
148
|
+
photo = {
|
149
|
+
albumId: 1,
|
150
|
+
title: 'new photo',
|
151
|
+
url: 'http://placehold.it/600/92c952',
|
152
|
+
thumbnailUrl: 'http://placehold.it/150/92c952'
|
153
|
+
}
|
154
|
+
p service.add_photo payload: photo
|
155
|
+
=begin
|
156
|
+
{
|
157
|
+
"albumId"=>1,
|
158
|
+
"title"=>"new photo",
|
159
|
+
"url"=>"http://placehold.it/600/92c952",
|
160
|
+
"thumbnailUrl"=>"http://placehold.it/150/92c952",
|
161
|
+
"id"=>5001
|
162
|
+
}
|
163
|
+
=end
|
164
|
+
|
165
|
+
```
|
166
|
+
|
167
|
+
|
168
|
+
### PATCH
|
169
|
+
```ruby
|
170
|
+
class SimpleService
|
171
|
+
include RestServiceClient
|
172
|
+
host 'https://jsonplaceholder.typicode.com'
|
173
|
+
patch :update_photo_data, '/photos/:id'
|
174
|
+
end
|
175
|
+
|
176
|
+
service = SimpleService.new
|
177
|
+
updated_photo = service.update_photo_data id: 1, payload: { title: 'new title'}
|
178
|
+
p updated_photo['title']
|
179
|
+
# "new title"
|
180
|
+
|
181
|
+
```
|
182
|
+
|
183
|
+
## Debug mode
|
184
|
+
|
185
|
+
You can debug mode on for see what is happening
|
186
|
+
|
187
|
+
```ruby
|
188
|
+
class SimpleService
|
189
|
+
include RestServiceClient
|
190
|
+
debug true
|
191
|
+
host 'https://jsonplaceholder.typicode.com'
|
192
|
+
headers key1: 'value1', 'key2': 'value2'
|
193
|
+
get :photo, '/photos/1'
|
194
|
+
end
|
195
|
+
|
196
|
+
service = SimpleService.new
|
197
|
+
service.photo
|
198
|
+
=begin
|
199
|
+
______
|
200
|
+
|
|
201
|
+
| SimpleService is processing GET request to https://jsonplaceholder.typicode.com/photos/1
|
202
|
+
| Headers: {:key1=>"value1", :key2=>"value2"}
|
203
|
+
| Payload: {}
|
204
|
+
|
|
205
|
+
| SimpleService is processing the response on GET request to https://jsonplaceholder.typicode.com/photos/1
|
206
|
+
| Status: 200
|
207
|
+
| Body: {
|
208
|
+
"albumId": 1,
|
209
|
+
"id": 1,
|
210
|
+
"title": "accusamus beatae ad facilis cum similique qui sunt",
|
211
|
+
"url": "http://placehold.it/600/92c952",
|
212
|
+
"thumbnailUrl": "http://placehold.it/150/92c952"
|
213
|
+
}
|
214
|
+
|______
|
215
|
+
=end
|
216
|
+
|
217
|
+
```
|
218
|
+
|
219
|
+
|
220
|
+
## Development
|
221
|
+
|
222
|
+
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.
|
223
|
+
|
224
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
225
|
+
|
226
|
+
## Contributing
|
227
|
+
|
228
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/besya/rest-service-client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
229
|
+
|
230
|
+
## License
|
231
|
+
|
232
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
233
|
+
|
234
|
+
## Code of Conduct
|
235
|
+
|
236
|
+
Everyone interacting in the ServiceClient project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/service_client/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'rest-service-client'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module RestServiceClient
|
5
|
+
def self.included(base)
|
6
|
+
base.extend(ClassMethods)
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_accessor :host,
|
10
|
+
:serializer,
|
11
|
+
:default_headers,
|
12
|
+
:default_params,
|
13
|
+
:debug
|
14
|
+
|
15
|
+
def initialize(url = nil, serializer = nil, debug = nil)
|
16
|
+
@host = url unless url.nil?
|
17
|
+
@host = get_host if respond_to?(:get_host) && url.nil?
|
18
|
+
|
19
|
+
@serializer = JsonSerializer
|
20
|
+
@serializer = serializer unless serializer.nil?
|
21
|
+
@serializer = get_serializer if respond_to?(:get_serializer) && serializer.nil?
|
22
|
+
|
23
|
+
@debug = false
|
24
|
+
@debug = debug unless debug.nil?
|
25
|
+
@debug = get_debug if respond_to?(:get_debug) && debug.nil?
|
26
|
+
|
27
|
+
@default_headers = {}
|
28
|
+
@default_params = {}
|
29
|
+
|
30
|
+
@default_headers = get_default_headers if respond_to? :get_default_headers
|
31
|
+
@default_params = get_default_params if respond_to? :get_default_params
|
32
|
+
end
|
33
|
+
|
34
|
+
def make_request(http_method, endpoint, payload = {}, headers = {})
|
35
|
+
case http_method
|
36
|
+
when :get then RestClient.get(endpoint, headers)
|
37
|
+
when :post then RestClient.post(endpoint, payload, headers)
|
38
|
+
when :put then RestClient.put(endpoint, payload, headers)
|
39
|
+
when :patch then RestClient.patch(endpoint, payload, headers)
|
40
|
+
when :delete then RestClient.delete(endpoint)
|
41
|
+
else throw Exception.new("Method #{http_method} doesn't supported.")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
private :make_request
|
45
|
+
|
46
|
+
module ClassMethods
|
47
|
+
def host(url)
|
48
|
+
define_method :get_host, &-> { url }
|
49
|
+
end
|
50
|
+
|
51
|
+
def serializer(serializer_class)
|
52
|
+
define_method :get_serializer, &-> { serializer_class }
|
53
|
+
end
|
54
|
+
|
55
|
+
def headers(default_headers)
|
56
|
+
define_method :get_default_headers, &-> { default_headers }
|
57
|
+
end
|
58
|
+
|
59
|
+
def params(default_params)
|
60
|
+
define_method :get_default_params, &-> { default_params }
|
61
|
+
end
|
62
|
+
|
63
|
+
def debug(flag)
|
64
|
+
define_method :get_debug, &-> { flag }
|
65
|
+
end
|
66
|
+
|
67
|
+
def get(method_name, path = '', default_params = {}, default_headers = {}, default_payload = {})
|
68
|
+
add_method :get, method_name, path, default_params, default_headers, default_payload
|
69
|
+
end
|
70
|
+
|
71
|
+
def post(method_name, path = '', default_params = {}, default_headers = {}, default_payload = {})
|
72
|
+
add_method :post, method_name, path, default_params, default_headers, default_payload
|
73
|
+
end
|
74
|
+
|
75
|
+
def put(method_name, path = '', default_params = {}, default_headers = {}, default_payload = {})
|
76
|
+
add_method :put, method_name, path, default_params, default_headers, default_payload
|
77
|
+
end
|
78
|
+
|
79
|
+
def patch(method_name, path = '', default_params = {}, default_headers = {}, default_payload = {})
|
80
|
+
add_method :patch, method_name, path, default_params, default_headers, default_payload
|
81
|
+
end
|
82
|
+
|
83
|
+
def delete(method_name, path = '', default_params = {}, default_headers = {}, default_payload = {})
|
84
|
+
add_method :delete, method_name, path, default_params, default_headers, default_payload
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
def add_method(http_method, method_name, path, default_params, default_headers, default_payload)
|
90
|
+
define_method method_name do |headers: {}, payload: {}, parameters: {}, **params|
|
91
|
+
params = @default_params.merge(default_params.merge(params.merge(parameters)))
|
92
|
+
headers = @default_headers.merge(default_headers.merge(headers))
|
93
|
+
payload = default_payload.merge payload
|
94
|
+
|
95
|
+
uri = path.clone
|
96
|
+
|
97
|
+
params.each_with_object(uri) do |(k, v), p|
|
98
|
+
p.sub! ":#{k}", v.to_s
|
99
|
+
end
|
100
|
+
|
101
|
+
endpoint = @host + uri
|
102
|
+
|
103
|
+
if @debug
|
104
|
+
puts
|
105
|
+
puts ' ______'
|
106
|
+
puts '|'
|
107
|
+
puts "| #{self.class.name} is processing #{http_method.upcase} request to #{endpoint}"
|
108
|
+
puts "| Headers: #{headers}"
|
109
|
+
puts "| Payload: #{payload}"
|
110
|
+
end
|
111
|
+
|
112
|
+
response = make_request http_method, endpoint, payload, headers
|
113
|
+
|
114
|
+
if @debug
|
115
|
+
puts '|'
|
116
|
+
puts "| #{self.class.name} is processing the response on #{http_method.upcase} request to #{endpoint}"
|
117
|
+
puts "| Status: #{response.code}"
|
118
|
+
puts "| Body: #{response.body}"
|
119
|
+
puts '|______'
|
120
|
+
puts
|
121
|
+
end
|
122
|
+
|
123
|
+
@serializer.deserialize(response.body)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
class JsonSerializer
|
129
|
+
def self.deserialize(data)
|
130
|
+
JSON.parse(data)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
lib = File.expand_path('../lib', __FILE__)
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
require File.dirname(__FILE__) + '/lib/restserviceclient/version'
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = 'rest-service-client'
|
10
|
+
spec.version = RestServiceClient::VERSION
|
11
|
+
spec.authors = ['Igor Bespalov']
|
12
|
+
spec.email = ['gravisbesya@list.ru']
|
13
|
+
|
14
|
+
spec.summary = 'DSL for rest-client'
|
15
|
+
spec.homepage = 'https://github.com/besya/rest-service-client'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\0").reject do |f|
|
19
|
+
f.match(%r{^(test|spec|features)/})
|
20
|
+
end
|
21
|
+
spec.bindir = 'exe'
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ['lib']
|
24
|
+
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.15'
|
26
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
27
|
+
spec.add_development_dependency 'minitest', '~> 5.0'
|
28
|
+
|
29
|
+
spec.add_dependency 'rest-client'
|
30
|
+
spec.add_dependency 'json'
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rest-service-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Igor Bespalov
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-08-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.15'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.15'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rest-client
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: json
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- gravisbesya@list.ru
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".ruby-gemset"
|
92
|
+
- ".ruby-version"
|
93
|
+
- ".travis.yml"
|
94
|
+
- CODE_OF_CONDUCT.md
|
95
|
+
- Gemfile
|
96
|
+
- LICENSE.txt
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- bin/console
|
100
|
+
- bin/setup
|
101
|
+
- lib/rest-service-client.rb
|
102
|
+
- lib/rest_service_client.rb
|
103
|
+
- lib/restserviceclient.rb
|
104
|
+
- lib/restserviceclient/version.rb
|
105
|
+
- rest-service-client.gemspec
|
106
|
+
homepage: https://github.com/besya/rest-service-client
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
metadata: {}
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 2.6.12
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: DSL for rest-client
|
130
|
+
test_files: []
|