excon 0.5.5 → 0.5.6

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

Potentially problematic release.


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

data/Rakefile CHANGED
@@ -43,14 +43,10 @@ end
43
43
  #
44
44
  #############################################################################
45
45
 
46
- task :default => :test
46
+ require 'shindo/rake'
47
+ Shindo::Rake.new
47
48
 
48
- require 'rake/testtask'
49
- Rake::TestTask.new(:test) do |test|
50
- test.libs << 'lib' << 'tests'
51
- test.pattern = 'tests/**/test_*.rb'
52
- test.verbose = true
53
- end
49
+ task :default => :tests
54
50
 
55
51
  desc "Generate RCov test coverage and open in your browser"
56
52
  task :coverage do
@@ -0,0 +1,27 @@
1
+ require 'rubygems'
2
+ require 'tach'
3
+
4
+ data = ["some", "var", "goes", "in", :here, 0]
5
+ Tach.meter(1_000_000) do
6
+ tach('for') do
7
+ for element in data
8
+ element == nil
9
+ end
10
+ end
11
+ tach('each') do
12
+ data.each do |element|
13
+ element == nil
14
+ end
15
+ end
16
+ end
17
+
18
+ # ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
19
+ #
20
+ # +------+----------+
21
+ # | tach | total |
22
+ # +------+----------+
23
+ # | for | 2.958672 |
24
+ # +------+----------+
25
+ # | each | 2.983550 |
26
+ # +------+----------+
27
+ #
@@ -0,0 +1,27 @@
1
+ require 'rubygems'
2
+ require 'tach'
3
+
4
+ data = {"some" => "var", "goes" => "in", :here => 0}
5
+ Tach.meter(1_000_000) do
6
+ tach('for') do
7
+ for key, values in data
8
+ key == values
9
+ end
10
+ end
11
+ tach('each') do
12
+ data.each do |key, values|
13
+ key == values
14
+ end
15
+ end
16
+ end
17
+
18
+ # ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
19
+ #
20
+ # +------+----------+
21
+ # | tach | total |
22
+ # +------+----------+
23
+ # | each | 2.748909 |
24
+ # +------+----------+
25
+ # | for | 2.949512 |
26
+ # +------+----------+
27
+ #
data/changelog.txt CHANGED
@@ -1,3 +1,11 @@
1
+ 0.5.6 02/19/11
2
+ ==============
3
+
4
+ * only split headers by first ':' to allow for values with ':'. Thanks mtodd!
5
+ * check a string instance for force_encoding, not class. Thanks seancribbs!
6
+ * add benchmarks related to for vs each for enumerable. Thanks caius!
7
+ * fix default rake task to run tests
8
+
1
9
  0.5.5 02/18/11
2
10
  ==============
3
11
 
data/excon.gemspec CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'excon'
16
- s.version = '0.5.5'
17
- s.date = '2011-02-18'
16
+ s.version = '0.5.6'
17
+ s.date = '2011-02-19'
18
18
  s.rubyforge_project = 'excon'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
@@ -54,6 +54,7 @@ Gem::Specification.new do |s|
54
54
  ## those that are only needed during development
55
55
  # s.add_development_dependency('DEVDEPNAME', [">= 1.1.0", "< 2.0.0"])
56
56
  s.add_development_dependency('open4')
57
+ s.add_development_dependency('rake')
57
58
  s.add_development_dependency('shindo', '0.2.0')
58
59
  s.add_development_dependency('sinatra')
59
60
 
@@ -72,6 +73,8 @@ Gem::Specification.new do |s|
72
73
  benchmarks/cr_lf.rb
73
74
  benchmarks/downcase-eq-eq_vs_casecmp.rb
74
75
  benchmarks/excon_vs.rb
76
+ benchmarks/for_vs_array_each.rb
77
+ benchmarks/for_vs_hash_each.rb
75
78
  benchmarks/has_key-vs-hash[key].rb
76
79
  benchmarks/headers_case_sensitivity.rb
77
80
  benchmarks/headers_split_vs_match.rb
data/lib/excon.rb CHANGED
@@ -13,7 +13,7 @@ require 'excon/response'
13
13
 
14
14
  module Excon
15
15
  unless const_defined?(:VERSION)
16
- VERSION = '0.5.5'
16
+ VERSION = '0.5.6'
17
17
  end
18
18
 
19
19
  unless const_defined?(:CHUNK_SIZE)
@@ -4,7 +4,7 @@ module Excon
4
4
 
5
5
  CR_NL = "\r\n"
