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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f64afdf2a10e15adc558059c7915b851cd34ed050c2f83dfd8e55ba9c7f99999
4
- data.tar.gz: f50ac77cbb188db889e3dcb0f37472ded68c80d7a7295981965f024c2482dde2
3
+ metadata.gz: a12a3d9db4308744812542f0e74b3d21ae3075fa91b2025114c2693ea20440f1
4
+ data.tar.gz: ab01f2d4accd0dfe778936fd2a6a1075cbd45e335f4e34f82f2d6507ebfcd7d0
5
5
  SHA512:
6
- metadata.gz: f54ea1ab20690321f7b1af9128d492dee40a23dcfc75a390809b4b30f776d7706e39881e41578b26b912900d9ab1b429ca81ecd222a6a13d4fe127172de1066a
7
- data.tar.gz: fd23a75256a7bdb761277aefdac9ca818da15ac0383d7f41627ed79442edafa674273717fab220c318402a37e031bba81d71d9c54fd07473e888d6d4f0c095ae
6
+ metadata.gz: '0193ebca25917fb8d6be7194a533d6920128213b11a8bf05abb4c093439a5f7c0449b8637af0effcbb139d477a3d0c68bd966567277de4a3f0c670d103a34c75'
7
+ data.tar.gz: 473e6a93ba6ba26fb70ec0fdf931e7a1a046c3713c95f49a0b1675ccd4aac7311f00025e7856faed052a7cc20d10a3d0d5b0fbb8848fc24c23b0e08656b2e7ce
@@ -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['Accept'] = headers['Content-Type'] = 'application/json'
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
 
@@ -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|
@@ -5,12 +5,14 @@ require 'dagger/ox_extension'
5
5
  class Parsers
6
6
 
7
7
  def initialize(response)
8
- @body = response.body
9
- @normalized = response.content_type.to_s.split(';').first.gsub(/[^a-z]/, '_')
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(@normalized, @body) if respond_to?(@normalized)
15
+ send(@normalized_type, @body) if @normalized_type && respond_to?(@normalized_type)
14
16
  end
15
17
 
16
18
  def application_json(body)
@@ -1,6 +1,6 @@
1
1
  module Dagger
2
2
  MAJOR = 1
3
- MINOR = 4
3
+ MINOR = 5
4
4
  PATCH = 1
5
5
 
6
6
  VERSION = [MAJOR, MINOR, PATCH].join('.')
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.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: 2019-11-19 00:00:00.000000000 Z
11
+ date: 2020-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler