ingamer_rhc 1.2.6 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,42 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ right_http_connection (1.3.0)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ builder (3.0.0)
10
+ cucumber (0.10.0)
11
+ builder (>= 2.1.2)
12
+ diff-lcs (~> 1.1.2)
13
+ gherkin (~> 2.3.2)
14
+ json (~> 1.4.6)
15
+ term-ansicolor (~> 1.0.5)
16
+ diff-lcs (1.1.2)
17
+ flexmock (0.8.11)
18
+ gherkin (2.3.3)
19
+ json (~> 1.4.6)
20
+ json (1.4.6)
21
+ rake (0.8.7)
22
+ rspec (2.4.0)
23
+ rspec-core (~> 2.4.0)
24
+ rspec-expectations (~> 2.4.0)
25
+ rspec-mocks (~> 2.4.0)
26
+ rspec-core (2.4.0)
27
+ rspec-expectations (2.4.0)
28
+ diff-lcs (~> 1.1.2)
29
+ rspec-mocks (2.4.0)
30
+ term-ansicolor (1.0.5)
31
+ trollop (1.16.2)
32
+
33
+ PLATFORMS
34
+ ruby
35
+
36
+ DEPENDENCIES
37
+ cucumber (~> 0.8)
38
+ flexmock (~> 0.8.11)
39
+ rake
40
+ right_http_connection!
41
+ rspec (~> 2.3)
42
+ trollop (~> 1.16)
data/Rakefile CHANGED
@@ -1,4 +1,6 @@
1
1
  require 'rubygems'
2
+ require 'bundler'
3
+ Bundler::GemHelper.install_tasks
2
4
  require 'rake'
3
5
  require 'rake/clean'
4
6
  require 'rake/testtask'
@@ -6,67 +8,25 @@ require 'rake/packagetask'
6
8
  require 'rake/gempackagetask'
7
9
  require 'rake/rdoctask'
8
10
  require 'rake/contrib/rubyforgepublisher'
11
+ require 'rspec/core/rake_task'
12
+ require 'cucumber/rake/task'
9
13
  require 'fileutils'
10
- require 'hoe'
11
14
  include FileUtils
12
15
  require File.join(File.dirname(__FILE__), 'lib', 'right_http_connection')
13
16
 
14
- AUTHOR = 'RightScale' # can also be an array of Authors
15
- EMAIL = "rubygems@rightscale.com"
16
- DESCRIPTION = "RightScale's robust HTTP/S connection module"
17
- GEM_NAME = 'right_http_connection' # what ppl will type to install your gem
18
- RUBYFORGE_PROJECT = 'rightscale' # The unix name for your project
19
- HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
20
- DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
21
-
22
- NAME = "right_http_connection"
23
- REV = nil # UNCOMMENT IF REQUIRED: File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
24
- VERS = RightHttpConnection::VERSION::STRING + (REV ? ".#{REV}" : "")
25
- CLEAN.include ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']
26
- RDOC_OPTS = ['--quiet', '--title', 'right_http_connection documentation',
27
- "--opname", "index.html",
28
- "--line-numbers",
29
- "--main", "README",
30
- "--inline-source"]
31
-
32
- # Suppress Hoe's self-inclusion as a dependency for our Gem. This also keeps
33
- # Rake & rubyforge out of the dependency list. Users must manually install
34
- # these gems to run tests, etc.
35
- # TRB 2/19/09: also do this for the extra_dev_deps array present in newer hoes.
36
- # Older versions of RubyGems will try to install developer-dependencies as
37
- # required runtime dependencies....
38
- class Hoe
39
- def extra_deps
40
- @extra_deps.reject do |x|
41
- Array(x).first == 'hoe'
42
- end
43
- end
44
- def extra_dev_deps
45
- @extra_dev_deps.reject do |x|
46
- Array(x).first == 'hoe'
47
- end
48
- end
49
- end
17
+ Bundler::GemHelper.install_tasks
18
+
19
+ # == Gem == #
50
20
 
51
- # Generate all the Rake tasks
52
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
53
- hoe = Hoe.new(GEM_NAME, VERS) do |p|
54
- p.author = AUTHOR
55
- p.description = DESCRIPTION
56
- p.email = EMAIL
57
- p.summary = DESCRIPTION
58
- p.url = HOMEPATH
59
- p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
60
- p.test_globs = ["test/**/test_*.rb"]
61
- p.clean_globs = CLEAN #An array of file patterns to delete on clean.
62
- p.remote_rdoc_dir = "right_http_gem_doc"
63
-
64
- # == Optional
65
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
66
- #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
67
- #p.spec_extras = {} # A hash of extra values to set in the gemspec.
21
+ gemtask = Rake::GemPackageTask.new(Gem::Specification.load("right_http_connection.gemspec")) do |package|
22
+ package.package_dir = ENV['PACKAGE_DIR'] || 'pkg'
23
+ package.need_zip = true
24
+ package.need_tar = true
68
25
  end
69
26
 
