httparty 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of httparty might be problematic. Click here for more details.

data/History CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.4.2 209-03-30
2
+ * 2 minor changes
3
+ * response code now returns an integer instead of a string (jqr)
4
+ * rubyforge project setup for crack so i'm now depending on that instead of jnunemaker-crack
5
+
1
6
  == 0.4.1 2009-03-29
2
7
  * 1 minor fix
3
8
  * gem 'jnunemaker-crack' instead of gem 'crack'
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ Echoe.new(ProjectName, HTTParty::Version) do |p|
14
14
  p.url = "http://#{ProjectName}.rubyforge.org"
15
15
  p.author = "John Nunemaker"
16
16
  p.email = "nunemaker@gmail.com"
17
- p.extra_deps = [['jnunemaker-crack', '>= 0.1.0']]
17
+ p.extra_deps = [['crack', '>= 0.1.1']]
18
18
  p.need_tar_gz = false
19
19
  p.docs_host = WebsitePath
20
20
  end
@@ -17,7 +17,7 @@ Then /it should return a Hash equaling:/ do |hash_table|
17
17
  end
18
18
 
19
19
  Then /it should return a response with a (\d+) response code/ do |code|
20
- @response_from_httparty.code.should eql(code)
20
+ @response_from_httparty.code.should eql(code.to_i)
21
21
  end
22
22
 
23
23
  Then /it should raise an HTTParty::RedirectionTooDeep exception/ do
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{httparty}
5
- s.version = "0.4.1"
5
+ s.version = "0.4.2"
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-03-29}
9
+ s.date = %q{2009-04-02}
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}
@@ -27,14 +27,14 @@ Gem::Specification.new do |s|
27
27
  s.specification_version = 2
28
28
 
29
29
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
30
- s.add_runtime_dependency(%q<jnunemaker-crack>, [">= 0.1.0"])
30
+ s.add_runtime_dependency(%q<crack>, [">= 0.1.1"])
31
31
  s.add_development_dependency(%q<echoe>, [">= 0"])
32
32
  else
33
- s.add_dependency(%q<jnunemaker-crack>, [">= 0.1.0"])
33
+ s.add_dependency(%q<crack>, [">= 0.1.1"])
34
34
  s.add_dependency(%q<echoe>, [">= 0"])
35
35
  end
36
36
  else
37
- s.add_dependency(%q<jnunemaker-crack>, [">= 0.1.0"])
37
+ s.add_dependency(%q<crack>, [">= 0.1.1"])
38
38
  s.add_dependency(%q<echoe>, [">= 0"])
39
39
  end
40
40
  end
@@ -4,7 +4,7 @@ require 'net/http'
4
4
  require 'net/https'
5
5
  require 'httparty/module_inheritable_attributes'
6
6
  require 'rubygems'
7
- gem 'jnunemaker-crack'
7
+ gem 'crack'
8
8
  require 'crack'
9
9
 
10
10
  module HTTParty
@@ -18,7 +18,8 @@ module HTTParty
18
18
  'text/javascript' => :json,
19
19
  'text/html' => :html,
20
20
  'application/x-yaml' => :yaml,
21
- 'text/yaml' => :yaml
21
+ 'text/yaml' => :yaml,
22
+ 'text/plain' => :plain
22
23
  } unless defined?(AllowedFormats)
23
24
 
24
25
  def self.included(base)
@@ -101,7 +102,7 @@ module HTTParty
101
102
  # format :json
102
103
  # end
103
104
  def format(f)
104
- raise UnsupportedFormat, "Must be one of: #{AllowedFormats.values.join(', ')}" unless AllowedFormats.value?(f)
105
+ raise UnsupportedFormat, "Must be one of: #{AllowedFormats.values.uniq.join(', ')}" unless AllowedFormats.value?(f)
105
106
  default_options[:format] = f
106
107
  end
107
108
 
@@ -166,13 +167,14 @@ module HTTParty
166
167
  end
167
168
 
168
169
  def self.normalize_base_uri(url) #:nodoc:
