phlanket_wrapper 0.0.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 +7 -0
- data/.gitignore +8 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +200 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/phlanket/exception.rb +106 -0
- data/lib/phlanket/response.rb +31 -0
- data/lib/phlanket/utils.rb +5 -0
- data/lib/phlanket/version.rb +4 -0
- data/lib/phlanket/wrapper.rb +115 -0
- data/lib/phlanket.rb +13 -0
- data/phlanket.gemspec +34 -0
- metadata +243 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 250b646dc5a34e74b3ce24fa23cb39c0b6425a97
|
4
|
+
data.tar.gz: 781e819a7ce4d771f87854501302ecb8722a9301
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c3c7e0fb8576f98309c53ae4987ac1a680f18060ec05eeda7dfe5859e81aa17384aad1854ffefd82490c853a81554dd5b381c81d6d79072523cff7e028aec620
|
7
|
+
data.tar.gz: 5595d2ac7d5e65fbd4d2c246e5418b9014b1d43f31af2465e1af59906d5befa1a87446727146f5596cf644ca247b3778d5b359eb210cf946fb34eb71bfd9248b
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Jascha
|
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,200 @@
|
|
1
|
+
# Blanket
|
2
|
+
[](https://travis-ci.org/inf0rmer/blanket)
|
3
|
+
[](https://coveralls.io/r/inf0rmer/blanket?branch=master)
|
4
|
+
[](https://codeclimate.com/github/inf0rmer/blanket)
|
5
|
+
[](http://inch-ci.org/github/inf0rmer/blanket)
|
6
|
+
|
7
|
+
|
8
|
+
A dead simple API wrapper.
|
9
|
+
|
10
|
+
**Table of Contents**
|
11
|
+
|
12
|
+
- [Installation](#installation)
|
13
|
+
- [Usage](#usage)
|
14
|
+
- [Quick demo](#quick-demo)
|
15
|
+
- [How it works](#how-it-works)
|
16
|
+
- [Responses](#responses)
|
17
|
+
- [Request Parameters](#request-parameters)
|
18
|
+
- [Headers](#headers)
|
19
|
+
- [Extensions](#extensions)
|
20
|
+
- [Handling Exceptions](#handling-exceptions)
|
21
|
+
- [Contributing](#contributing)
|
22
|
+
|
23
|
+
## Installation
|
24
|
+
|
25
|
+
Add this line to your application's Gemfile:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
gem 'phlanket_wrapper'
|
29
|
+
```
|
30
|
+
|
31
|
+
And then execute:
|
32
|
+
|
33
|
+
$ bundle
|
34
|
+
|
35
|
+
Or install it yourself as:
|
36
|
+
|
37
|
+
$ gem install phlanket_wrapper
|
38
|
+
|
39
|
+
## Usage
|
40
|
+
|
41
|
+
### Quick demo
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
require 'phlanket'
|
45
|
+
|
46
|
+
github = Blanket.wrap("https://api.github.com")
|
47
|
+
|
48
|
+
# Get some user's info
|
49
|
+
user = github.users('inf0rmer').get
|
50
|
+
user.login
|
51
|
+
# => "inf0rmer"
|
52
|
+
|
53
|
+
# Get a user's repos
|
54
|
+
github.users('inf0rmer').repos.get
|
55
|
+
# => [{
|
56
|
+
# "id": 20000073,
|
57
|
+
# "name": "BAPersistentOperationQueue",
|
58
|
+
# ...
|
59
|
+
# }]
|
60
|
+
```
|
61
|
+
|
62
|
+
### How it works
|
63
|
+
Blanket uses some metaprogramming black magic to wrap an API. Everytime you call a method on a wrapped API, Blanket appends it as a part of the final URL:
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
github = Blanket.wrap("https://api.github.com")
|
67
|
+
github.users('inf0rmer').repos.get
|
68
|
+
```
|
69
|
+
|
70
|
+
Here's how the final URL is built, the step by step:
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
github = Blanket.wrap("https://api.github.com")
|
74
|
+
# => "https://api.github.com"
|
75
|
+
|
76
|
+
github.users
|
77
|
+
# => "https://api.github.com/users"
|
78
|
+
|
79
|
+
github.users('inf0rmer')
|
80
|
+
# => "https://api.github.com/users/inf0rmer"
|
81
|
+
|
82
|
+
github.users('inf0rmer').repos
|
83
|
+
# => "https://api.github.com/users/inf0rmer/repos"
|
84
|
+
```
|
85
|
+
|
86
|
+
The final `get` method performs a GET HTTP request. You can also use it to append a final part to your request, so you can write something like:
|
87
|
+
|
88
|
+
As this magic works using `method_missing`, you can `send` slashed uri parts to the wrapper and it will play nicely. This is especially usefull when APIs give you URLs:
|
89
|
+
```ruby
|
90
|
+
github.get('users/inf0rmer/repos')
|
91
|
+
# or, if you don't wnat to perform the request yet, or have to append more parts to the uri
|
92
|
+
github.send('users/inf0rmer').repos#.get
|
93
|
+
```
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
github = Blanket.wrap("https://api.github.com")
|
97
|
+
github.users.get('inf0rmer')
|
98
|
+
# => "https://api.github.com/users/inf0rmer"
|
99
|
+
```
|
100
|
+
|
101
|
+
### Responses
|
102
|
+
At the moment Blanket only accepts JSON responses. Every request returns a `Blanket::Response` instance, which parses the JSON internally and lets you access keys using dot syntax:
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
user = github.users('inf0rmer').get
|
106
|
+
|
107
|
+
user.login
|
108
|
+
# => "inf0rmer"
|
109
|
+
|
110
|
+
user.url
|
111
|
+
# => "https://api.github.com/users/inf0rmer"
|
112
|
+
|
113
|
+
# It even works on nested keys
|
114
|
+
repo = github.repos('inf0rmer').get('blanket')
|
115
|
+
|
116
|
+
repo.owner.login
|
117
|
+
# => "inf0rmer"
|
118
|
+
```
|
119
|
+
|
120
|
+
If the response is an array, all `Enumerable` methods work as expected:
|
121
|
+
|
122
|
+
```ruby
|
123
|
+
repos = github.users('inf0rmer').repos.get
|
124
|
+
|
125
|
+
repos.map(&:name)
|
126
|
+
# => ["analytics-ios", "aztec", "fusebox", ...]
|
127
|
+
```
|
128
|
+
|
129
|
+
### Request Body
|
130
|
+
You can make requests with body using the `body` option:
|
131
|
+
|
132
|
+
```ruby
|
133
|
+
api = Blanket::wrap("http://api.example.org")
|
134
|
+
api.messages.post(body: 'Hello')
|
135
|
+
```
|
136
|
+
|
137
|
+
### Request Parameters
|
138
|
+
Blanket supports appending parameters to your requests:
|
139
|
+
|
140
|
+
```ruby
|
141
|
+
api.users(55).get(params: {foo: 'bar'})
|
142
|
+
# => "http://api.example.org/users/55?foo=bar"
|
143
|
+
```
|
144
|
+
|
145
|
+
You can also set default params for all your requests on initialization:
|
146
|
+
|
147
|
+
```ruby
|
148
|
+
api = Blanket::wrap("http://api.example.org", params: {access_token: 'my secret token'})
|
149
|
+
```
|
150
|
+
|
151
|
+
### Headers
|
152
|
+
HTTP Headers are always useful when accessing an API, so Blanket makes it easy for you to specify them, either globally or on a per-request basis:
|
153
|
+
|
154
|
+
```ruby
|
155
|
+
# All requests will carry the `token` header
|
156
|
+
api = Blanket::wrap("http://api.example.org", headers: {token: 'my secret token'})
|
157
|
+
|
158
|
+
# This single request will carry the `foo` header
|
159
|
+
api.users(55).get(headers: {foo: 'bar'})
|
160
|
+
```
|
161
|
+
|
162
|
+
### Extensions
|
163
|
+
Some APIs require you to append an extension to your requests, such as `.json` or `.xml`. Blanket supports this use case, letting you define an extension for all your requests or override it for a single one:
|
164
|
+
|
165
|
+
```ruby
|
166
|
+
# All request URLs are suffixed with ".json"
|
167
|
+
api = Blanket::wrap("http://api.example.org", extension: :json)
|
168
|
+
|
169
|
+
# Requests to "users_endpoint" are suffixed with ".xml" instead
|
170
|
+
users_endpoint = api.users(55)
|
171
|
+
users_endpoint.extension = :xml
|
172
|
+
```
|
173
|
+
|
174
|
+
### Handling Exceptions
|
175
|
+
|
176
|
+
Blanket will raise exceptions for HTTP errors encountered while making requests. Exception subclasses are raised for well known errors (404, 500, etc.) but for other status codes a default `Blanket::Exception` will be raised instead.
|
177
|
+
|
178
|
+
```ruby
|
179
|
+
begin
|
180
|
+
api.thingamajig.get
|
181
|
+
rescue Blanket::ResourceNotFound => e
|
182
|
+
e.code
|
183
|
+
# => 404
|
184
|
+
|
185
|
+
e.message
|
186
|
+
# => "404: Resource Not Found"
|
187
|
+
|
188
|
+
# The HTTP body, ie. the error message sent by the server
|
189
|
+
e.body
|
190
|
+
# => "Could not find this resource!"
|
191
|
+
end
|
192
|
+
```
|
193
|
+
|
194
|
+
## Contributing
|
195
|
+
|
196
|
+
1. Fork it ( https://github.com/inf0rmer/blanket/fork )
|
197
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
198
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
199
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
200
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "phlanket"
|
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,106 @@
|
|
1
|
+
module Phlanket
|
2
|
+
|
3
|
+
# A Map of "error" HTTP status codes and their names
|
4
|
+
STATUSES = {
|
5
|
+
400 => 'Bad Request',
|
6
|
+
401 => 'Unauthorized',
|
7
|
+
402 => 'Payment Required',
|
8
|
+
403 => 'Forbidden',
|
9
|
+
404 => 'Resource Not Found',
|
10
|
+
405 => 'Method Not Allowed',
|
11
|
+
406 => 'Not Acceptable',
|
12
|
+
407 => 'Proxy Authentication Required',
|
13
|
+
408 => 'Request Timeout',
|
14
|
+
409 => 'Conflict',
|
15
|
+
410 => 'Gone',
|
16
|
+
411 => 'Length Required',
|
17
|
+
412 => 'Precondition Failed',
|
18
|
+
413 => 'Request Entity Too Large',
|
19
|
+
414 => 'Request-URI Too Long',
|
20
|
+
415 => 'Unsupported Media Type',
|
21
|
+
416 => 'Requested Range Not Satisfiable',
|
22
|
+
417 => 'Expectation Failed',
|
23
|
+
418 => 'I\'m A Teapot', #RFC2324
|
24
|
+
421 => 'Too Many Connections From This IP',
|
25
|
+
422 => 'Unprocessable Entity', #WebDAV
|
26
|
+
423 => 'Locked', #WebDAV
|
27
|
+
424 => 'Failed Dependency', #WebDAV
|
28
|
+
425 => 'Unordered Collection', #WebDAV
|
29
|
+
426 => 'Upgrade Required',
|
30
|
+
428 => 'Precondition Required', #RFC6585
|
31
|
+
429 => 'Too Many Requests', #RFC6585
|
32
|
+
431 => 'Request Header Fields Too Large', #RFC6585
|
33
|
+
449 => 'Retry With', #Microsoft
|
34
|
+
450 => 'Blocked By Windows Parental Controls', #Microsoft
|
35
|
+
|
36
|
+
500 => 'Internal Server Error',
|
37
|
+
501 => 'Not Implemented',
|
38
|
+
502 => 'Bad Gateway',
|
39
|
+
503 => 'Service Unavailable',
|
40
|
+
504 => 'Gateway Timeout',
|
41
|
+
505 => 'HTTP Version Not Supported',
|
42
|
+
506 => 'Variant Also Negotiates',
|
43
|
+
507 => 'Insufficient Storage', #WebDAV
|
44
|
+
509 => 'Bandwidth Limit Exceeded', #Apache
|
45
|
+
510 => 'Not Extended',
|
46
|
+
511 => 'Network Authentication Required', # RFC6585
|
47
|
+
}
|
48
|
+
|
49
|
+
# The base class for all Blanket Exceptions
|
50
|
+
class Exception < RuntimeError
|
51
|
+
# Attribute writer for the Exception message
|
52
|
+
attr_writer :message
|
53
|
+
# Attribute reader for the Exception http response
|
54
|
+
attr_reader :response
|
55
|
+
|
56
|
+
# Creates a new exception
|
57
|
+
# @param [HTTParty::Response] response the HTTP Response
|
58
|
+
# @return [Blanket::Exception] The Blanket Exception object
|
59
|
+
def initialize(response = nil)
|
60
|
+
@response = response
|
61
|
+
end
|
62
|
+
|
63
|
+
# Returns the HTTP response body
|
64
|
+
def body
|
65
|
+
@response.body.to_s if @response
|
66
|
+
end
|
67
|
+
|
68
|
+
# Returns the HTTP status code
|
69
|
+
def code
|
70
|
+
@response.code.to_i if @response
|
71
|
+
end
|
72
|
+
|
73
|
+
# Returns a formatted error message
|
74
|
+
def message
|
75
|
+
@message || self.class.name
|
76
|
+
end
|
77
|
+
|
78
|
+
# Returns a stringified error message
|
79
|
+
def inspect
|
80
|
+
"#{message}: #{body}"
|
81
|
+
end
|
82
|
+
|
83
|
+
alias_method :to_s, :inspect
|
84
|
+
end
|
85
|
+
|
86
|
+
# We will a create an exception for each status code, see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
|
87
|
+
module Exceptions
|
88
|
+
# Map http status codes to the corresponding exception class
|
89
|
+
EXCEPTIONS_MAP = {}
|
90
|
+
|
91
|
+
def self.generate_from_response(response)
|
92
|
+
(EXCEPTIONS_MAP[response.code] || Exception).new(response)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
STATUSES.each_pair do |code, message|
|
97
|
+
klass = Class.new(Exception) do
|
98
|
+
define_method :message do
|
99
|
+
"#{code} #{message}"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
klass_constant = const_set message.delete(' \-\''), klass
|
104
|
+
Exceptions::EXCEPTIONS_MAP[code] = klass_constant
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'json'
|
2
|
+
module Phlanket
|
3
|
+
|
4
|
+
# The Response class wraps HTTP responses
|
5
|
+
class Response
|
6
|
+
# Attribute reader for the original JSON payload string and JSON payload
|
7
|
+
attr_reader :payload_json
|
8
|
+
|
9
|
+
# A Blanket HTTP response wrapper.
|
10
|
+
# @param [String] json_string A string containing data in the JSON format
|
11
|
+
# @return [Blanket::Response] The wrapped Response object
|
12
|
+
def initialize(json_string)
|
13
|
+
@payload_json = json_string || "{}"
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
# Allows accessing the payload's JSON keys through methods.
|
19
|
+
def method_missing(method, *args, &block)
|
20
|
+
if payload.respond_to? method
|
21
|
+
payload.public_send method, *args, &block
|
22
|
+
else
|
23
|
+
super
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def payload
|
28
|
+
@payload ||= JSON.parse(payload_json, object_class: OpenStruct)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require_relative "utils"
|
2
|
+
|
3
|
+
module Phlanket
|
4
|
+
class Wrapper
|
5
|
+
class << self
|
6
|
+
private
|
7
|
+
# @macro [attach] REST action
|
8
|
+
# @method $1()
|
9
|
+
# Performs a $1 request on the wrapped URL
|
10
|
+
# @param [String, Symbol, Numeric] id The resource identifier to attach to the last part of the request
|
11
|
+
# @param [Hash] options An options hash with values for :headers, :extension, :params and :body
|
12
|
+
# @return [Blanket::Response, Array] A wrapped Blanket::Response or an Array
|
13
|
+
def add_action(action)
|
14
|
+
define_method(action) do |id=nil, options={}|
|
15
|
+
request(action, id, options)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def method_overrides
|
20
|
+
[:send]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Attribute accessor for HTTP Headers that
|
25
|
+
# should be applied to all requests
|
26
|
+
attr_accessor :headers
|
27
|
+
|
28
|
+
# Attribute accessor for params that
|
29
|
+
# should be applied to all requests
|
30
|
+
attr_accessor :params
|
31
|
+
|
32
|
+
# Attribute accessor for file extension that
|
33
|
+
# should be appended to all requests
|
34
|
+
attr_accessor :extension
|
35
|
+
|
36
|
+
add_action :get
|
37
|
+
add_action :post
|
38
|
+
add_action :put
|
39
|
+
add_action :patch
|
40
|
+
add_action :delete
|
41
|
+
|
42
|
+
# Wraps the base URL for an API
|
43
|
+
# @param [String, Symbol] base_uri The root URL of the API you wish to wrap.
|
44
|
+
# @param [Hash] options An options hash with global values for :headers, :extension and :params
|
45
|
+
# @return [Blanket] The Blanket object wrapping the API
|
46
|
+
def initialize(base_uri, options={})
|
47
|
+
@base_uri = base_uri
|
48
|
+
@uri_parts = []
|
49
|
+
@headers = options[:headers] || {}
|
50
|
+
@params = options[:params] || {}
|
51
|
+
@extension = options[:extension]
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def method_missing(method, *args, &block)
|
57
|
+
Wrapper.new uri_from_parts([method, args.first]), {
|
58
|
+
headers: @headers,
|
59
|
+
extension: @extension,
|
60
|
+
params: @params
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
method_overrides.each do |method_name|
|
65
|
+
define_method(method_name) do |argument|
|
66
|
+
Wrapper.new(
|
67
|
+
uri_from_parts([:method_name, argument]),
|
68
|
+
headers: @headers,
|
69
|
+
extension: @extension,
|
70
|
+
params: @params
|
71
|
+
)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def request(method, id=nil, options={})
|
76
|
+
if id.is_a? Hash
|
77
|
+
options = id
|
78
|
+
id = nil
|
79
|
+
end
|
80
|
+
|
81
|
+
headers = Phlanket.stringify_keys merged_headers(options[:headers])
|
82
|
+
params = merged_params(options[:params])
|
83
|
+
uri = uri_from_parts([id])
|
84
|
+
|
85
|
+
if @extension
|
86
|
+
uri = "#{uri}.#{extension}"
|
87
|
+
end
|
88
|
+
|
89
|
+
response = HTTParty.public_send(method, uri, {
|
90
|
+
query: params,
|
91
|
+
headers: headers,
|
92
|
+
body: options[:body]
|
93
|
+
}.reject { |_, value| value.nil? || value.empty? })
|
94
|
+
|
95
|
+
if response.code < 400
|
96
|
+
body = (response.respond_to? :body) ? response.body : nil
|
97
|
+
(body.is_a? Array) ? body.map(Response.new) : Response.new(body)
|
98
|
+
else
|
99
|
+
raise Phlanket::Exceptions.generate_from_response(response)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def merged_headers(headers)
|
104
|
+
@headers.merge(headers || {})
|
105
|
+
end
|
106
|
+
|
107
|
+
def merged_params(params)
|
108
|
+
@params.merge(params || {})
|
109
|
+
end
|
110
|
+
|
111
|
+
def uri_from_parts(parts)
|
112
|
+
File.join @base_uri, *parts.compact.map(&:to_s)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
data/lib/phlanket.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative "phlanket/version"
|
2
|
+
require_relative "phlanket/response"
|
3
|
+
require_relative "phlanket/exception"
|
4
|
+
require_relative "phlanket/wrapper"
|
5
|
+
require 'typhoeus'
|
6
|
+
|
7
|
+
# The main Blanket module
|
8
|
+
module Phlanket
|
9
|
+
# Wraps an API using Blanket::Wrapper
|
10
|
+
def self.wrap(*args)
|
11
|
+
Wrapper.new *args
|
12
|
+
end
|
13
|
+
end
|
data/phlanket.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'phlanket/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "phlanket_wrapper"
|
8
|
+
spec.version = Phlanket::VERSION
|
9
|
+
spec.authors = ["Jascha"]
|
10
|
+
spec.email = ["jascha@zaaksysteem.nl"]
|
11
|
+
spec.summary = %q{Blanket, but with Typhoeus instead of httparty. Access your data with style - and better http functionality.}
|
12
|
+
spec.homepage = "https://gitlab.com/ninjapie"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "typhoeus"
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
spec.add_development_dependency "rspec-nc"
|
26
|
+
spec.add_development_dependency "guard"
|
27
|
+
spec.add_development_dependency "guard-rspec"
|
28
|
+
spec.add_development_dependency "pry"
|
29
|
+
spec.add_development_dependency "pry-remote"
|
30
|
+
spec.add_development_dependency "pry-nav"
|
31
|
+
spec.add_development_dependency "coveralls"
|
32
|
+
spec.add_development_dependency "webmock"
|
33
|
+
spec.add_development_dependency "yard"
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,243 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: phlanket_wrapper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jascha
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-11-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: typhoeus
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
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: rspec-nc
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard-rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry-remote
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: pry-nav
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: coveralls
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: webmock
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: yard
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
description:
|
196
|
+
email:
|
197
|
+
- jascha@zaaksysteem.nl
|
198
|
+
executables:
|
199
|
+
- console
|
200
|
+
- setup
|
201
|
+
extensions: []
|
202
|
+
extra_rdoc_files: []
|
203
|
+
files:
|
204
|
+
- ".gitignore"
|
205
|
+
- Gemfile
|
206
|
+
- LICENSE.txt
|
207
|
+
- README.md
|
208
|
+
- Rakefile
|
209
|
+
- bin/console
|
210
|
+
- bin/setup
|
211
|
+
- lib/phlanket.rb
|
212
|
+
- lib/phlanket/exception.rb
|
213
|
+
- lib/phlanket/response.rb
|
214
|
+
- lib/phlanket/utils.rb
|
215
|
+
- lib/phlanket/version.rb
|
216
|
+
- lib/phlanket/wrapper.rb
|
217
|
+
- phlanket.gemspec
|
218
|
+
homepage: https://gitlab.com/ninjapie
|
219
|
+
licenses:
|
220
|
+
- MIT
|
221
|
+
metadata: {}
|
222
|
+
post_install_message:
|
223
|
+
rdoc_options: []
|
224
|
+
require_paths:
|
225
|
+
- lib
|
226
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
227
|
+
requirements:
|
228
|
+
- - ">="
|
229
|
+
- !ruby/object:Gem::Version
|
230
|
+
version: '0'
|
231
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
232
|
+
requirements:
|
233
|
+
- - ">="
|
234
|
+
- !ruby/object:Gem::Version
|
235
|
+
version: '0'
|
236
|
+
requirements: []
|
237
|
+
rubyforge_project:
|
238
|
+
rubygems_version: 2.6.14
|
239
|
+
signing_key:
|
240
|
+
specification_version: 4
|
241
|
+
summary: Blanket, but with Typhoeus instead of httparty. Access your data with style
|
242
|
+
- and better http functionality.
|
243
|
+
test_files: []
|