dagger 1.4.1 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dagger.rb +5 -4
- data/lib/dagger/ox_extension.rb +20 -0
- data/lib/dagger/parsers.rb +5 -3
- 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: a12a3d9db4308744812542f0e74b3d21ae3075fa91b2025114c2693ea20440f1
|
4
|
+
data.tar.gz: ab01f2d4accd0dfe778936fd2a6a1075cbd45e335f4e34f82f2d6507ebfcd7d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0193ebca25917fb8d6be7194a533d6920128213b11a8bf05abb4c093439a5f7c0449b8637af0effcbb139d477a3d0c68bd966567277de4a3f0c670d103a34c75'
|
7
|
+
data.tar.gz: 473e6a93ba6ba26fb70ec0fdf931e7a1a046c3713c95f49a0b1675ccd4aac7311f00025e7856faed052a7cc20d10a3d0d5b0fbb8848fc24c23b0e08656b2e7ce
|
data/lib/dagger.rb
CHANGED
@@ -93,7 +93,7 @@ module Dagger
|
|
93
93
|
|
94
94
|
opts[:follow] = 10 if opts[:follow] == true
|
95
95
|
headers = opts[:headers] || {}
|
96
|
-
headers['Accept'] = 'application/json' if opts[:json]
|
96
|
+
headers['Accept'] = 'application/json' if opts[:json] && headers['Accept'].nil?
|
97
97
|
|
98
98
|
request = Net::HTTP::Get.new(uri, DEFAULT_HEADERS.merge(headers))
|
99
99
|
request.basic_auth(opts.delete(:username), opts.delete(:password)) if opts[:username]
|
@@ -154,7 +154,8 @@ module Dagger
|
|
154
154
|
query = if data.is_a?(String)
|
155
155
|
data
|
156
156
|
elsif opts[:json]
|
157
|
-
headers['
|
157
|
+
headers['Content-Type'] = 'application/json'
|
158
|
+
headers['Accept'] = 'application/json' if headers['Accept'].nil?
|
158
159
|
Oj.dump(data, mode: :compat) # compat ensures symbols are converted to strings
|
159
160
|
else # querystring, then
|
160
161
|
Utils.encode(data)
|
@@ -173,8 +174,8 @@ module Dagger
|
|
173
174
|
resp, data = @http.send(*args)
|
174
175
|
else # Net::HTTP::Persistent
|
175
176
|
req = Kernel.const_get("Net::HTTP::#{method.capitalize}").new(uri.path, headers)
|
176
|
-
req.set_form_data(query)
|
177
|
-
|
177
|
+
# req.set_form_data(query)
|
178
|
+
req.body = query
|
178
179
|
resp, data = @http.request(uri, req)
|
179
180
|
end
|
180
181
|
|
data/lib/dagger/ox_extension.rb
CHANGED
@@ -20,6 +20,26 @@ XMLNode = Struct.new(:name, :text, :attributes, :children) do
|
|
20
20
|
found.empty? ? nil : found.size == 1 ? found.first : found
|
21
21
|
end
|
22
22
|
|
23
|
+
def slice(*arr)
|
24
|
+
Array(arr).flatten.map { |key| self[key] }
|
25
|
+
end
|
26
|
+
|
27
|
+
def values(arr = nil, include_empty: false)
|
28
|
+
if arr
|
29
|
+
Array(arr).flatten.each_with_object({}) do |key, memo|
|
30
|
+
if found = self[key] and (found.to_s || include_empty)
|
31
|
+
memo[key] = found.to_s
|
32
|
+
end
|
33
|
+
end
|
34
|
+
else
|
35
|
+
children.each_with_object({}) do |child, memo|
|
36
|
+
if child.to_s || include_empty
|
37
|
+
memo[child.name] = child.to_s
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
23
43
|
def dig(*paths)
|
24
44
|
list = Array(paths).flatten
|
25
45
|
res = list.reduce([self]) do |parents, key|
|
data/lib/dagger/parsers.rb
CHANGED
@@ -5,12 +5,14 @@ require 'dagger/ox_extension'
|
|
5
5
|
class Parsers
|
6
6
|
|
7
7
|
def initialize(response)
|
8
|
-
|
9
|
-
|
8
|
+
if type = response.content_type
|
9
|
+
@normalized_type = type.split(';').first.gsub(/[^a-z]/, '_')
|
10
|
+
@body = response.body
|
11
|
+
end
|
10
12
|
end
|
11
13
|
|
12
14
|
def process
|
13
|
-
send(@
|
15
|
+
send(@normalized_type, @body) if @normalized_type && respond_to?(@normalized_type)
|
14
16
|
end
|
15
17
|
|
16
18
|
def application_json(body)
|
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.5.1
|
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: 2020-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|