dagger 1.1.0 → 1.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4bfc1ae0c456b34133f1193441ade9ec29aff0a12c8cd3d5789431095e0b9460
4
- data.tar.gz: 4793e4ca427ee9ed39dd93b0b3eb0055023a3fcbacb2e168e1e1dc91c56ae988
3
+ metadata.gz: fb4982d6515068052558c93a430c1d62c3c95908f4c4f48b945fbd2414d50673
4
+ data.tar.gz: e66cbf94eaa46bb61b4a72648b337cc36664703368818d42aaa0b6704d23bdec
5
5
  SHA512:
6
- metadata.gz: dd762ea62c7d7a5a10d8c953900c7875aefa4e4b8c983b8b198bdbbf9083d218b8b8aad156d89ae30a457be3f7e0cd51f4dbb0d35ff92bb7ef6032d28e98a302
7
- data.tar.gz: 980873071693904349794ca12d5b22ad791ba52ac658ce8225da61fc94faaa4e8a4529c30fbb6cd6be3945d6a83cc31fb4bb5288f957f8d8a309646712b592be
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.
@@ -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
- request = Net::HTTP::Get.new(path, DEFAULT_HEADERS.merge(opts[:headers] || {}))
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
@@ -5,6 +5,10 @@ XMLNode = Struct.new(:name, :text, :attributes, :children) do
5
5
  alias_method :to_s, :text
6
6
  alias_method :value, :text
7
7
 
8
+ def count
9
+ raise "Please call #children.count"
10
+ end
11
+
8
12
  def to_hash
9
13
  self # for backwards compat
10
14
  end
@@ -1,6 +1,6 @@
1
1
  module Dagger
2
2
  MAJOR = 1
3
- MINOR = 1
3
+ MINOR = 2
4
4
  PATCH = 0
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.1.0
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: 2018-09-26 00:00:00.000000000 Z
11
+ date: 2019-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler