transport 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,50 +1,13 @@
1
- require 'rubygems'
2
-
3
- gem 'rspec'
4
- require 'rspec'
1
+ require 'bundler/gem_tasks'
5
2
  require 'rspec/core/rake_task'
6
-
7
- gem 'reek'
8
3
  require 'reek/rake/task'
4
+ require 'rdoc/task'
9
5
 
10
- require 'rake/rdoctask'
6
+ RSpec::Core::RakeTask.new(:spec)
7
+ Rake::RDocTask.new(:spec)
11
8
 
12
9
  task :default => :spec
13
10
 
14
- namespace :gem do
15
-
16
- desc "Builds the gem"
17
- task :build do
18
- system "gem build *.gemspec && mkdir -p pkg/ && mv *.gem pkg/"
19
- end
20
-
21
- desc "Builds and installs the gem"
22
- task :install => :build do
23
- system "gem install pkg/"
24
- end
25
-
26
- end
27
-
28
- Reek::Rake::Task.new do |task|
29
- task.fail_on_error = true
30
- end
31
-
32
- desc "Generate the rdoc"
33
- Rake::RDocTask.new do |rdoc|
34
- rdoc.rdoc_files.add [ "README.rdoc", "lib/**/*.rb" ]
35
- rdoc.main = "README.rdoc"
36
- end
37
-
38
- desc "Run all specs in spec directory"
39
- RSpec::Core::RakeTask.new do |task|
40
- task.pattern = "spec/lib/**/*_spec.rb"
41
- end
42
-
43
- namespace :spec do
44
-
45
- desc "Run all integration specs in spec/acceptance directory"
46
- RSpec::Core::RakeTask.new(:acceptance) do |task|
47
- task.pattern = "spec/acceptance/**/*_spec.rb"
48
- end
49
-
11
+ Reek::Rake::Task.new do |t|
12
+ t.fail_on_error = false
50
13
  end
@@ -19,7 +19,8 @@ module Transport
19
19
  private
20
20
 
21
21
  def perform_request
22
- @http_response = Net::HTTP.start(@uri.host, @uri.port) do |connection|
22
+ use_ssl = @uri.scheme == 'https'
23
+ @http_response = Net::HTTP.start(@uri.host, @uri.port, nil, nil, nil, nil, :use_ssl => use_ssl) do |connection|
23
24
  connection.request @request
24
25
  end
25
26
  @response = @http_response.body
@@ -34,8 +34,10 @@ module Transport
34
34
  uri = URI.parse @url
35
35
  generate_query
36
36
  @request_path = uri.path
37
- @request_path += "/" if @request_path == ""
38
- @request_path += "?" + @query if HTTP_METHODS_WITH_PARAMETERS.include?(@http_method.to_sym) && @query
37
+ @request_path << "/" if @request_path == ""
38
+ query = uri.query || ''
39
+ query << @query if HTTP_METHODS_WITH_PARAMETERS.include?(@http_method.to_sym) && @query
40
+ @request_path << "?" << query unless query.empty?
39
41
  end
40
42
 
41
43
  def initialize_request
@@ -5,7 +5,7 @@ require 'logger'
5
5
  describe Transport::HTTP do
6
6
 
7
7
  before :each do
8
- @uri = mock URI, :host => "host", :port => 1234
8
+ @uri = mock URI, :host => "host", :port => 1234, :scheme => "http"
9
9
  @request = mock Net::HTTPRequest, :path => "/path"
10
10
  @logger = mock ::Logger, :info => nil
11
11
  @options = { :expected_status_code => 200, :logger => @logger }
@@ -21,9 +21,22 @@ describe Transport::HTTP do
21
21
 
22
22
  describe "perform" do
23
23
 
24
- it "should perform the request" do
25
- Net::HTTP.should_receive(:start).with("host", 1234).and_return(@response)
26
- @transport.perform
24
+ context "when using HTTP scheme" do
25
+ it "should perform the request" do
26
+ Net::HTTP.should_receive(:start).with("host", 1234, nil, nil, nil, nil, { :use_ssl => false }).and_return(@response)
27
+ @transport.perform
28
+ end
29
+ end
30
+
31
+ context "when HTTPS scheme" do
32
+ before :each do
33
+ https_uri = mock URI, :host => "host", :port => 1234, :scheme => "https"
34
+ @transport = described_class.new https_uri, @request, @options
35
+ end
36
+ it "should perform the request" do
37
+ Net::HTTP.should_receive(:start).with("host", 1234, nil, nil, nil, nil, { :use_ssl => true }).and_return(@response)
38
+ @transport.perform
39
+ end
27
40
  end
28
41
 
29
42
  it "should initialize the formatter" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transport
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,30 +9,72 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-18 00:00:00.000000000Z
12
+ date: 2013-03-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &23192160 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ! '>='
19
+ - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '2'
21
+ version: '2.12'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *23192160
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '2.12'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: reek
27
- requirement: &23191420 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.3'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.3'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '10.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
28
57
  none: false