169
- use_ssl = (url =~ /^https/) || url.include?(':443')
170
- ends_with_slash = url =~ /\/$/
170
+ normalized_url = url.dup
171
+ use_ssl = (normalized_url =~ /^https/) || normalized_url.include?(':443')
172
+ ends_with_slash = normalized_url =~ /\/$/
171
173
 
172
- url.chop! if ends_with_slash
173
- url.gsub!(/^https?:\/\//i, '')
174
+ normalized_url.chop! if ends_with_slash
175
+ normalized_url.gsub!(/^https?:\/\//i, '')
174
176
 
175
- "http#{'s' if use_ssl}://#{url}"
177
+ "http#{'s' if use_ssl}://#{normalized_url}"
176
178
  end
177
179
 
178
180
  class Basement #:nodoc:
@@ -6,7 +6,7 @@ module HTTParty
6
6
  def initialize(delegate, body, code, headers={})
7
7
  @delegate = delegate
8
8
  @body = body
9
- @code = code
9
+ @code = code.to_i
10
10
  @headers = headers
11
11
  end
12
12
 
@@ -1,3 +1,3 @@
1
1
  module HTTParty #:nodoc:
2
- Version = '0.4.1'
2
+ Version = '0.4.2'
3
3
  end
@@ -5,7 +5,7 @@ describe HTTParty::Response do
5
5
  before do
6
6
  @response_object = {'foo' => 'bar'}
7
7
  @body = "{foo:'bar'}"
8
- @code = 200
8
+ @code = '200'
9
9
  @response = HTTParty::Response.new(@response_object, @body, @code)
10
10
  end
11
11
 
@@ -18,7 +18,11 @@ describe HTTParty::Response do
18
18
  end
19
19
 
20
20
  it "should set code" do
21
- @response.code.should == @code
21
+ @response.code.should.to_s == @code
22
+ end
23
+
24
+ it "should set code as a Fixnum" do
25
+ @response.code.should be_an_instance_of(Fixnum)
22
26
  end
23
27
  end
24
28
 
@@ -19,6 +19,12 @@ describe HTTParty do
19
19
  @klass.base_uri('http://api.foobar.com')
20
20
  @klass.base_uri.should == 'http://api.foobar.com'
21
21
  end
22
+
23
+ it 'should not modify the parameter during assignment' do
24
+ uri = 'http://api.foobar.com'
25
+ @klass.base_uri(uri)
26
+ uri.should == 'http://api.foobar.com'
27
+ end
22
28
  end
23
29
 
24
30
  describe "#normalize_base_uri" do
@@ -36,6 +42,12 @@ describe HTTParty do
36
42
  uri = HTTParty.normalize_base_uri('https://api.foo.com/v1:443')
37
43
  uri.should == 'https://api.foo.com/v1:443'
38
44
  end
45
+
46
+ it 'should not modify the parameter' do
47
+ uri = 'http://api.foobar.com'
48
+ HTTParty.normalize_base_uri(uri)
49
+ uri.should == 'http://api.foobar.com'
50
+ end
39
51
  end
40
52
 
41
53
  describe "headers" do
@@ -149,11 +161,23 @@ describe HTTParty do
149
161
  @klass.default_options[:format].should == :yaml
150
162
  end
151
163
 
164
+ it "should allow plain" do
165
+ @klass.format :plain
166
+ @klass.default_options[:format].should == :plain
167
+ end
168
+
152
169
  it 'should not allow funky format' do
153
170
  lambda do
154
171
  @klass.format :foobar
155
172
  end.should raise_error(HTTParty::UnsupportedFormat)
156
173
  end
174
+
175
+ it 'should only print each format once with an exception' do
176
+ lambda do
177
+ @klass.format :foobar
178
+ end.should raise_error(HTTParty::UnsupportedFormat, "Must be one of: json, plain, html, yaml, xml")
179
+ end
180
+
157
181
  end
158
182
 
159
183
  describe "with explicit override of automatic redirect handling" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httparty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
@@ -9,18 +9,18 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-29 00:00:00 -04:00
12
+ date: 2009-04-02 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: jnunemaker-crack
16
+ name: crack
17
17
  type: :runtime
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.1.0
23
+ version: 0.1.1
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: echoe