takeout 1.0.5 → 1.0.6
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/lib/takeout/client.rb +10 -5
- data/lib/takeout/core/ext/nil_class.rb +9 -0
- data/lib/takeout/version.rb +1 -1
- data/takeout.gemspec +1 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5d8d5f83e93d1ddd98f7b0694a53ba366aff5da
|
4
|
+
data.tar.gz: 8d36b86cac6fe3019f26ccd74a1e98345fb9a6c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa2ac9b5812224c26fae12ae3915ae715995bf918e3ae2a4a2c277aec15b60704c0f8631070a58d9f8f7af47575d258ac552ad34d03e954739783ec8af049be4
|
7
|
+
data.tar.gz: b4d30288f0b2b5324fdb81091ee74bbcd6299a909032bae53c6a2dd35f41afd6444ec7b78714f3513c3fb0222decce1607233417f2b9f8e93932891926a3338f
|
data/lib/takeout/client.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'takeout/core/ext/nil_class'
|
1
2
|
module Takeout
|
2
3
|
class Client
|
3
4
|
require 'curb'
|
@@ -5,6 +6,7 @@ module Takeout
|
|
5
6
|
require 'uri'
|
6
7
|
require 'erb'
|
7
8
|
require 'liquid'
|
9
|
+
require 'active_support/core_ext/hash'
|
8
10
|
|
9
11
|
# @return [Boolean] a boolean specifying whether or not to run curl with teh verbose setting
|
10
12
|
attr_accessor :debug
|
@@ -32,7 +34,9 @@ module Takeout
|
|
32
34
|
attr_accessor :endpoint_prefix
|
33
35
|
|
34
36
|
# A constant specifying the kind of event callbacks and if they should or should not raise an error
|
35
|
-
CALLBACKS = {failure: true, missing: true
|
37
|
+
CALLBACKS = {failure: true, missing: true}
|
38
|
+
|
39
|
+
JSON_REQUEST_BODY = [:put, :post]
|
36
40
|
|
37
41
|
# The main client initialization method.
|
38
42
|
# ==== Attributes
|
@@ -115,7 +119,8 @@ module Takeout
|
|
115
119
|
end
|
116
120
|
|
117
121
|
def perform_curl_request(request_type, request_url, options=nil, headers=nil)
|
118
|
-
|
122
|
+
body = JSON_REQUEST_BODY.include?(request_type.to_sym) ? Oj.dump(options.deep_stringify_keys!) : options
|
123
|
+
curl = Curl.send(request_type, request_url.to_s, body) do |curl|
|
119
124
|
curl.verbose = true if @debug
|
120
125
|
curl.headers = headers if headers
|
121
126
|
|
@@ -125,12 +130,12 @@ module Takeout
|
|
125
130
|
curl.password = options[:password]
|
126
131
|
end
|
127
132
|
|
128
|
-
CALLBACKS.each { |callback_type,failure| curl.send("on_#{callback_type}") {|response| @
|
133
|
+
CALLBACKS.each { |callback_type,failure| curl.send("on_#{callback_type}") {|response| @failure = failure}}
|
129
134
|
end
|
130
135
|
|
131
136
|
raise Takeout::EndpointFailureError.new(curl, request_type, @parsed_body) if @failure
|
132
137
|
|
133
|
-
return
|
138
|
+
return Takeout::Response.new(headers: parse_response_headers(curl.head), body: Oj.load(curl.body_str), response: curl)
|
134
139
|
end
|
135
140
|
|
136
141
|
|
@@ -178,7 +183,7 @@ module Takeout
|
|
178
183
|
end
|
179
184
|
|
180
185
|
def parse_response_headers(header_string)
|
181
|
-
header_string.split("\r\n")[1..-1].map {|x| {x.split(': ')[0].to_sym => x.split(': ')[1]} }.reduce({}, :update)
|
186
|
+
header_string.split("\r\n")[1..-1].map {|x| {x.split(': ')[0].to_sym => x.split(': ')[1]} }.reduce({}, :update) if header_string && !header_string.empty?
|
182
187
|
end
|
183
188
|
|
184
189
|
def method_missing(method_sym, *attributes, &block)
|
data/lib/takeout/version.rb
CHANGED
data/takeout.gemspec
CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_runtime_dependency "oj"
|
25
25
|
spec.add_runtime_dependency "curb", "~> 0.8.8"
|
26
26
|
spec.add_runtime_dependency "liquid"
|
27
|
+
spec.add_runtime_dependency "activesupport"
|
27
28
|
spec.add_development_dependency "rspec"
|
28
29
|
spec.add_development_dependency "sinatra"
|
29
30
|
spec.add_development_dependency "webmock"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: takeout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle Lucas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: activesupport
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rspec
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -155,6 +169,7 @@ files:
|
|
155
169
|
- lib/.DS_Store
|
156
170
|
- lib/takeout.rb
|
157
171
|
- lib/takeout/client.rb
|
172
|
+
- lib/takeout/core/ext/nil_class.rb
|
158
173
|
- lib/takeout/endpoint_failure_error.rb
|
159
174
|
- lib/takeout/response.rb
|
160
175
|
- lib/takeout/version.rb
|
@@ -194,3 +209,4 @@ test_files:
|
|
194
209
|
- spec/support/fake_test_api.rb
|
195
210
|
- spec/support/fixtures/post.json
|
196
211
|
- spec/support/fixtures/posts.json
|
212
|
+
has_rdoc:
|