jnunemaker-httparty 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History +5 -1
- data/examples/basic.rb +2 -2
- data/httparty.gemspec +2 -2
- data/lib/httparty/request.rb +1 -1
- data/lib/httparty/response.rb +3 -2
- data/lib/httparty/version.rb +1 -1
- data/spec/httparty/response_spec.rb +11 -6
- metadata +2 -2
data/History
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
== 0.4.
|
1
|
+
== 0.4.5 2009-04-23
|
2
|
+
* 1 minor update
|
3
|
+
* added message to the response object
|
4
|
+
|
5
|
+
== 0.4.2 2009-03-30
|
2
6
|
* 2 minor changes
|
3
7
|
* response code now returns an integer instead of a string (jqr)
|
4
8
|
* rubyforge project setup for crack so i'm now depending on that instead of jnunemaker-crack
|
data/examples/basic.rb
CHANGED
@@ -4,8 +4,8 @@ require 'pp'
|
|
4
4
|
|
5
5
|
# You can also use post, put, delete in the same fashion
|
6
6
|
response = HTTParty.get('http://twitter.com/statuses/public_timeline.json')
|
7
|
-
puts response.body, response.code, response.headers.inspect
|
7
|
+
puts response.body, response.code, response.message, response.headers.inspect
|
8
8
|
|
9
9
|
response.each do |item|
|
10
10
|
puts item['user']['screen_name']
|
11
|
-
end
|
11
|
+
end
|
data/httparty.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{httparty}
|
5
|
-
s.version = "0.4.
|
5
|
+
s.version = "0.4.3"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["John Nunemaker"]
|
9
|
-
s.date = %q{2009-04-
|
9
|
+
s.date = %q{2009-04-23}
|
10
10
|
s.default_executable = %q{httparty}
|
11
11
|
s.description = %q{Makes http fun! Also, makes consuming restful web services dead easy.}
|
12
12
|
s.email = %q{nunemaker@gmail.com}
|
data/lib/httparty/request.rb
CHANGED
@@ -99,7 +99,7 @@ module HTTParty
|
|
99
99
|
perform
|
100
100
|
else
|
101
101
|
parsed_response = parse_response(response.body)
|
102
|
-
Response.new(parsed_response, response.body, response.code, response.to_hash)
|
102
|
+
Response.new(parsed_response, response.body, response.code, response.message, response.to_hash)
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
data/lib/httparty/response.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
module HTTParty
|
2
2
|
class Response < BlankSlate #:nodoc:
|
3
|
-
attr_accessor :body, :code, :headers
|
3
|
+
attr_accessor :body, :code, :message, :headers
|
4
4
|
attr_reader :delegate
|
5
5
|
|
6
|
-
def initialize(delegate, body, code, headers={})
|
6
|
+
def initialize(delegate, body, code, message, headers={})
|
7
7
|
@delegate = delegate
|
8
8
|
@body = body
|
9
9
|
@code = code.to_i
|
10
|
+
@message = message
|
10
11
|
@headers = headers
|
11
12
|
end
|
12
13
|
|
data/lib/httparty/version.rb
CHANGED
@@ -6,7 +6,8 @@ describe HTTParty::Response do
|
|
6
6
|
@response_object = {'foo' => 'bar'}
|
7
7
|
@body = "{foo:'bar'}"
|
8
8
|
@code = '200'
|
9
|
-
@
|
9
|
+
@message = 'OK'
|
10
|
+
@response = HTTParty::Response.new(@response_object, @body, @code, @message)
|
10
11
|
end
|
11
12
|
|
12
13
|
it "should set delegate" do
|
@@ -24,20 +25,24 @@ describe HTTParty::Response do
|
|
24
25
|
it "should set code as a Fixnum" do
|
25
26
|
@response.code.should be_an_instance_of(Fixnum)
|
26
27
|
end
|
28
|
+
|
29
|
+
it "should set body" do
|
30
|
+
@response.body.should == @body
|
31
|
+
end
|
27
32
|
end
|
28
33
|
|
29
34
|
it "should be able to set headers during initialization" do
|
30
|
-
response = HTTParty::Response.new({'foo' => 'bar'}, "{foo:'bar'}", 200, {'foo' => 'bar'})
|
35
|
+
response = HTTParty::Response.new({'foo' => 'bar'}, "{foo:'bar'}", 200, 'OK', {'foo' => 'bar'})
|
31
36
|
response.headers.should == {'foo' => 'bar'}
|
32
37
|
end
|
33
38
|
|
34
39
|
it "should send missing methods to delegate" do
|
35
|
-
response = HTTParty::Response.new({'foo' => 'bar'}, "{foo:'bar'}", 200)
|
40
|
+
response = HTTParty::Response.new({'foo' => 'bar'}, "{foo:'bar'}", 200, 'OK')
|
36
41
|
response['foo'].should == 'bar'
|
37
42
|
end
|
38
43
|
|
39
44
|
it "should be able to iterate delegate if it is array" do
|
40
|
-
response = HTTParty::Response.new([{'foo' => 'bar'}, {'foo' => 'baz'}], "[{foo:'bar'}, {foo:'baz'}]", 200)
|
45
|
+
response = HTTParty::Response.new([{'foo' => 'bar'}, {'foo' => 'baz'}], "[{foo:'bar'}, {foo:'baz'}]", 200, 'OK')
|
41
46
|
response.size.should == 2
|
42
47
|
lambda {
|
43
48
|
response.each { |item| }
|
@@ -45,12 +50,12 @@ describe HTTParty::Response do
|
|
45
50
|
end
|
46
51
|
|
47
52
|
xit "should allow hashes to be accessed with dot notation" do
|
48
|
-
response = HTTParty::Response.new({'foo' => 'bar'}, "{foo:'bar'}", 200)
|
53
|
+
response = HTTParty::Response.new({'foo' => 'bar'}, "{foo:'bar'}", 200, 'OK')
|
49
54
|
response.foo.should == 'bar'
|
50
55
|
end
|
51
56
|
|
52
57
|
xit "should allow nested hashes to be accessed with dot notation" do
|
53
|
-
response = HTTParty::Response.new({'foo' => {'bar' => 'baz'}}, "{foo: {bar:'baz'}}", 200)
|
58
|
+
response = HTTParty::Response.new({'foo' => {'bar' => 'baz'}}, "{foo: {bar:'baz'}}", 200, 'OK')
|
54
59
|
response.foo.should == {'bar' => 'baz'}
|
55
60
|
response.foo.bar.should == 'baz'
|
56
61
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jnunemaker-httparty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Nunemaker
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-04-
|
12
|
+
date: 2009-04-23 00:00:00 -07:00
|
13
13
|
default_executable: httparty
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|