zephyr 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -6,5 +6,6 @@ gem "typhoeus", ">= 0.2.4"
6
6
  group :development do
7
7
  gem "bundler", "~> 1.0.0"
8
8
  gem "jeweler", "~> 1.6.4"
9
+ gem "shoulda", "~> 2.11.3"
9
10
  end
10
11
 
@@ -8,6 +8,7 @@ GEM
8
8
  rake
9
9
  mime-types (1.16)
10
10
  rake (0.9.2)
11
+ shoulda (2.11.3)
11
12
  typhoeus (0.2.4)
12
13
  mime-types
13
14
  mime-types
@@ -18,4 +19,5 @@ PLATFORMS
18
19
  DEPENDENCIES
19
20
  bundler (~> 1.0.0)
20
21
  jeweler (~> 1.6.4)
22
+ shoulda (~> 2.11.3)
21
23
  typhoeus (>= 0.2.4)
data/Rakefile CHANGED
@@ -42,12 +42,3 @@ end
42
42
 
43
43
  task :default => :test
44
44
 
45
- require 'rake/rdoctask'
46
- Rake::RDocTask.new do |rdoc|
47
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
-
49
- rdoc.rdoc_dir = 'rdoc'
50
- rdoc.title = "zephyr #{version}"
51
- rdoc.rdoc_files.include('README*')
52
- rdoc.rdoc_files.include('lib/**/*.rb')
53
- end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.0.2
@@ -15,20 +15,22 @@
15
15
 
16
16
  # Splits headers into < 8KB chunks
17
17
  # @private
18
- module Net::HTTPHeader
19
- def each_capitalized
20
- # 1.9 check
21
- respond_to?(:enum_for) and (block_given? or return enum_for(__method__))
22
- @header.each do |k,v|
23
- base_length = "#{k}: \r\n".length
24
- values = v.map { |i| i.to_s.split(', ') }.flatten
25
- while !values.empty?
26
- current_line = ""
27
- while values.first && current_line.length + base_length + values.first.length + 2 < 8192
28
- val = values.shift.strip
29
- current_line += current_line.empty? ? val : ", #{val}"
18
+ module Net
19
+ module HTTPHeader
20
+ def each_capitalized
21
+ # 1.9 check
22
+ respond_to?(:enum_for) and (block_given? or return enum_for(__method__))
23
+ @header.each do |k,v|
24
+ base_length = "#{k}: \r\n".length
25
+ values = v.map { |i| i.to_s.split(', ') }.flatten
26
+ while !values.empty?
27
+ current_line = ""
28
+ while values.first && current_line.length + base_length + values.first.length + 2 < 8192
29
+ val = values.shift.strip
30
+ current_line += current_line.empty? ? val : ", #{val}"
31
+ end
32
+ yield capitalize(k), current_line
30
33
  end
31
- yield capitalize(k), current_line
32
34
  end
33
35
  end
34
36
  end
@@ -64,8 +66,6 @@ class Zephyr
64
66
  perform(:head, path_components, headers, expected_statuses, timeout)
65
67
  end
66
68
 
67
- Workfeed::Timer.time_method self, :head, 'http_head'
68
-
69
69
  # Performs a GET request to the specified resource.
70
70
  #
71
71
  # A request to /users/#{@user.id}/things?q=woof with an Accept header of
@@ -83,8 +83,6 @@ class Zephyr
83
83
  perform(:get, path_components, headers, expected_statuses, timeout)
84
84
  end
85
85
 
86
- Workfeed::Timer.time_method self, :get, 'http_get'
87
-
88
86
  # The same thing as #get, but decodes the response entity as JSON (if it's
89
87
  # application/json) and adds it under the :json key in the returned hash.
90
88
  def get_json(expected_statuses, timeout, path_components, headers={}, yajl_opts={})
@@ -118,8 +116,6 @@ class Zephyr
118
116
  perform(:put, path_components, headers, expected_statuses, timeout, entity)
119
117
  end
120
118
 
121
- Workfeed::Timer.time_method self, :put, 'http_put'
122
-
123
119
  # The same thing as #put, but encodes the entity as JSON and specifies
124
120
  # "application/json" as the request entity content type.
125
121
  def put_json(expected_statuses, timeout, path_components, entity, headers={})
@@ -144,8 +140,6 @@ class Zephyr
144
140
  perform(:post, path_components, headers, expected_statuses, timeout, entity)
145
141
  end
146
142
 
147
- Workfeed::Timer.time_method self, :post, 'http_post'
148
-
149
143
  # The same thing as #post, but encodes the entity as JSON and specifies
150
144
  # "application/json" as the request entity content type.
151
145
  def post_json(expected_statuses, timeout, path_components, entity, headers={})
@@ -175,8 +169,6 @@ class Zephyr
175
169
  perform(:delete, path_components, headers, expected_statuses, timeout)
176
170
  end
177
171
 
178
- Workfeed::Timer.time_method self, :delete, 'http_delete'
179
-
180
172
  # Creates a URI object, combining the root_uri passed on initialization
181
173
  # with the given parts.
182
174
  #
@@ -9,6 +9,7 @@ rescue Bundler::BundlerError => e
9
9
  end
10
10
  require 'test/unit'
11
11
  require 'shoulda'
12
+ require 'typhoeus'
12
13
 
13
14
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
15
  $LOAD_PATH.unshift(File.dirname(__FILE__))
@@ -1,7 +1,78 @@
1
1
  require 'helper'
2
2
 
3
3
  class TestZephyr < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
