mudbug 0.8.0.1 → 0.8.1.1

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.
Files changed (5) hide show
  1. checksums.yaml +8 -8
  2. data/VERSION +1 -1
  3. data/lib/mudbug.rb +7 -19
  4. data/test/mudbug.rb +3 -30
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MWQ5MTgyMDc4ODAxMzZlNGNjODA3Mzk4NmFjYmJmMzU5YWQ3MzY5ZA==
4
+ ZTFjMWMzMmVmZGQ4NjM1NTI1YzZlNWU4MTVlMzQ5MDFiYzcyNTA4OA==
5
5
  data.tar.gz: !binary |-
6
- NzM5M2RlZTk4OGRhZGJmZTQwOGQ3Njc0MWVjMTAxZDJkNTQ2YTc2MA==
6
+ NTliMTVhOTYxMjE0ZTNjM2FiNjQ0ODY4MGU4NTYzNWM2MmZjZDdiMQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZjRkYmM5NWExY2IwZjA1YzJiN2Y3ZjFlZTFiOTU2NTY5YzE5ZGU0Y2Q3ODI4
10
- YzQ0MDExNjZlODExMTAwM2FjOWQyOWU5NDg1YjA0MmYzYTkzYmUxOTQ4MTUw
11
- NTVlNjhiOWRmZTliYmEwZjk5OTQzYTBiODc0YTk0YzVlMTAxNDU=
9
+ OWVjZGMzM2JiZGI1OGQwMzUwYzQ2MDNmN2YyZmVmZTcyY2U0NDdlYTQ5ZDYz
10
+ OWVkOWM0MjQ0YTA2YTE5MTE1NDVjZDc3NzVhY2Y0ZTY1NDQ2ZmY0MjRjOGY1
11
+ ODg2M2Q4YzkxNTk0OGZjMmQyYTA2NTAyMmIyYmJjZDQ3YzljY2E=
12
12
  data.tar.gz: !binary |-
13
- ZmQ0MTVjMTBmMjE0NmMwMjY4OTE2M2MyNzYzZGQ5MzVlZWQ4YWMwOTUwYjY1
14
- NzNhMTBmY2ZjMTEwOTljNTBiYThkNGU0MTU4MTUxNjBiNjZiZWJjNjgwNjdj
15
- YmRlYmU1N2Q0NjZlMGMwZmU5YTk4MTBiZDgxYzVmZWYyN2Q1MTc=
13
+ MTU0NGI1ZDc3YzFhM2RhYjM5MTA0YTgxODgxYTlhNzJkYWM3YmY0NTdjYjg4
14
+ NDliMzNmMDM1MDQ2MjMwNjRmZjMxYzdhMDQzYmMwYWIxNTVhODg2NGJhYWM1
15
+ YTdlOWZkYzU2MjlmZDU2YTA4MWFlNWE0ZTYzZDE5NGM1MWVhNTk=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.0.1
1
+ 0.8.1.1
data/lib/mudbug.rb CHANGED
@@ -49,6 +49,7 @@ class Mudbug
49
49
  # accept is e.g. [:json, :html]
50
50
  #
51
51
  def self.process(resp, accept = nil)
52
+ @lager.debug { "accept: #{accept}" }
52
53
  @lager.debug { "response code: #{resp.code}" }
53
54
  @lager.debug { "response headers:\n" << resp.raw_headers.inspect }
54
55
 
@@ -107,7 +108,7 @@ class Mudbug
107
108
  # handling
108
109
  # supports /path/to/res, path/to/res, http://host.com/path/to/res
109
110
  #
110
- def resource(path, options = {})
111
+ def resource(path)
111
112
  uri = URI.parse(path)
112
113
  if uri.host # a full URL was passed in
113
114
  @host = uri.host
@@ -116,7 +117,7 @@ class Mudbug
116
117
  path = "/#{path}" unless path[0,1] == '/'
117
118
  url = "http://#{@host}#{path}"
118
119
  end
119
- RestClient::Resource.new(url, merge(options))
120
+ RestClient::Resource.new(url, @options)
120
121
  end
121
122
 
122
123
  # no payload
@@ -136,24 +137,11 @@ class Mudbug
136
137
  [:post, :put].each { |meth|
137
138
  define_method(meth) { |path, payload, params = {}|
138
139
  payload = payload.to_json unless payload.is_a?(String)
139
- res = resource(path, content_type: CONTENT[:json][:type])
140
- resp = res.send(meth, payload, params: params)
140
+ res = resource(path)
141
+ resp = res.send(meth, payload,
142
+ content_type: CONTENT[:json][:type],
143
+ params: params)
141
144
  self.class.process(resp, res.headers[:accept])
142
145
  }
143
146
  }
144
-
145
- # a standard merge would throw away @options[:headers][:accept], if
146
- # options[:headers] is provided. Handle nested hashes while still allowing
147
- # @options to be overridden
148
- #
149
- def merge(options)
150
- # gah, let's go ahead and do this for all nested hashes we maintain
151
- result = options.merge({}) # work on a copy, TODO: better way (not dup)
152
- @options.each { |key, hsh|
153
- if result[key] and result[key].is_a?(Hash) and hsh.is_a?(Hash)
154
- result[key] = hsh.merge(result[key])
155
- end
156
- }
157
- result
158
- end
159
147
  end
data/test/mudbug.rb CHANGED
@@ -3,35 +3,8 @@ require 'minitest/autorun'
3
3
 
4
4
  require_relative '../lib/mudbug'
5
5
 
6
- describe "Mudbug#merge" do
7
- it "should maintain 2nd-level nested hash keys" do
8
- m = Mudbug.new
9
- m.options[:headers].must_be_instance_of Hash
10
- m.options[:headers][:accept].must_be_instance_of String
11
- default_accept = m.options[:headers][:accept]
12
-
13
- options = m.merge(headers: {})
14
- options[:headers].must_be_instance_of Hash
15
- options[:headers][:accept].must_equal default_accept
16
-
17
- options = m.merge(headers: { accept: '12345' })
18
- options[:headers].must_be_instance_of Hash
19
- options[:headers][:accept].must_equal '12345'
20
-
21
- distinct = { headers: { xmadeup: '12345' }, max_redirects: 5 }
22
- options = m.merge(distinct)
23
- options[:headers].must_be_instance_of Hash
24
- options[:headers][:accept].must_equal default_accept
25
-
26
- # make sure the outside hash takes precedence
27
- distinct.each { |key, val|
28
- if val.is_a?(Hash)
29
- val.each { |key2, val2|
30
- options[key][key2].must_equal val2
31
- }
32
- else
33
- options[key].must_equal val
34
- end
35
- }
6
+ describe "Mudbug" do
7
+ it "has no tests" do
8
+ skip
36
9
  end
37
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mudbug
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0.1
4
+ version: 0.8.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rick Hull