29
58
  requirements:
30
- - - ! '>='
59
+ - - ~>
31
60
  - !ruby/object:Gem::Version
32
- version: '1.2'
61
+ version: '10.0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rdoc
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '3.0'
33
70
  type: :development
34
71
  prerelease: false
35
- version_requirements: *23191420
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '3.0'
36
78
  description: Provide a single command interface to perform http/json requests. A spec
37
79
  helper to perform request against a fake server is also included.
38
80
  email: b.phifty@gmail.com
@@ -44,33 +86,33 @@ files:
44
86
  - README.rdoc
45
87
  - LICENSE
46
88
  - Rakefile
47
- - lib/transport.rb
89
+ - lib/transport/common/request_builder.rb
90
+ - lib/transport/json.rb
91
+ - lib/transport/http/request_builder/parameter_serializer.rb
92
+ - lib/transport/http/request_builder.rb
93
+ - lib/transport/http/formatter.rb
94
+ - lib/transport/spec.rb
48
95
  - lib/transport/json/request_builder.rb
49
96
  - lib/transport/json/response_parser.rb
50
97
  - lib/transport/common.rb
51
- - lib/transport/http.rb
52
- - lib/transport/common/request_builder.rb
53
- - lib/transport/http/formatter.rb
54
- - lib/transport/http/request_builder.rb
55
- - lib/transport/http/request_builder/parameter_serializer.rb
56
98
  - lib/transport/unexpected_status_code_error.rb
57
- - lib/transport/spec.rb
99
+ - lib/transport/http.rb
58
100
  - lib/transport/spec/faker.rb
59
- - lib/transport/json.rb
101
+ - lib/transport.rb
102
+ - spec/acceptance/json_spec.rb
103
+ - spec/acceptance/http_spec.rb
104
+ - spec/lib/transport/json_spec.rb
105
+ - spec/lib/transport/common/request_builder_spec.rb
60
106
  - spec/lib/transport/unexpected_status_code_error_spec.rb
107
+ - spec/lib/transport/http/request_builder_spec.rb
108
+ - spec/lib/transport/http/request_builder/parameter_serializer_spec.rb
109
+ - spec/lib/transport/http/formatter_spec.rb
61
110
  - spec/lib/transport/json/request_builder_spec.rb
62
111
  - spec/lib/transport/json/response_parser_spec.rb
63
112
  - spec/lib/transport/http_spec.rb
64
113
  - spec/lib/transport/common_spec.rb
65
- - spec/lib/transport/common/request_builder_spec.rb
66
- - spec/lib/transport/http/request_builder_spec.rb
67
- - spec/lib/transport/http/request_builder/parameter_serializer_spec.rb
68
- - spec/lib/transport/http/formatter_spec.rb
69
- - spec/lib/transport/json_spec.rb
70
114
  - spec/lib/transport/spec/faker_spec.rb
71
115
  - spec/spec_helper.rb
72
- - spec/acceptance/http_spec.rb
73
- - spec/acceptance/json_spec.rb
74
116
  homepage: http://github.com/phifty/transport
75
117
  licenses: []
76
118
  post_install_message:
@@ -89,24 +131,27 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
131
  - - ! '>='
90
132
  - !ruby/object:Gem::Version
91
133
  version: '0'
134
+ segments:
135
+ - 0
136
+ hash: 3188865586453898669
92
137
  requirements:
93
138
  - The 'json' gem if ruby version 1.8.x is used.
94
139
  rubyforge_project: transport
95
- rubygems_version: 1.8.10
140
+ rubygems_version: 1.8.24
96
141
  signing_key:
97
142
  specification_version: 3
98
143
  summary: A HTTP/JSON transport layer.
99
144
  test_files:
145
+ - spec/acceptance/json_spec.rb
146
+ - spec/acceptance/http_spec.rb
147
+ - spec/lib/transport/json_spec.rb
148
+ - spec/lib/transport/common/request_builder_spec.rb
100
149
  - spec/lib/transport/unexpected_status_code_error_spec.rb
150
+ - spec/lib/transport/http/request_builder_spec.rb
151
+ - spec/lib/transport/http/request_builder/parameter_serializer_spec.rb
152
+ - spec/lib/transport/http/formatter_spec.rb
101
153
  - spec/lib/transport/json/request_builder_spec.rb
102
154
  - spec/lib/transport/json/response_parser_spec.rb
103
155
  - spec/lib/transport/http_spec.rb
104
156
  - spec/lib/transport/common_spec.rb
105
- - spec/lib/transport/common/request_builder_spec.rb
106
- - spec/lib/transport/http/request_builder_spec.rb
107
- - spec/lib/transport/http/request_builder/parameter_serializer_spec.rb
108
- - spec/lib/transport/http/formatter_spec.rb
109
- - spec/lib/transport/json_spec.rb
110
157
  - spec/lib/transport/spec/faker_spec.rb
111
- - spec/acceptance/http_spec.rb
112
- - spec/acceptance/json_spec.rb