rest_connection 1.0.10 → 1.0.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -48,11 +48,27 @@ module RightScale
48
48
  def refresh_cookie
49
49
  # login
50
50
  @cookie = nil
51
+ #####################################################################
52
+ # HACK: Re-login with API version 1.0 when receiving an API 0.1 call
53
+ # https://rightsite.gitsrc.com/trac/ticket/16404
54
+ if @settings[:common_headers]["X_API_VERSION"] == "0.1"
55
+ @settings[:common_headers]["X_API_VERSION"] = "1.0"
56
+ @__refreshing_cookie_for_api_0_1__ = true
57
+ end
58
+ #####################################################################
51
59
  resp = get("login")
52
60
  unless resp.code == "302" || resp.code == "204"
53
61
  raise "ERROR: Login failed. #{resp.message}. Code:#{resp.code}"
54
62
  end
55
63
  @cookie = resp.response['set-cookie']
64
+ #####################################################################
65
+ # HACK: Reset the API version header to 0.1 so subsequent calls work
66
+ # https://rightsite.gitsrc.com/trac/ticket/16404
67
+ if @__refreshing_cookie_for_api_0_1__
68
+ @settings[:common_headers]["X_API_VERSION"] = "0.1"
69
+ @__refreshing_cookie_for_api_0_1__ = false
70
+ end
71
+ #####################################################################
56
72
  true
57
73
  end
58
74
  end
@@ -137,7 +137,16 @@ class ServerInterface
137
137
  next unless hsh[to]