27
+ directory gemtask.package_dir
28
+
29
+ CLEAN.include(gemtask.package_dir)
70
30
 
71
31
  desc 'Generate website files'
72
32
  task :website_generate do
@@ -101,3 +61,29 @@ task :check_version do
101
61
  exit
102
62
  end
103
63
  end
64
+
65
+ task :default => 'spec'
66
+
67
+ # == Unit Tests == #
68
+
69
+ desc "Run unit tests"
70
+ RSpec::Core::RakeTask.new
71
+
72
+ namespace :spec do
73
+ desc "Run unit tests with RCov"
74
+ RSpec::Core::RakeTask.new(:rcov) do |t|
75
+ t.rcov = true
76
+ t.rcov_opts = %q[--exclude "spec"]
77
+ end
78
+
79
+ desc "Print Specdoc for unit tests"
80
+ RSpec::Core::RakeTask.new(:doc) do |t|
81
+ t.rspec_opts = ["--format", "documentation"]
82
+ end
83
+ end
84
+
85
+ # == Functional tests == #
86
+ desc "Run functional tests"
87
+ Cucumber::Rake::Task.new do |t|
88
+ t.cucumber_opts = %w{--color --format pretty}
89
+ end
@@ -27,21 +27,10 @@ require "time"
27
27
  require "logger"
28
28
 
29
29
  $:.unshift(File.dirname(__FILE__))
30
+ require 'version'
30
31
  require 'support'
31
32
  require "net_fix"
32
33
 
33
-
34
- module RightHttpConnection #:nodoc:
35
- module VERSION #:nodoc:
36
- MAJOR = 1 unless defined?(MAJOR)
37
- MINOR = 2 unless defined?(MINOR)
38
- TINY = 5 unless defined?(TINY)
39
-
40
- STRING = [MAJOR, MINOR, TINY].join('.') unless defined?(STRING)
41
- end
42
- end
43
-
44
-
45
34
  module Rightscale
46
35
 
47
36
  =begin rdoc
@@ -101,9 +90,14 @@ them.
101
90
  #
102
91
  # :user_agent => 'www.HostName.com' # String to report as HTTP User agent
103
92
  # :ca_file => 'path_to_file' # Path to a CA certification file in PEM format. The file can contain several CA certificates. If this parameter isn't set, HTTPS certs won't be verified.
93
+ # :fail_if_ca_mismatch => Boolean # If ca_file is set and the server certificate doesn't verify, a log line is generated regardless, but normally right_http_connection continues on past the failure. If this is set, fail to connect in that case. Defaults to false.
104
94
  # :logger => Logger object # If omitted, HttpConnection logs to STDOUT
105
95
  # :exception => Exception to raise # The type of exception to raise
106
96
  # # if a request repeatedly fails. RuntimeError is raised if this parameter is omitted.
97
+ # :proxy_host => 'hostname' # hostname of HTTP proxy host to use, default none.
98
+ # :proxy_port => port # port of HTTP proxy host to use, default none.
99
+ # :proxy_username => 'username' # username to use for proxy authentication, default none.
100
+ # :proxy_password => 'password' # password to use for proxy authentication, default none.
107
101
  # :http_connection_retry_count # by default == Rightscale::HttpConnection::HTTP_CONNECTION_RETRY_COUNT
108
102
  # :http_connection_open_timeout # by default == Rightscale::HttpConnection::HTTP_CONNECTION_OPEN_TIMEOUT
109
103
  # :http_connection_read_timeout # by default == Rightscale::HttpConnection::HTTP_CONNECTION_READ_TIMEOUT
@@ -129,8 +123,13 @@ them.
129
123
  # Params hash:
130
124
  # :user_agent => 'www.HostName.com' # String to report as HTTP User agent
131
125
  # :ca_file => 'path_to_file' # A path of a CA certification file in PEM format. The file can contain several CA certificates.
126
+ # :fail_if_ca_mismatch => Boolean # If ca_file is set and the server certificate doesn't verify, a log line is generated regardless, but normally right_http_connection continues on past the failure. If this is set, fail to connect in that case. Defaults to false.
132
127
  # :logger => Logger object # If omitted, HttpConnection logs to STDOUT
133
128
  # :exception => Exception to raise # The type of exception to raise if a request repeatedly fails. RuntimeError is raised if this parameter is omitted.
129
+ # :proxy_host => 'hostname' # hostname of HTTP proxy host to use, default none.
130
+ # :proxy_port => port # port of HTTP proxy host to use, default none.
131
+ # :proxy_username => 'username' # username to use for proxy authentication, default none.
132
+ # :proxy_password => 'password' # password to use for proxy authentication, default none.
134
133
  # :http_connection_retry_count # by default == Rightscale::HttpConnection.params[:http_connection_retry_count]
135
134
  # :http_connection_open_timeout # by default == Rightscale::HttpConnection.params[:http_connection_open_timeout]
136
135
  # :http_connection_read_timeout # by default == Rightscale::HttpConnection.params[:http_connection_read_timeout]