4
+
5
+ context "urls" do
6
+ should "be canonicalized" do
7
+ assert_equal 'http://example.com/', Zephyr.new('http://example.com').uri.to_s
8
+ assert_equal 'http://example.com/', Zephyr.new('http://example.com/').uri.to_s
9
+ assert_equal 'http://example.com/', Zephyr.new('http://example.com//').uri.to_s
10
+ end
11
+ end
12
+
13
+ context "query string parameters" do
14
+ should "be sorted" do
15
+ zephyr = Zephyr.new
16
+ duples = ('a'..'z').zip('A'..'Z') # [ [ 'a', 'A' ], [ 'b', 'B' ], ... ]
17
+ expected = duples.map { |l,u| '%s=%s' % [ l, u ] }.sort.join('&')
18
+
19
+ assert_equal expected, zephyr.build_query_string(Hash[duples.shuffle])
20
+ end
21
+
22
+ should "be constructed for arrays" do
23
+ zephyr = Zephyr.new
24
+ assert_equal 'a=1&a=2', zephyr.build_query_string(:a => [ 2, 1 ])
25
+ end
26
+ end
27
+
28
+ context "percent encoding" do
29
+ should "be correct" do
30
+ zephyr = Zephyr.new
31
+
32
+ # RFC 3986 Reserved Characters
33
+ assert_equal '%21', zephyr.percent_encode('!')
34
+ assert_equal '%2A', zephyr.percent_encode('*')
35
+ assert_equal '%27', zephyr.percent_encode("'")
36
+ assert_equal '%28', zephyr.percent_encode('(')
37
+ assert_equal '%29', zephyr.percent_encode(')')
38
+ assert_equal '%3B', zephyr.percent_encode(';')
39
+ assert_equal '%3A', zephyr.percent_encode(':')
40
+ assert_equal '%40', zephyr.percent_encode('@')
41
+ assert_equal '%26', zephyr.percent_encode('&')
42
+ assert_equal '%3D', zephyr.percent_encode('=')
43
+ assert_equal '%2B', zephyr.percent_encode('+')
44
+ assert_equal '%24', zephyr.percent_encode('$')
45
+ assert_equal '%2C', zephyr.percent_encode(',')
46
+ assert_equal '%2F', zephyr.percent_encode('/')
47
+ assert_equal '%3F', zephyr.percent_encode('?')
48
+ assert_equal '%23', zephyr.percent_encode('#')
49
+ assert_equal '%5B', zephyr.percent_encode('[')
50
+ assert_equal '%5D', zephyr.percent_encode(']')
51
+
52
+ # Common Percent Encodings
53
+ assert_equal '%3C', zephyr.percent_encode('<')
54
+ assert_equal '%3E', zephyr.percent_encode('>')
55
+ assert_equal '%22', zephyr.percent_encode('"')
56
+ assert_equal '%7B', zephyr.percent_encode('{')
57
+ assert_equal '%7D', zephyr.percent_encode('}')
58
+ assert_equal '%7C', zephyr.percent_encode('|')
59
+ assert_equal '%5C', zephyr.percent_encode('\\')
60
+ assert_equal '%60', zephyr.percent_encode('`')
61
+ assert_equal '%5E', zephyr.percent_encode('^')
62
+ assert_equal '%25', zephyr.percent_encode('%')
63
+ assert_equal '%20', zephyr.percent_encode(' ')
64
+
65
+ # Should test for \n as %0A or %0D or %0D%0A
66
+ assert_contains ['%0A', '%0D', '%0D%0A'], zephyr.percent_encode("\n")
67
+
68
+ # Should figure out why the will not be percent encoded by libcurl
69
+ #assert_equal '%2E', zephyr.percent_encode('.')
70
+ #assert_equal '%2D', zephyr.percent_encode('-')
71
+ #assert_equal '%5F', zephyr.percent_encode('_')
72
+ #assert_equal '%7E', zephyr.percent_encode('~')
73
+
74
+ # Fancy
75
+ assert_equal '%E3%81%BE%E3%81%A4%E3%82%82%E3%81%A8', zephyr.percent_encode('まつもと')
76
+ end
6
77
  end
7
78
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{zephyr}
8
- s.version = "1.0.1"
8
+ s.version = "1.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Knopp"]
12
- s.date = %q{2011-09-30}
12
+ s.date = %q{2011-10-03}
13
13
  s.description = %q{Simple HTTP client using Typheous, derived from the Riak client}
14
14
  s.email = %q{matt.knopp@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -42,15 +42,18 @@ Gem::Specification.new do |s|
42
42
  s.add_runtime_dependency(%q<typhoeus>, [">= 0.2.4"])
43
43
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
44
44
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
45
+ s.add_development_dependency(%q<shoulda>, ["~> 2.11.3"])
45
46
  else
46
47
  s.add_dependency(%q<typhoeus>, [">= 0.2.4"])
47
48
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
48
49
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
50
+ s.add_dependency(%q<shoulda>, ["~> 2.11.3"])
49
51
  end
50
52
  else
51
53
  s.add_dependency(%q<typhoeus>, [">= 0.2.4"])
52
54
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
53
55
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
56
+ s.add_dependency(%q<shoulda>, ["~> 2.11.3"])
54
57
  end
55
58
  end
56
59
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zephyr
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
9
+ - 2
10
+ version: 1.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Knopp
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-30 00:00:00 -07:00
18
+ date: 2011-10-03 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -66,6 +66,22 @@ dependencies:
66
66
  prerelease: false
67
67
  type: :development
68
68
  requirement: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: shoulda
71
+ version_requirements: &id004 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ hash: 37
77
+ segments:
78
+ - 2
79
+ - 11
80
+ - 3
81
+ version: 2.11.3
82
+ prerelease: false
83
+ type: :development
84
+ requirement: *id004
69
85
  description: Simple HTTP client using Typheous, derived from the Riak client
70
86
  email: matt.knopp@gmail.com
71
87
  executables: []