138
138
  hsh[to].each { |field|
139
139
  vals = opts.select {|k,v| [[hsh["1.0"]] + [hsh["1.5"]]].flatten.include?(k.to_sym) }
140
- vals.flatten!
140
+ # IMPORTANT NOTE REGARDING RUBY VERSIONS!
141
+ #
142
+ # In Ruby 1.9.3 the next line of code is required to be written the way it is. Previously, it was written as:
143
+ # vals.flatten! which doesn't work in Ruby 1.9.3.
144
+ #
145
+ # This is because opts is a hash and in Ruby 1.8.7, the select (above) returns an flattened array of
146
+ # key, value pairs but in 1.9.3 it returns a new hash. flatten! does not exist for hashes so that would
147
+ # no longer work in Ruby 1.9.3 and the code had to be changed to vals = vals.flatten to work correctly
148
+ # in both Ruby versions.
149
+ vals = vals.flatten
141
150
  vals.compact!
142
151
  if hsh["fn"]
143
152
  server[field.to_s] = __send__(hsh["fn"], to, opts[vals.first]) unless vals.first.nil?
@@ -102,6 +102,20 @@ module SshHax
102
102
  output += data
103
103
  end
104
104
  end
105
+ # IMPORTANT NOTE REGARDING RUBY VERSIONS!
106
+ #
107
+ # In Ruby 1.9.3 the next line of code is required. In Ruby 1.8.x, block variables were introduced into the
108
+ # scope that the block was called from. Now, in Ruby 1.9.1, blocks introduce their own scope for the block
109
+ # parameters only. That means, when a block taking a single parameter called x is called, if there are local
110
+ # variables x and y in scope, then any reference to the variable x within the scope refers to the new
111
+ # variable the block parameter brings into scope. However, any reference to the variable y in the block
112
+ # refers to the variable y in scope where the block was called.
113
+ #
114
+ # See http://ruby.about.com/od/newinruby191/a/blockvariscope.htm for more details.
115
+ #
116
+ # Without the next line of code, the while will never terminate in Ruby 1.9.3. In Ruby 1.8.7 it is
117
+ # essentially a no-op as success will already be set to true.
118
+ success = true
105
119
  end
106
120
  end
107
121
  rescue Exception => e
@@ -1,4 +1,4 @@
1
1
  # This gem is versioned with the usual X.Y.Z notation
2
2
  module RestConnection
3
- VERSION = '1.0.10'
3
+ VERSION = '1.0.11'
4
4
  end
@@ -18,16 +18,26 @@ It currently has support for RightScale API 1.0 and 1.5.
18
18
  s.test_files = `git ls-files spec config`.split(' ')
19
19
  s.rubygems_version = '1.8.24'
20
20
 
21
- s.add_runtime_dependency 'activesupport'
22
21
  s.add_runtime_dependency 'net-ssh'
23
22
  s.add_runtime_dependency 'json'
24
23
  s.add_runtime_dependency 'highline'
25
24
  s.add_runtime_dependency 'rest-client'
26
- # nokogiri >= 1.6.0 requires ruby 1.9
27
- s.add_runtime_dependency 'nokogiri', "<1.6.0"
28
25
 
29
26
  s.add_development_dependency 'rake', '0.8.7'
30
27
  s.add_development_dependency 'bundler'
31
28
  s.add_development_dependency 'rspec', '1.3.0'
32
- s.add_development_dependency 'ruby-debug'
29
+ # If we're using Ruby 1.9.x
30
+ if RUBY_VERSION =~ /1.9.*/
31
+ s.add_runtime_dependency 'activesupport'
32
+ s.add_runtime_dependency 'nokogiri'
33
+ s.add_development_dependency 'ruby-debug19'
34
+ elsif RUBY_VERSION =~ /1.8.*/
35
+ # Ruby 1.8.x needs limited nokogiri version
36
+ s.add_runtime_dependency 'nokogiri', "<1.6.0"
37
+ # Ruby 1.8.x needs limited activesupport version
38
+ s.add_runtime_dependency 'activesupport', "<4.0.0"
39
+ s.add_development_dependency 'ruby-debug'
40
+ else
41
+ raise "Ruby version '#{RUBY_VERSION}' is not currently supported."
42
+ end
33
43
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest_connection
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 10
10
- version: 1.0.10
9
+ - 11
10
+ version: 1.0.11
11
11
  platform: ruby
12
12
  authors:
13
13
  - RightScale, Inc.
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-06-17 00:00:00 Z
18
+ date: 2013-08-28 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  version_requirements: &id001 !ruby/object:Gem::Requirement
@@ -30,7 +30,7 @@ dependencies:
30
30
  type: :runtime
31
31
  requirement: *id001
32
32
  prerelease: false
33
- name: activesupport
33
+ name: net-ssh
34
34
  - !ruby/object:Gem::Dependency
35
35
  version_requirements: &id002 !ruby/object:Gem::Requirement
36
36
  none: false
@@ -44,7 +44,7 @@ dependencies:
44
44
  type: :runtime
45
45
  requirement: *id002
46
46
  prerelease: false
47
- name: net-ssh
47
+ name: json
48
48
  - !ruby/object:Gem::Dependency
49
49
  version_requirements: &id003 !ruby/object:Gem::Requirement
50
50
  none: false
@@ -58,7 +58,7 @@ dependencies:
58
58
  type: :runtime
59
59
  requirement: *id003
60
60
  prerelease: false
61
- name: json
61
+ name: highline
62
62
  - !ruby/object:Gem::Dependency
63
63
  version_requirements: &id004 !ruby/object:Gem::Requirement
64
64
  none: false
@@ -72,83 +72,85 @@ dependencies:
72
72
  type: :runtime
73
73
  requirement: *id004
74
74
  prerelease: false
75
- name: highline
75
+ name: rest-client
76
76
  - !ruby/object:Gem::Dependency
77
77
  version_requirements: &id005 !ruby/object:Gem::Requirement
78
78
  none: false
79
79
  requirements:
80
- - - ">="
80
+ - - "="
81
81
  - !ruby/object:Gem::Version
82
- hash: 3
82
+ hash: 49
83
83
  segments:
84
84
  - 0
85
- version: "0"
86
- type: :runtime
85
+ - 8
86
+ - 7
87
+ version: 0.8.7
88
+ type: :development
87
89
  requirement: *id005
88
90
  prerelease: false
89
- name: rest-client
91
+ name: rake
90
92
  - !ruby/object:Gem::Dependency
91
93
  version_requirements: &id006 !ruby/object:Gem::Requirement
92
94
  none: false
93
95
  requirements:
94
- - - <
96
+ - - ">="
95
97
  - !ruby/object:Gem::Version
96
- hash: 15
98
+ hash: 3
97
99
  segments:
98
- - 1
99
- - 6
100
100
  - 0
101
- version: 1.6.0
102
- type: :runtime
101
+ version: "0"
102
+ type: :development
103
103
  requirement: *id006
104
104
  prerelease: false
105
- name: nokogiri
105
+ name: bundler
106
106
  - !ruby/object:Gem::Dependency
107
107
  version_requirements: &id007 !ruby/object:Gem::Requirement
108
108
  none: false
109
109
  requirements:
110
110
  - - "="
111
111
  - !ruby/object:Gem::Version
112
- hash: 49
112
+ hash: 27
113
113
  segments:
114
+ - 1
115
+ - 3
114
116
  - 0
115
- - 8
116
- - 7
117
- version: 0.8.7
117
+ version: 1.3.0
118
118
  type: :development
119
119
  requirement: *id007
120
120
  prerelease: false
121
- name: rake
121
+ name: rspec
122
122
  - !ruby/object:Gem::Dependency
123
123
  version_requirements: &id008 !ruby/object:Gem::Requirement
124
124
  none: false
125
125
  requirements:
126
- - - ">="
126
+ - - <
127
127
  - !ruby/object:Gem::Version
128
- hash: 3
128
+ hash: 15
129
129
  segments:
130
+ - 1
131
+ - 6
130
132
  - 0
131
- version: "0"
132
- type: :development
133
+ version: 1.6.0
134
+ type: :runtime
133
135
  requirement: *id008
134
136
  prerelease: false
135
- name: bundler
137
+ name: nokogiri
136
138
  - !ruby/object:Gem::Dependency
137
139
  version_requirements: &id009 !ruby/object:Gem::Requirement
138
140
  none: false
139
141
  requirements:
140
- - - "="
142
+ - - <
141
143
  - !ruby/object:Gem::Version
142
- hash: 27
144
+ hash: 63
143
145
  segments:
144
- - 1
145
- - 3
146
+ - 4
146
147
  - 0
147
- version: 1.3.0
148
- type: :development
148
+ - 0
149
+ version: 4.0.0
150
+ type: :runtime
149
151
  requirement: *id009
150
152
  prerelease: false
151
- name: rspec
153
+ name: activesupport
152
154
  - !ruby/object:Gem::Dependency
153
155
  version_requirements: &id010 !ruby/object:Gem::Requirement
154
156
  none: false