@@ -142,6 +141,10 @@ them.
142
141
  @params[:http_connection_open_timeout] ||= @@params[:http_connection_open_timeout]
143
142
  @params[:http_connection_read_timeout] ||= @@params[:http_connection_read_timeout]
144
143
  @params[:http_connection_retry_delay] ||= @@params[:http_connection_retry_delay]
144
+ @params[:proxy_host] ||= @@params[:proxy_host]
145
+ @params[:proxy_port] ||= @@params[:proxy_port]
146
+ @params[:proxy_username] ||= @@params[:proxy_username]
147
+ @params[:proxy_password] ||= @@params[:proxy_password]
145
148
  @http = nil
146
149
  @server = nil
147
150
  @logger = get_param(:logger) ||
@@ -283,13 +286,20 @@ them.
283
286
  # close the previous if exists
284
287
  finish
285
288
  # create new connection
286
- @server = request_params[:server]
287
- @port = request_params[:port]
288
- @protocol = request_params[:protocol]
289
+ @server = request_params[:server]
290
+ @port = request_params[:port]
291
+ @protocol = request_params[:protocol]
292
+ @proxy_host = request_params[:proxy_host]
293
+ @proxy_port = request_params[:proxy_port]
294
+ @proxy_username = request_params[:proxy_username]
295
+ @proxy_password = request_params[:proxy_password]
289
296
 
290
297
  @logger.info("Opening new #{@protocol.upcase} connection to #@server:#@port")
298
+ @logger.info("Connecting to proxy #{@proxy_host}:#{@proxy_port} with username" +
299
+ " #{@proxy_username}") unless @proxy_host.nil?
291
300
 
292
- @http = Net::HTTP.new(@server, @port)
301
+ @http = Net::HTTP.new(@server, @port, @proxy_host, @proxy_port, @proxy_username,
302
+ @proxy_password)
293
303
  @http.open_timeout = get_param(:http_connection_open_timeout, request_params)
294
304
  @http.read_timeout = get_param(:http_connection_read_timeout, request_params)
295
305
 
@@ -299,7 +309,11 @@ them.
299
309
  msg = x509_store_ctx.error_string
300
310
  #debugger
301
311
  @logger.warn("##### #{@server} certificate verify failed: #{msg}") unless code == 0
302
- true
312
+ if request_params[:fail_if_ca_mismatch] && code != 0
313
+ false
314
+ else
315
+ true
316
+ end
303
317
  }
304
318
  @http.use_ssl = true
305
319
  ca_file = get_param(:ca_file)
@@ -325,6 +339,10 @@ them.
325
339
  :port => '80' # Port of HTTP server
326
340
  :protocol => 'https' # http and https are supported on any port
327
341
  :request => 'requeststring' # Fully-formed HTTP request to make
342
+ :proxy_host => 'hostname' # hostname of HTTP proxy host to use, default none.
343
+ :proxy_port => port # port of HTTP proxy host to use, default none.
344
+ :proxy_username => 'username' # username to use for proxy authentication, default none.
345
+ :proxy_password => 'password' # password to use for proxy authentication, default none.
328
346
 
329
347
  :raise_on_timeout # do not perform a retry if timeout is received (false by default)
330
348
  :http_connection_retry_count
@@ -411,7 +429,7 @@ them.
411
429
  end
412
430
  rescue Exception => e # See comment at bottom for the list of errors seen...
413
431
  @http = nil
414
- timeout_exception = e.is_a?(Errno::ETIMEDOUT) || e.is_a?(Timeout::Error)
432
+ timeout_exception = e.is_a?(Errno::ETIMEDOUT) || e.is_a?(Timeout::Error)
415
433
  # Omit retries if it was explicitly requested
416
434
  if current_params[:raise_on_timeout] && timeout_exception
417
435
  # #6481:
@@ -0,0 +1,32 @@
1
+ #-- -*- mode: ruby; encoding: utf-8 -*-
2
+ # Copyright: Copyright (c) 2010 RightScale, Inc.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # 'Software'), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
+ # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19
+ # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21
+ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ module RightHttpConnection #:nodoc:
25
+ module VERSION #:nodoc:
26
+ MAJOR = 1 unless defined?(MAJOR)
27
+ MINOR = 3 unless defined?(MINOR)
28
+ TINY = 0 unless defined?(TINY)
29
+
30
+ STRING = [MAJOR, MINOR, TINY].join('.') unless defined?(STRING)
31
+ end
32
+ end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 2
8
- - 6
9
- version: 1.2.6
7
+ - 3
8
+ - 0
9
+ version: 1.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - RightScale
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-30 00:00:00 -04:00
17
+ date: 2011-02-28 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -30,6 +30,9 @@ files:
30
30
  - lib/net_fix.rb
31
31
  - lib/right_http_connection.rb
32
32
  - lib/support.rb
33
+ - lib/version.rb
34
+ - Gemfile
35
+ - Gemfile.lock
33
36
  - History.txt
34
37
  - Manifest.txt
35
38
  - Rakefile