6
6
  HTTP_1_1 = " HTTP/1.1\r\n"
7
- FORCE_ENC = String.respond_to?(:force_encoding)
7
+ FORCE_ENC = CR_NL.respond_to?(:force_encoding)
8
8
 
9
9
  # Initializes a new Connection instance
10
10
  # @param [String] url The destination URL
@@ -67,7 +67,7 @@ module Excon
67
67
  when nil
68
68
  request << key.to_s << '&'
69
69
  when Array
70
- for value in values
70
+ values.each do |value|
71
71
  request << key.to_s << '=' << CGI.escape(value.to_s) << '&'
72
72
  end
73
73
  else
@@ -13,7 +13,7 @@ module Excon
13
13
  block_given = block_given?
14
14
 
15
15
  until ((data = socket.readline).chop!).empty?
16
- key, value = data.split(': ')
16
+ key, value = data.split(': ', 2)
17
17
  response.headers[key] = value
18
18
  if key.casecmp('Content-Length') == 0
19
19
  content_length = value.to_i
data/tests/basic_tests.rb CHANGED
@@ -23,14 +23,18 @@ with_rackup('basic.ru') do
23
23
  response.headers['Content-Type']
24
24
  end
25
25
 
26
- test("Time.parse(response.headers['Date']).is_a?(Time)") do
26
+ tests("Time.parse(response.headers['Date']).is_a?(Time)") do
27
27
  Time.parse(response.headers['Date']).is_a?(Time)
28
28
  end
29
29
 
30
- test("!!(response.headers['Server'] =~ /^WEBrick/)") do
30
+ tests("!!(response.headers['Server'] =~ /^WEBrick/)") do
31
31
  !!(response.headers['Server'] =~ /^WEBrick/)
32
32
  end
33
33
 
34
+ tests("response.headers['Custom']").returns("Foo: bar") do
35
+ response.headers['Custom']
36
+ end
37
+
34
38
  tests("response.body").returns('x' * 100) do
35
39
  response.body
36
40
  end
@@ -2,6 +2,7 @@ require 'sinatra'
2
2
 
3
3
  class App < Sinatra::Base
4
4
  get '/content-length/:value' do |value|
5
+ headers "Custom" => "Foo: bar"
5
6
  'x' * value.to_i
6
7
  end
7
8
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: excon
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 5
10
- version: 0.5.5
9
+ - 6
10
+ version: 0.5.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - geemus (Wesley Beary)
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-18 00:00:00 -08:00
18
+ date: 2011-02-19 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -33,9 +33,23 @@ dependencies:
33
33
  type: :development
34
34
  version_requirements: *id001
35
35
  - !ruby/object:Gem::Dependency
36
- name: shindo
36
+ name: rake
37
37
  prerelease: false
38
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :development
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: shindo
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
39
53
  none: false
40
54
  requirements:
41
55
  - - "="
@@ -47,11 +61,11 @@ dependencies:
47
61
  - 0
48
62
  version: 0.2.0
49
63
  type: :development
50
- version_requirements: *id002
64
+ version_requirements: *id003
51
65
  - !ruby/object:Gem::Dependency
52
66
  name: sinatra
53
67
  prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
68
+ requirement: &id004 !ruby/object:Gem::Requirement
55
69
  none: false
56
70
  requirements:
57
71
  - - ">="
@@ -61,7 +75,7 @@ dependencies:
61
75
  - 0
62
76
  version: "0"
63
77
  type: :development
64
- version_requirements: *id003
78
+ version_requirements: *id004
65
79
  description: EXtended http(s) CONnections
66
80
  email: geemus@gmail.com
67
81
  executables: []
@@ -81,6 +95,8 @@ files:
81
95
  - benchmarks/cr_lf.rb
82
96
  - benchmarks/downcase-eq-eq_vs_casecmp.rb
83
97
  - benchmarks/excon_vs.rb
98
+ - benchmarks/for_vs_array_each.rb
99
+ - benchmarks/for_vs_hash_each.rb
84
100
  - benchmarks/has_key-vs-hash[key].rb
85
101
  - benchmarks/headers_case_sensitivity.rb
86
102
  - benchmarks/headers_split_vs_match.rb
@@ -130,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
146
  requirements: []
131
147
 
132
148
  rubyforge_project: excon
133
- rubygems_version: 1.4.1
149
+ rubygems_version: 1.4.2
134
150
  signing_key:
135
151
  specification_version: 2
136
152
  summary: speed, persistence, http(s)