dagger 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -0
- data/lib/dagger.rb +6 -3
- data/lib/dagger/ox_extension.rb +4 -0
- data/lib/dagger/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb4982d6515068052558c93a430c1d62c3c95908f4c4f48b945fbd2414d50673
|
4
|
+
data.tar.gz: e66cbf94eaa46bb61b4a72648b337cc36664703368818d42aaa0b6704d23bdec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e225aa8eddb6f7c2d56ba5883af52836430e05a984313fc4ee345d4186f3b5168dc7bb1979b7dcc35407501d152f9da33a8d2285f103a7a9e178de5771dec74
|
7
|
+
data.tar.gz: b47405379f7627f120bb3ddfc6a364baf6ff790918367774445f7a9a19151378a3b945cd683371af5d434109f2244ce083c00c08e4387502d515b5d65a580321
|
data/README.md
CHANGED
@@ -64,6 +64,17 @@ Dagger.open('https://api.server.com', { verify_ssl: 'false' }) do
|
|
64
64
|
end
|
65
65
|
```
|
66
66
|
|
67
|
+
Passing the block is optional, by the way. You can also open and call the request verb on the returned object:
|
68
|
+
|
69
|
+
```rb
|
70
|
+
http = Dagger.open('https://api.server.com')
|
71
|
+
resp = http.get('/foo')
|
72
|
+
puts resp.code # => 200
|
73
|
+
resp = http.post('/bar', { some: 'thing' })
|
74
|
+
puts resp.data.inspect # => { status: "success" }
|
75
|
+
http.close # don't forget to!
|
76
|
+
```
|
77
|
+
|
67
78
|
# Options
|
68
79
|
|
69
80
|
These are all the available options.
|
data/lib/dagger.rb
CHANGED
@@ -72,7 +72,10 @@ module Dagger
|
|
72
72
|
path = uri[0] == '/' ? uri : Utils.parse_uri(uri).request_uri
|
73
73
|
path.sub!(/\?.*|$/, '?' + Utils.encode(opts[:query])) if opts[:query] and opts[:query].any?
|
74
74
|
|
75
|
-
|
75
|
+
headers = opts[:headers] || {}
|
76
|
+
headers['Accept'] = 'application/json' if opts[:json]
|
77
|
+
|
78
|
+
request = Net::HTTP::Get.new(path, DEFAULT_HEADERS.merge(headers))
|
76
79
|
request.basic_auth(opts.delete(:username), opts.delete(:password)) if opts[:username]
|
77
80
|
|
78
81
|
@http.start unless @http.started?
|
@@ -115,7 +118,7 @@ module Dagger
|
|
115
118
|
query = if data.is_a?(String)
|
116
119
|
data
|
117
120
|
elsif opts[:json]
|
118
|
-
headers['Content-Type'] = 'application/json'
|
121
|
+
headers['Accept'] = headers['Content-Type'] = 'application/json'
|
119
122
|
Oj.dump(data, mode: :compat) # compat ensures symbols are converted to strings
|
120
123
|
else # querystring, then
|
121
124
|
Utils.encode(data)
|
@@ -192,4 +195,4 @@ module Dagger
|
|
192
195
|
|
193
196
|
end
|
194
197
|
|
195
|
-
end
|
198
|
+
end
|
data/lib/dagger/ox_extension.rb
CHANGED
data/lib/dagger/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dagger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomás Pollak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|