right_develop 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.2.0
1
+ 2.2.1
data/bin/right_develop CHANGED
@@ -20,7 +20,7 @@ end
20
20
  # just yet.
21
21
  command_list = commands.keys.map { |c| " * #{c}" }.join("\n")
22
22
  p = Trollop::Parser.new do
23
- version "right_develop #{gemspec.version} (c) 2013- RightScale, Inc."
23
+ version "right_develop #{gemspec.version} (c) 2013-2014 RightScale, Inc."
24
24
  banner <<-EOS
25
25
  A command-line interface to various tools offered by the right_develop gem.
26
26
 
@@ -61,7 +61,7 @@ module RightDevelop::Testing::Recording
61
61
  FIXTURE_FILE_NAME_REGEX = /^([0-9A-Fa-f]{32}).yml$/
62
62
 
63
63
  # typename to value expression for significant/requests/responses configurations.
64
- TYPE_NAME_VALUE_REGEX = /^(body|header|query|verb)(?:\:([^=]+))?=(.*)$/
64
+ TYPE_NAME_VALUE_REGEX = /^(body|header|query|verb)(?:[:#]([^=]+))?=(.*)$/
65
65
 
66
66
  # exceptions.
67
67
  class ConfigError < StandardError; end
@@ -37,7 +37,7 @@ module RightDevelop::Testing::Recording
37
37
  VERBS = %w(DELETE GET HEAD PATCH POST PUT).freeze
38
38
 
39
39
  # valid modes, determines how variables are substituted, etc.
40
- MODES = %w(echo record playback)
40
+ MODES = %w(echo record playback validate)
41
41
 
42
42
  # valid kinds, also keys under matchers.
43
43
  KINDS = %w(request response)
@@ -87,6 +87,7 @@ module RightDevelop::Testing::Recording
87
87
 
88
88
  attr_reader :uri, :verb, :http_status, :headers, :body
89
89
  attr_reader :mode, :logger, :effective_route_config, :variables
90
+ attr_reader :typenames_to_values
90
91
 
91
92
  # Computes the metadata used to identify where the request/response should
92
93
  # be stored-to/retrieved-from. Recording the full request is not strictly
@@ -141,7 +142,7 @@ module RightDevelop::Testing::Recording
141
142
  # apply the configuration by substituting for variables in the request and
142
143
  # by obfuscating wherever a variable name is nil.
143
144
  case @mode
144
- when 'echo'
145
+ when 'validate'
145
146
  # do nothing; used to validate the fixtures before playback, etc.
146
147
  else
147
148
  erck = @effective_route_config[@kind]
@@ -750,7 +751,7 @@ module RightDevelop::Testing::Recording
750
751
 
751
752
  # use deep-sorted JSON to prevent random ordering changing the checksum.
752
753
  checksum_data = self.class.deep_sorted_json(significant_data)
753
- if logger.debug? && @mode != 'echo'
754
+ if logger.debug? && @mode != 'validate'
754
755
  logger.debug("#{@kind} checksum_data = #{checksum_data.inspect}")
755
756
  end
756
757
  ::Digest::MD5.hexdigest(checksum_data)
@@ -175,7 +175,7 @@ module RightDevelop::Testing::Server::MightApi
175
175
 
176
176
  # eliminate headers that interfere with response via proxy.
177
177
  %w(
178
- connection status content-encoding
178
+ status content-encoding
179
179
  ).each { |key| response_headers.delete(key) }
180
180
 
181
181
  case response_code = Integer(rest_response.code)
@@ -293,10 +293,20 @@ module RightDevelop::Testing::Server::MightApi
293
293
  #
294
294
  # @return [Hash] normalized headers
295
295
  def normalize_rack_response_headers(headers)
296
- headers.inject({}) do |h, (k, v)|
296
+ result = headers.inject({}) do |h, (k, v)|
297
297
  h[k.to_s.gsub('_', '-').downcase] = v.join("\n")
298
298
  h
299
299
  end
300
+
301
+ # a proxy server must always instruct the client close the connection by
302
+ # specification because a live socket cannot be proxied from client to
303
+ # the real server. this also works around a lame warning in ruby 1.9.3
304
+ # webbrick code (fixed in 2.1.0+) saying:
305
+ # Could not determine content-length of response body.
306
+ # Set content-length of the response or set Response#chunked = true
307
+ # in the case of 204 empty response, which is incorrect.
308
+ result['connection'] = 'close'
309
+ result
300
310
  end
301
311
 
302
312
  # @return [Array] rack-style response for 500
@@ -39,19 +39,51 @@ module RightDevelop::Testing::Server::MightApi::App
39
39
  # @see RightDevelop::Testing::Server::MightApi::App::Base#handle_request
40
40
  def handle_request(env, verb, uri, headers, body)
41
41
 
42
- # check routes.
42
+ # echo request back as response.
43
43
  response = ::Rack::Response.new
44
+ response.write "verb = #{verb.inspect}\n\n"
45
+ response.write "uri = #{uri}\n\n"
46
+ response.write "headers = #{METADATA_CLASS.deep_sorted_json(headers, true)}\n\n"
47
+ response.write "body = #{body.inspect}\n\n"
48
+
49
+ # check routes.
44
50
  if route = find_route(uri)
45
- response.write "URL matched #{route.last[:name].inspect}\n"
51
+ route_path, route_data = route
52
+ response.write "URL matched #{route_data[:name].inspect}\n\n"
53
+
54
+ # compute effective metadata for request.
55
+ begin
56
+ proxied_url = ::File.join(route_data[:url], uri.path)
57
+ unless uri.query.to_s.empty?
58
+ proxied_url << '?' << uri.query
59
+ end
60
+ request_metadata = METADATA_CLASS.new(
61
+ mode: :echo,
62
+ kind: :request,
63
+ logger: logger,
64
+ route_data: route_data,
65
+ uri: METADATA_CLASS.normalize_uri(proxied_url),
66
+ verb: verb,
67
+ headers: headers,
68
+ body: body,
69
+ variables: {})
70
+
71
+ # echo any interesting metadata.
72
+ response.write "substituted request variables = #{METADATA_CLASS.deep_sorted_json(request_metadata.variables, true)}\n\n"
73
+ response.write "effective route configuration = #{METADATA_CLASS.deep_sorted_json(request_metadata.effective_route_config, true)}\n\n"
74
+ response.write "request checksum = #{request_metadata.checksum}\n\n"
75
+ rescue Exception => e
76
+ response.write "Failure to compute request metadata:\n#{e.class}: #{e.message}\n#{(e.backtrace || []).join("\n")}\n\n"
77
+ end
46
78
  else
47
- response.write "Failed to match any route. The following routes are valid:\n"
79
+ response.write "Failed to match any route. The following routes are valid:\n\n"
48
80
  config.routes.keys.each do |prefix|
49
81
  response.write "Prefix = #{prefix.inspect}\n\n"
50
82
  end
51
83
  end
52
84
 
53
- # echo request back as response.
54
- response.write "\nruby %sp%s\n\n" % [RUBY_VERSION, RUBY_PATCHLEVEL]
85
+ # process details.
86
+ response.write "ruby %sp%s\n\n" % [RUBY_VERSION, RUBY_PATCHLEVEL]
55
87
  response.write "Raw configuration = #{::JSON.pretty_generate(config.to_hash)}\n\n" # hash order is significant in config
56
88
  config.routes.each do |route_path, route_config|
57
89
  response.write "=== Compiled route matchers begin for root = #{route_path.inspect}:\nmatchers = {\n"
@@ -62,10 +94,6 @@ module RightDevelop::Testing::Server::MightApi::App
62
94
  end
63
95
  response.write "env = #{METADATA_CLASS.deep_sorted_json(env, true)}\n\n"
64
96
  response.write "ENV = #{METADATA_CLASS.deep_sorted_json(::ENV, true)}\n\n"
65
- response.write "verb = #{verb.inspect}\n\n"
66
- response.write "uri = #{uri}\n\n"
67
- response.write "headers = #{METADATA_CLASS.deep_sorted_json(headers, true)}\n\n"
68
- response.write "body = #{body.inspect}\n\n"
69
97
  response.finish
70
98
  end
71
99
 
@@ -154,7 +154,7 @@ module RightDevelop::Testing::Server::MightApi
154
154
 
155
155
  # compute checksum from recorded request metadata.
156
156
  request_metadata = METADATA_CLASS.new(
157
- mode: :echo,
157
+ mode: :validate,
158
158
  kind: :request,
159
159
  logger: logger,
160
160
  route_data: route_data,
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{right_develop}
8
- s.version = "2.2.0"
8
+ s.version = "2.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tony Spataro"]
12
- s.date = %q{2014-04-28}
12
+ s.date = %q{2014-05-13}
13
13
  s.default_executable = %q{right_develop}
14
14
  s.description = %q{A toolkit of development tools created by RightScale.}
15
15
  s.email = %q{support@rightscale.com}
metadata CHANGED
@@ -1,245 +1,241 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: right_develop
3
- version: !ruby/object:Gem::Version
4
- hash: 7
5
- prerelease: false
6
- segments:
7
- - 2
8
- - 2
9
- - 0
10
- version: 2.2.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.2.1
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Tony Spataro
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2014-05-06 00:00:00 -07:00
19
- default_executable: right_develop
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- requirement: &id001 !ruby/object:Gem::Requirement
12
+ date: 2014-05-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
23
17
  none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- hash: 49
28
- segments:
29
- - 0
30
- - 8
31
- - 7
32
- version: 0.8.7
18
+ requirements:
33
19
  - - <
34
- - !ruby/object:Gem::Version
35
- hash: 31
36
- segments:
37
- - 0
38
- - 10
39
- version: "0.10"
40
- name: rake
20
+ - !ruby/object:Gem::Version
21
+ version: '0.10'
22
+ - - ! '>='
23
+ - !ruby/object:Gem::Version
24
+ version: 0.8.7
41
25
  type: :runtime
42
26
  prerelease: false
43
- version_requirements: *id001
44
- - !ruby/object:Gem::Dependency
45
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ version_requirements: !ruby/object:Gem::Requirement
46
28
  none: false
47
- requirements:
48
- - - ~>
49
- - !ruby/object:Gem::Version
50
- hash: 3
51
- segments:
52
- - 2
53
- - 0
54
- version: "2.0"
29
+ requirements:
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: '0.10'
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
35
+ version: 0.8.7
36
+ - !ruby/object:Gem::Dependency
55
37
  name: right_support
38
+ requirement: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '2.0'
56
44
  type: :runtime
57
45
  prerelease: false
58
- version_requirements: *id002
59
- - !ruby/object:Gem::Dependency
60
- requirement: &id003 !ruby/object:Gem::Requirement
46
+ version_requirements: !ruby/object:Gem::Requirement
61
47
  none: false
62
- requirements:
48
+ requirements:
63
49
  - - ~>
64
- - !ruby/object:Gem::Version
65
- hash: 7
66
- segments:
67
- - 3
68
- - 0
69
- version: "3.0"
50
+ - !ruby/object:Gem::Version
51
+ version: '2.0'
52
+ - !ruby/object:Gem::Dependency
70
53
  name: builder
54
+ requirement: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ version: '3.0'
71
60
  type: :runtime
72
61
  prerelease: false
73
- version_requirements: *id003
74
- - !ruby/object:Gem::Dependency
75
- requirement: &id004 !ruby/object:Gem::Requirement
62
+ version_requirements: !ruby/object:Gem::Requirement
76
63
  none: false
77
- requirements:
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- hash: 9
81
- segments:
82
- - 1
83
- - 3
84
- version: "1.3"
85
- - - <
86
- - !ruby/object:Gem::Version
87
- hash: 7
88
- segments:
89
- - 3
90
- - 0
91
- version: "3.0"
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: '3.0'
68
+ - !ruby/object:Gem::Dependency
92
69
  name: rspec
70
+ requirement: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - <
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '1.3'
93
79
  type: :runtime
94
80
  prerelease: false
95
- version_requirements: *id004
96
- - !ruby/object:Gem::Dependency
97
- requirement: &id005 !ruby/object:Gem::Requirement
81
+ version_requirements: !ruby/object:Gem::Requirement
98
82
  none: false
99
- requirements:
100
- - - ~>
101
- - !ruby/object:Gem::Version
102
- hash: 15
103
- segments:
104
- - 1
105
- - 0
106
- version: "1.0"
83
+ requirements:
107
84
  - - <
108
- - !ruby/object:Gem::Version
109
- hash: 29
110
- segments:
111
- - 1
112
- - 3
113
- - 3
114
- version: 1.3.3
85
+ - !ruby/object:Gem::Version
86
+ version: '3.0'
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '1.3'
90
+ - !ruby/object:Gem::Dependency
115
91
  name: cucumber
92
+ requirement: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - <
96
+ - !ruby/object:Gem::Version
97
+ version: 1.3.3
98
+ - - ~>
99
+ - !ruby/object:Gem::Version
100
+ version: '1.0'
116
101
  type: :runtime
117
102
  prerelease: false
118
- version_requirements: *id005
119
- - !ruby/object:Gem::Dependency
120
- requirement: &id006 !ruby/object:Gem::Requirement
103
+ version_requirements: !ruby/object:Gem::Requirement
121
104
  none: false
122
- requirements:
123
- - - ">="
124
- - !ruby/object:Gem::Version
125
- hash: 15
126
- segments:
127
- - 1
128
- - 0
129
- version: "1.0"
105
+ requirements:
130
106
  - - <
131
- - !ruby/object:Gem::Version
132
- hash: 7
133
- segments:
134
- - 3
135
- - 0
136
- version: "3.0"
107
+ - !ruby/object:Gem::Version
108
+ version: 1.3.3
109
+ - - ~>
110
+ - !ruby/object:Gem::Version
111
+ version: '1.0'
112
+ - !ruby/object:Gem::Dependency
137
113
  name: trollop
114
+ requirement: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - <
118
+ - !ruby/object:Gem::Version
119
+ version: '3.0'
120
+ - - ! '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '1.0'
138
123
  type: :runtime
139
124
  prerelease: false
140
- version_requirements: *id006
141
- - !ruby/object:Gem::Dependency
142
- requirement: &id007 !ruby/object:Gem::Requirement
125
+ version_requirements: !ruby/object:Gem::Requirement
126
+ none: false
127
+ requirements:
128
+ - - <
129
+ - !ruby/object:Gem::Version
130
+ version: '3.0'
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '1.0'
134
+ - !ruby/object:Gem::Dependency
135
+ name: right_git
136
+ requirement: !ruby/object:Gem::Requirement
143
137
  none: false
144
- requirements:
138
+ requirements:
145
139
  - - ~>
146
- - !ruby/object:Gem::Version
147
- hash: 27
148
- segments:
149
- - 0
150
- - 1
151
- - 0
140
+ - !ruby/object:Gem::Version
152
141
  version: 0.1.0
153
- name: right_git
154
142
  type: :runtime
155
143
  prerelease: false
156
- version_requirements: *id007
157
- - !ruby/object:Gem::Dependency
158
- requirement: &id008 !ruby/object:Gem::Requirement
144
+ version_requirements: !ruby/object:Gem::Requirement
159
145
  none: false
160
- requirements:
161
- - - ">="
162
- - !ruby/object:Gem::Version
163
- hash: 11
164
- segments:
165
- - 2
166
- - 1
167
- - 0
168
- version: 2.1.0
146
+ requirements:
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
149
+ version: 0.1.0
150
+ - !ruby/object:Gem::Dependency
169
151
  name: right_aws
152
+ requirement: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: 2.1.0
170
158
  type: :runtime
171
159
  prerelease: false
172
- version_requirements: *id008
173
- - !ruby/object:Gem::Dependency
174
- requirement: &id009 !ruby/object:Gem::Requirement
160
+ version_requirements: !ruby/object:Gem::Requirement
175
161
  none: false
176
- requirements:
177
- - - ">="
178
- - !ruby/object:Gem::Version
179
- hash: 3
180
- segments:
181
- - 0
182
- version: "0"
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: 2.1.0
166
+ - !ruby/object:Gem::Dependency
183
167
  name: extlib
168
+ requirement: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
184
174
  type: :runtime
185
175
  prerelease: false
186
- version_requirements: *id009
187
- - !ruby/object:Gem::Dependency
188
- requirement: &id010 !ruby/object:Gem::Requirement
176
+ version_requirements: !ruby/object:Gem::Requirement
189
177
  none: false
190
- requirements:
191
- - - ">="
192
- - !ruby/object:Gem::Version
193
- hash: 3
194
- segments:
195
- - 0
196
- version: "0"
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ - !ruby/object:Gem::Dependency
197
183
  name: rack
184
+ requirement: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
198
190
  type: :runtime
199
191
  prerelease: false
200
- version_requirements: *id010
201
- - !ruby/object:Gem::Dependency
202
- requirement: &id011 !ruby/object:Gem::Requirement
192
+ version_requirements: !ruby/object:Gem::Requirement
193
+ none: false
194
+ requirements:
195
+ - - ! '>='
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
198
+ - !ruby/object:Gem::Dependency
199
+ name: jeweler
200
+ requirement: !ruby/object:Gem::Requirement
203
201
  none: false
204
- requirements:
202
+ requirements:
205
203
  - - ~>
206
- - !ruby/object:Gem::Version
207
- hash: 49
208
- segments:
209
- - 1
210
- - 8
211
- - 3
204
+ - !ruby/object:Gem::Version
212
205
  version: 1.8.3
213
- name: jeweler
214
206
  type: :development
215
207
  prerelease: false
216
- version_requirements: *id011
217
- - !ruby/object:Gem::Dependency
218
- requirement: &id012 !ruby/object:Gem::Requirement
208
+ version_requirements: !ruby/object:Gem::Requirement
219
209
  none: false
220
- requirements:
221
- - - ">="
222
- - !ruby/object:Gem::Version
223
- hash: 27
224
- segments:
225
- - 2
226
- - 4
227
- - 2
228
- version: 2.4.2
210
+ requirements:
211
+ - - ~>
212
+ - !ruby/object:Gem::Version
213
+ version: 1.8.3
214
+ - !ruby/object:Gem::Dependency
229
215
  name: rdoc
216
+ requirement: !ruby/object:Gem::Requirement
217
+ none: false
218
+ requirements:
219
+ - - ! '>='
220
+ - !ruby/object:Gem::Version
221
+ version: 2.4.2
230
222
  type: :development
231
223
  prerelease: false
232
- version_requirements: *id012
224
+ version_requirements: !ruby/object:Gem::Requirement
225
+ none: false
226
+ requirements:
227
+ - - ! '>='
228
+ - !ruby/object:Gem::Version
229
+ version: 2.4.2
233
230
  description: A toolkit of development tools created by RightScale.
234
231
  email: support@rightscale.com
235
- executables:
232
+ executables:
236
233
  - right_develop
237
234
  extensions: []
238
-
239
- extra_rdoc_files:
235
+ extra_rdoc_files:
240
236
  - LICENSE
241
237
  - README.rdoc
242
- files:
238
+ files:
243
239
  - CHANGELOG.rdoc
244
240
  - LICENSE
245
241
  - README.rdoc
@@ -291,39 +287,32 @@ files:
291
287
  - lib/right_develop/utility/versioning.rb
292
288
  - right_develop.gemspec
293
289
  - right_develop.rconf
294
- has_rdoc: true
295
290
  homepage: https://github.com/rightscale/right_develop
296
- licenses:
291
+ licenses:
297
292
  - MIT
298
293
  post_install_message:
299
294
  rdoc_options: []
300
-
301
- require_paths:
295
+ require_paths:
302
296
  - lib
303
- required_ruby_version: !ruby/object:Gem::Requirement
297
+ required_ruby_version: !ruby/object:Gem::Requirement
304
298
  none: false
305
- requirements:
306
- - - ">="
307
- - !ruby/object:Gem::Version
308
- hash: 3
309
- segments:
299
+ requirements:
300
+ - - ! '>='
301
+ - !ruby/object:Gem::Version
302
+ version: '0'
303
+ segments:
310
304
  - 0
311
- version: "0"
312
- required_rubygems_version: !ruby/object:Gem::Requirement
305
+ hash: -307522925874421181
306
+ required_rubygems_version: !ruby/object:Gem::Requirement
313
307
  none: false
314
- requirements:
315
- - - ">="
316
- - !ruby/object:Gem::Version
317
- hash: 3
318
- segments:
319
- - 0
320
- version: "0"
308
+ requirements:
309
+ - - ! '>='
310
+ - !ruby/object:Gem::Version
311
+ version: '0'
321
312
  requirements: []
322
-
323
313
  rubyforge_project:
324
- rubygems_version: 1.3.7
314
+ rubygems_version: 1.8.23
325
315
  signing_key:
326
316
  specification_version: 3
327
317
  summary: Reusable dev & test code.
328
318
  test_files: []
329
-