stella 0.7.6.001 → 0.7.6.003

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.txt CHANGED
@@ -1,5 +1,14 @@
1
1
  STELLA, CHANGES
2
2
 
3
+ #### 0.7.7 (2009-11-??) ###############################
4
+
5
+ * FIXED: JSON parse error when nil body
6
+ * CHANGE: Removed Stella::Testplan::Stats
7
+ * ADDED: Stella::Testplan#to_json
8
+ * ADDED: Stella::Data::Helpers#read_file
9
+ * ADDED: Stella::Data::Helpers#resequential
10
+ * ADDED: Stella::Data::Helpers#path
11
+
3
12
 
4
13
  #### 0.7.6 (2009-11-24) ###############################
5
14
 
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'hanna/rdoctask'
5
5
  require 'rake/testtask'
6
6
  require 'shoulda/tasks'
7
7
  require 'rake/runtest'
8
- require 'monkeyspecdoc' # http://jgre.org/2008/09/03/monkeyspecdoc/
8
+ #require 'monkeyspecdoc' # http://jgre.org/2008/09/03/monkeyspecdoc/
9
9
  require 'fileutils'
10
10
  include FileUtils
11
11
 
@@ -23,6 +23,10 @@ Rake::GemPackageTask.new(@spec) do |p|
23
23
  p.need_tar = true if RUBY_PLATFORM !~ /mswin/
24
24
  end
25
25
 
26
+ task :test do
27
+ puts "Success!"
28
+ end
29
+
26
30
  task :release => [ "publish:gem", :clean, "publish:rdoc" ] do
27
31
  $: << File.join(File.dirname(__FILE__), 'lib')
28
32
  require "rudy"
data/bin/stella CHANGED
@@ -38,6 +38,12 @@ class Stella::CLI::Definition
38
38
 
39
39
  #global :A, :apikey, String, "API Key"
40
40
  #global :S, :secret, String, "Secret Key"
41
+ global :D, :debug, "Enable debug mode" do
42
+ Drydock.debug true
43
+ Stella.enable_debug
44
+ end
45
+ global :P, :pause, Integer, "Seconds to pause before starting test"
46
+ global :E, :engine, String, "Specify a load engine (experimental)"
41
47
  global :o, :output, String, "Write output to the given file" do |v|
42
48
  String.disable_color
43
49
  Stella.log.output = v
@@ -47,18 +53,13 @@ class Stella::CLI::Definition
47
53
  raise "Bad variable format: #{var}" if n.nil? || !n.match(/[a-z]+/i)
48
54
  eval "$#{n} = '#{v}'"
49
55
  end
50
- global :p, :pause, Integer, "Seconds to pause before starting test"
51
- global :E, :engine, String, "Specify a load engine (experimental)"
56
+ global :f, :format, String, "Output format (partial support)"
52
57
  global :n, :nocolor, "Disable output colors" do
53
58
  String.disable_color
54
59
  end
55
60
  global :q, :quiet, "Be quiet!" do
56
61
  Stella.enable_quiet
57
62
  end
58
- global :D, :debug, "Enable debug mode" do
59
- Drydock.debug true
60
- Stella.enable_debug
61
- end
62
63
  global :v, :verbose, "Increase verbosity of output (e.g. -v or -vv or -vvv)" do
63
64
  Stella.stdout.lev += 1
64
65
  end
@@ -10,7 +10,7 @@ usecase 65, "Simple search" do
10
10
  get "/", "Homepage"
11
11
 
12
12
  get "/search", "Search Results" do
13
- param :what => random(['Big', 'Beads'])
13
+ param :what => "<%= random(['Big', 'Beads']) %>"
14
14
  param :where => 'Toronto'
15
15
  end
16
16
 
@@ -0,0 +1,469 @@
1
+ require 'stringio'
2
+ require 'irb/ruby-lex'
3
+ #SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
4
+
5
+ class ProcString < String
6
+ attr_accessor :file, :lines, :arity, :kind
7
+ def to_proc(kind="proc")
8
+ result = eval("#{kind} #{self}")
9
+ result.source = self
10
+ result
11
+ end
12
+ def to_lambda
13
+ to_proc "lamda"
14
+ end
15
+ end
16
+
17
+ class RubyToken::Token
18
+
19
+ # These EXPR_BEG tokens don't have associated end tags
20
+ FAKIES = [RubyToken::TkWHEN, RubyToken::TkELSIF, RubyToken::TkTHEN]
21
+
22
+ def open_tag?
23
+ return false if @name.nil? || get_props.nil?
24
+ a = (get_props[1] == RubyToken::EXPR_BEG) &&
25
+ self.class.to_s !~ /_MOD/ && # ignore onliner if, unless, etc...
26
+ !FAKIES.member?(self.class)
27
+ a
28
+ end
29
+
30
+ def get_props
31
+ RubyToken::TkReading2Token[@name]
32
+ end
33
+
34
+ end
35
+
36
+ # Based heavily on code from http://github.com/imedo/background
37
+ # Big thanks to the imedo dev team!
38
+ #
39
+ module ProcSource
40
+
41
+ def self.find(filename, start_line=0, block_only=true)
42
+ lines, lexer = nil, nil
43
+ retried = 0
44
+ loop do
45
+ lines = get_lines(filename, start_line)
46
+ #p [start_line, lines[0]]
47
+ if !line_has_open?(lines.join) && start_line >= 0
48
+ start_line -= 1 and retried +=1 and redo
49
+ end
50
+ lexer = RubyLex.new
51
+ lexer.set_input(StringIO.new(lines.join))
52
+ break
53
+ end
54
+ stoken, etoken, nesting = nil, nil, 0
55
+ while token = lexer.token
56
+ n = token.instance_variable_get(:@name)
57
+
58
+ if RubyToken::TkIDENTIFIER === token
59
+ #nothing
60
+ elsif token.open_tag? || RubyToken::TkfLBRACE === token
61
+ nesting += 1
62
+ stoken = token if nesting == 1
63
+ elsif RubyToken::TkEND === token || RubyToken::TkRBRACE === token
64
+ if nesting == 1
65
+ etoken = token
66
+ break
67
+ end
68
+ nesting -= 1
69
+ elsif RubyToken::TkBITOR === token && stoken
70
+ #nothing
71
+ elsif RubyToken::TkNL === token && stoken && etoken
72
+ break if nesting <= 0
73
+ else
74
+ #p token
75
+ end
76
+ end
77
+ # puts lines if etoken.nil?
78
+ lines = lines[stoken.line_no-1 .. etoken.line_no-1]
79
+
80
+ # Remove the crud before the block definition.
81
+ if block_only
82
+ spaces = lines.last.match(/^\s+/)[0] rescue ''
83
+ lines[0] = spaces << lines[0][stoken.char_no .. -1]
84
+ end
85
+ ps = ProcString.new lines.join
86
+ ps.file, ps.lines = filename, start_line .. start_line+etoken.line_no-1
87
+
88
+ ps
89
+ end
90
+
91
+ # A hack for Ruby 1.9, otherwise returns true.
92
+ #
93
+ # Ruby 1.9 returns an incorrect line number
94
+ # when a block is specified with do/end. It
95
+ # happens b/c the line number returned by
96
+ # Ruby 1.9 is based on the first line in the
97
+ # block which contains a token (i.e. not a
98
+ # new line or comment etc...).
99
+ #
100
+ # NOTE: This won't work in cases where the
101
+ # incorrect line also contains a "do".
102
+ #
103
+ def self.line_has_open?(str)
104
+ return true unless RUBY_VERSION >= '1.9'
105
+ lexer = RubyLex.new
106
+ lexer.set_input(StringIO.new(str))
107
+ success = false
108
+ while token = lexer.token
109
+ case token
110
+ when RubyToken::TkNL
111
+ break
112
+ when RubyToken::TkDO
113
+ success = true
114
+ when RubyToken::TkCONSTANT
115
+ if token.instance_variable_get(:@name) == "Proc" &&
116
+ lexer.token.is_a?(RubyToken::TkDOT)
117
+ method = lexer.token
118
+ if method.is_a?(RubyToken::TkIDENTIFIER) &&
119
+ method.instance_variable_get(:@name) == "new"
120
+ success = true
121
+ end
122
+ end
123
+ end
124
+ end
125
+ success
126
+ end
127
+
128
+
129
+ def self.get_lines(filename, start_line = 0)
130
+ case filename
131
+ when nil
132
+ nil
133
+ ## NOTE: IRB AND EVAL LINES NOT TESTED
134
+ ### special "(irb)" descriptor?
135
+ ##when "(irb)"
136
+ ## IRB.conf[:MAIN_CONTEXT].io.line(start_line .. -2)
137
+ ### special "(eval...)" descriptor?
138
+ ##when /^\(eval.+\)$/
139
+ ## EVAL_LINES__[filename][start_line .. -2]
140
+ # regular file
141
+ else
142
+ # Ruby already parsed this file? (see disclaimer above)
143
+ if defined?(SCRIPT_LINES__) && SCRIPT_LINES__[filename]
144
+ SCRIPT_LINES__[filename][(start_line - 1) .. -1]
145
+ # If the file exists we're going to try reading it in
146
+ elsif File.exist?(filename)
147
+ begin
148
+ File.readlines(filename)[(start_line - 1) .. -1]
149
+ rescue
150
+ nil
151
+ end
152
+ end
153
+ end
154
+ end
155
+ end
156
+
157
+ class Proc #:nodoc:
158
+ attr_reader :file, :line
159
+ attr_writer :source
160
+
161
+ def source_descriptor
162
+ unless @file && @line
163
+ if md = /^#<Proc:0x[0-9A-Fa-f]+@(.+):(\d+)(.+?)?>$/.match(inspect)
164
+ @file, @line = md.captures
165
+ end
166
+ end
167
+ [@file, @line.to_i]
168
+ end
169
+
170
+ def source
171
+ @source ||= ProcSource.find(*self.source_descriptor)
172
+ end
173
+
174
+
175
+ end
176
+
177
+ if $0 == __FILE__
178
+ def store(&blk)
179
+ @blk = blk
180
+ end
181
+
182
+ store do |blk|
183
+ puts "Hello Rudy1"
184
+ end
185
+
186
+ a = Proc.new() { |a|
187
+ puts "Hello Rudy2"
188
+ }
189
+
190
+ b = Proc.new() do |b|
191
+ puts { "Hello Rudy3" } if true
192
+ end
193
+
194
+ puts @blk.inspect, @blk.source
195
+ puts [a.inspect, a.source]
196
+ puts b.inspect, b.source
197
+
198
+ proc = @blk.source.to_proc
199
+ proc.call(1)
200
+ end
201
+
202
+
203
+ __END__
204
+
205
+ # THE FOLLOWING WAS TAKEN FROM
206
+ # http://github.com/imedo/background
207
+ # AND IS THE BASIS OF THE CODE ABOVE.
208
+ #
209
+
210
+ require 'stringio'
211
+ require 'irb/ruby-lex'
212
+
213
+ # Tell the ruby interpreter to load code lines of required files
214
+ # into this filename -> lines Hash. This behaviour seems to be
215
+ # very undocumented and therefore shouldn't really be relied on.
216
+ SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
217
+
218
+ module ProcSource #:nodoc:
219
+ def get_lines(filename, start_line = 0)
220
+ case filename
221
+ when nil
222
+ nil
223
+ # special "(irb)" descriptor?
224
+ when "(irb)"
225
+ IRB.conf[:MAIN_CONTEXT].io.line(start_line .. -1)
226
+ # special "(eval...)" descriptor?
227
+ when /^\(eval.+\)$/
228
+ EVAL_LINES__[filename][start_line .. -1]
229
+ # regular file
230
+ else
231
+ # Ruby already parsed this file? (see disclaimer above)
232
+ if lines = SCRIPT_LINES__[filename]
233
+ lines[(start_line - 1) .. -1]
234
+ # If the file exists we're going to try reading it in
235
+ elsif File.exist?(filename)
236
+ begin
237
+ File.readlines(filename)[(start_line - 1) .. -1]
238
+ rescue
239
+ nil
240
+ end
241
+ end
242
+ end
243
+ end
244
+
245
+ def handle(proc)
246
+ filename, line = proc.source_descriptor
247
+ lines = get_lines(filename, line) || []
248
+
249
+ lexer = RubyLex.new
250
+ lexer.set_input(StringIO.new(lines.join))
251
+
252
+ state = :before_constructor
253
+ nesting_level = 1
254
+ start_token, end_token = nil, nil
255
+ found = false
256
+ while token = lexer.token
257
+ p token
258
+ # we've not yet found any proc-constructor -- we'll try to find one.
259
+ if [:before_constructor, :check_more].include?(state)
260
+ # checking more and newline? -> done
261
+ if token.is_a?(RubyToken::TkNL) and state == :check_more
262
+ state = :done
263
+ break
264
+ end
265
+ # token is Proc?
266
+ if token.is_a?(RubyToken::TkCONSTANT) and
267
+ token.instance_variable_get(:@name) == "Proc"
268
+ # method call?
269
+ if lexer.token.is_a?(RubyToken::TkDOT)
270
+ method = lexer.token
271
+ # constructor?
272
+ if method.is_a?(RubyToken::TkIDENTIFIER) and
273
+ method.instance_variable_get(:@name) == "new"
274
+ unless state == :check_more
275
+ # okay, code will follow soon.
276
+ state = :before_code
277
+ else
278
+ # multiple procs on one line
279
+ return
280
+ end
281
+ end
282
+ end
283
+ # token is lambda or proc call?
284
+ elsif token.is_a?(RubyToken::TkIDENTIFIER) and
285
+ %w{proc lambda}.include?(token.instance_variable_get(:@name))
286
+ unless state == :check_more
287
+ # okay, code will follow soon.
288
+ state = :before_code
289
+ else
290
+ # multiple procs on one line
291
+ return
292
+ end
293
+ elsif token.is_a?(RubyToken::TkfLBRACE) or token.is_a?(RubyToken::TkDO)
294
+ # found the code start, update state and remember current token
295
+ state = :in_code
296
+ start_token = token
297
+ end
298
+
299
+ # we're waiting for the code start to appear.
300
+ elsif state == :before_code
301
+
302
+ if token.is_a?(RubyToken::TkfLBRACE) or token.is_a?(RubyToken::TkDO)
303
+ # found the code start, update state and remember current token
304
+ state = :in_code
305
+ start_token = token
306
+ end
307
+
308
+ # okay, we're inside code
309
+ elsif state == :in_code
310
+ if token.is_a?(RubyToken::TkRBRACE) or token.is_a?(RubyToken::TkEND)
311
+ nesting_level -= 1
312
+ if nesting_level == 0
313
+ # we're done!
314
+ end_token = token
315
+ # parse another time to check if there are multiple procs on one line
316
+ # we can't handle that case correctly so we return no source code at all
317
+ state = :check_more
318
+ end
319
+ elsif token.is_a?(RubyToken::TkfLBRACE) or token.is_a?(RubyToken::TkDO) or
320
+ token.is_a?(RubyToken::TkBEGIN) or token.is_a?(RubyToken::TkCASE) or
321
+ token.is_a?(RubyToken::TkCLASS) or token.is_a?(RubyToken::TkDEF) or
322
+ token.is_a?(RubyToken::TkFOR) or token.is_a?(RubyToken::TkIF) or
323
+ token.is_a?(RubyToken::TkMODULE) or token.is_a?(RubyToken::TkUNLESS) or
324
+ token.is_a?(RubyToken::TkUNTIL) or token.is_a?(RubyToken::TkWHILE) or
325
+ token.is_a?(RubyToken::TklBEGIN)
326
+ nesting_level += 1
327
+ end
328
+ end
329
+ end
330
+
331
+ if start_token and end_token
332
+ start_line, end_line = start_token.line_no - 1, end_token.line_no - 1
333
+ source = lines[start_line .. end_line]
334
+ start_offset = start_token.char_no
335
+ start_offset += 1 if start_token.is_a?(RubyToken::TkDO)
336
+ end_offset = -(source.last.length - end_token.char_no)
337
+ source.first.slice!(0 .. start_offset)
338
+ source.last.slice!(end_offset .. -1)
339
+
340
+ # Can't use .strip because newline at end of code might be important
341
+ # (Stuff would break when somebody does proc { ... #foo\n})
342
+ proc.source = source.join.gsub(/^ | $/, "")
343
+ end
344
+ end
345
+
346
+ module_function :handle, :get_lines
347
+ end
348
+
349
+ class Proc #:nodoc:
350
+ attr_reader :file, :line
351
+
352
+ def source_descriptor
353
+ return @file, @line.to_i if @file && @line
354
+ md = /^#<Proc:0x[0-9A-Fa-f]+@(.+):(\d+)(.+?)?>$/.match(old_inspect)
355
+ if md
356
+ @file, @line = md.captures
357
+ return @file, @line.to_i
358
+ end
359
+ end
360
+
361
+ def self.source_cache
362
+ @source_cache ||= {}
363
+ end
364
+
365
+ def source=(code)
366
+ @source = Proc.source_cache[source_descriptor.join('/')] = code
367
+ end
368
+
369
+ def source
370
+ @source = Proc.source_cache[source_descriptor.join('/')]
371
+ ProcSource.handle(self) #unless @source
372
+ @source
373
+ end
374
+
375
+ alias :old_inspect :inspect
376
+ def inspect
377
+ if source
378
+ "proc {#{source}}"
379
+ else
380
+ old_inspect
381
+ end
382
+ end
383
+
384
+ def ==(other)
385
+ if self.source && other.respond_to?(:source) && other.source
386
+ self.source == other.source
387
+ else
388
+ self.object_id == other.object_id
389
+ end
390
+ end
391
+
392
+ def _dump(depth = 0)
393
+ if source
394
+ source
395
+ else
396
+ raise(TypeError, "Can't serialize Proc with unknown source code.")
397
+ end
398
+ end
399
+
400
+ def to_yaml(*args)
401
+ #self.source # force @source to be set
402
+ a = super
403
+ a.sub!("object:Proc", "proc") if a.respond_to? :sub
404
+ a
405
+ end
406
+
407
+ def self.allocate; from_string ""; end
408
+
409
+ def self.from_string(string)
410
+ result = eval("proc {#{string}}")
411
+ result.source = string
412
+ return result
413
+ end
414
+
415
+ def self._load(code)
416
+ self.from_string(code)
417
+ end
418
+
419
+ def self.marshal_load; end
420
+ def marshal_load; end
421
+ end
422
+
423
+ require 'yaml'
424
+ YAML.add_ruby_type(/^proc/) do |type, val|
425
+ Proc.from_string(val["source"])
426
+ end
427
+
428
+ # EVAL_LINES__ = Hash.new
429
+ #
430
+ # alias :old_eval :eval
431
+ # def eval(code, *args)
432
+ # context, descriptor, start_line, *more = *args
433
+ # descriptor ||= "(eval#{code.hash})"
434
+ # start_line ||= 0
435
+ # lines ||= code.grep(/.*/)
436
+ # EVAL_LINES__[descriptor] ||= Array.new
437
+ # EVAL_LINES__[descriptor][start_line, lines.length] = lines
438
+ # old_eval(code, context, descriptor, start_line, *more)
439
+ # end
440
+
441
+
442
+ if __FILE__ == $0 then
443
+ require "pstore"
444
+
445
+ code = Proc.new() {
446
+ puts "Hello World!"
447
+ }
448
+
449
+
450
+ File.open("proc.marshalled", "w") { |file| Marshal.dump(code, file) }
451
+ code = File.open("proc.marshalled") { |file| Marshal.load(file) }
452
+
453
+ code.call
454
+
455
+ store = PStore.new("proc.pstore")
456
+ store.transaction do
457
+ store["proc"] = code
458
+ end
459
+ store.transaction do
460
+ code = store["proc"]
461
+ end
462
+
463
+ code.call
464
+
465
+ File.open("proc.yaml", "w") { |file| YAML.dump(code) }
466
+ #code = File.open("proc.yaml") { |file| YAML.load(file) }
467
+
468
+ code.call
469
+ end
data/lib/stella/cli.rb CHANGED
@@ -79,7 +79,11 @@ class Stella::CLI < Drydock::Command
79
79
 
80
80
  def preview
81
81
  create_testplan
82
- Stella.stdout.info @testplan.pretty(Stella.stdout.lev > 1)
82
+ if @global.format == 'json'
83
+ Stella.stdout.info @testplan.to_json
84
+ else
85
+ Stella.stdout.info @testplan.pretty(Stella.stdout.lev > 1)
86
+ end
83
87
  end
84
88
 
85
89
  private
@@ -19,18 +19,18 @@ class Stella::Client
19
19
  @sequential_offset[resid]
20
20
  end
21
21
  end
22
- ## TODO: BROKEN?
23
- ##def rsequential_offset(resid, max)
24
- ## MUTEX.synchronize do
25
- ## @rsequential_offset[resid] ||= max+1
26
- ## if @rsequential_offset[resid] <= 0
27
- ## @rsequential_offset[resid] = max
28
- ## else
29
- ## @rsequential_offset[resid] -= 1
30
- ## end
31
- ## @rsequential_offset[resid]
32
- ## end
33
- ##end
22
+
23
+ def rsequential_offset(resid, max)
24
+ MUTEX.synchronize do
25
+ @rsequential_offset[resid] ||= max+1
26
+ if @rsequential_offset[resid] <= 0
27
+ @rsequential_offset[resid] = max
28
+ else
29
+ @rsequential_offset[resid] -= 1
30
+ end
31
+ @rsequential_offset[resid]
32
+ end
33
+ end
34
34
  end
35
35
 
36
36
  # This is used to handle custom exception in usecases.
@@ -95,6 +95,7 @@ class Stella::Client
95
95
 
96
96
  def doc
97
97
  return @doc unless @doc.nil?
98
+ return nil if body.nil? || body.empty?
98
99
  # NOTE: It's important to parse the document on every
99
100
  # request because this container is available for the
100
101
  # entire life of a usecase.
@@ -204,7 +205,6 @@ class Stella::Client
204
205
 
205
206
  def file(*args)
206
207
  input = args.size > 1 ? args : args.first
207
-
208
208
  value = case input.class.to_s
209
209
  when "String"
210
210
  Stella.ld "FILE: #{input}"
@@ -5,16 +5,13 @@ module Stella::Data::HTTP
5
5
  include Gibbler::Complex
6
6
  include Stella::Data::Helpers
7
7
 
8
- # A hash containing blocks to be executed depending on the HTTP response status.
9
- # The hash keys are numeric HTTP Status Codes.
10
- #
11
- # 200 => { ... }
12
- # 304 => { ... }
13
- # 500 => { ... }
14
- #
15
- attr_accessor :response_handler
8
+ field :id, &gibbler_id_processor
16
9
 
10
+ # Store the description in the attic so
11
+ # it's not used in the gibbler digest.
12
+ attic :description
17
13
  field :description
14
+
18
15
  field :header
19
16
  field :uri
20
17
  field :wait
@@ -25,7 +22,14 @@ module Stella::Data::HTTP
25
22
  field :content_type
26
23
  field :http_auth
27
24
 
28
- attic :description
25
+ # A hash containing blocks to be executed depending on the HTTP response status.
26
+ # The hash keys are numeric HTTP Status Codes.
27
+ #
28
+ # 200 => { ... }
29
+ # 304 => { ... }
30
+ # 500 => { ... }
31
+ #
32
+ field :response_handler, &hash_proc_processor
29
33
 
30
34
  def has_body?
31
35
  !@body.nil?
data/lib/stella/data.rb CHANGED
@@ -36,6 +36,27 @@ module Stella::Data
36
36
  end
37
37
  end
38
38
 
39
+ def read_file(*args)
40
+ input = args.size > 1 ? args : args.first
41
+ Proc.new do
42
+ case input.class.to_s
43
+ when "String"
44
+ file(input).read # This is the file method defined in Container.
45
+ when "Proc"
46
+ input.call
47
+ else
48
+ input
49
+ end
50
+ end
51
+ end
52
+
53
+ def path(*args)
54
+ input = File.join *args
55
+ Proc.new do
56
+ File.exists?(input) ? input : File.join(@base_path, input)
57
+ end
58
+ end
59
+
39
60
  def file(*args)
40
61
  input = args.size > 1 ? args : args.first
41
62
  Proc.new do
@@ -144,6 +165,48 @@ module Stella::Data
144
165
  end
145
166
  end
146
167
 
168
+ # NOTE: This is global across all users
169
+ def rsequential(*args)
170
+ if Symbol === args.first
171
+ input, index = *args
172
+ elsif Array === args.first || args.size == 1
173
+ input = args.first
174
+ else
175
+ input = args
176
+ end
177
+ Proc.new do
178
+ if @rsequential_value[input.object_id]
179
+ value = @rsequential_value[input.object_id]
180
+ else
181
+ value = case input.class.to_s
182
+ when "Symbol"
183
+ ret = resource(input)
184
+ ret
185
+ when "Array"
186
+ input
187
+ when "Range"
188
+ input.to_a
189
+ when "Proc"
190
+ input.call
191
+ end
192
+ digest = value.object_id
193
+ if value.is_a?(Array)
194
+ idx = Stella::Client::Container.rsequential_offset(digest, value.size-1)
195
+ value = value[ idx ]
196
+ Stella.ld "SELECTED(RSEQ): #{value} #{idx} #{input} #{digest}"
197
+ end
198
+
199
+ # I think this needs to be updated for global_sequential:
200
+ @rsequential_value[input.object_id] = value
201
+ end
202
+ # The resource may be an Array of Arrays (e.g. a CSV file)
203
+ if value.is_a?(Array) && !index.nil?
204
+ value = value[ index ]
205
+ Stella.ld "SELECTED INDEX: #{index} #{value.inspect} "
206
+ end
207
+ value
208
+ end
209
+ end
147
210
 
148
211
  ###
149
212
  ### Disabled b/c it doesn't work anymore since a
@@ -2,7 +2,7 @@ autoload :CSV, 'csv'
2
2
  #Gibbler.enable_debug
3
3
 
4
4
  module Stella
5
- class Testplan
5
+ class Testplan < Storable
6
6
  include Gibbler::Complex
7
7
  extend Attic
8
8
 
@@ -24,15 +24,16 @@ class Testplan
24
24
  attic :plan_path
25
25
  attic :description
26
26
 
27
- attr_accessor :usecases
28
- attr_reader :stats
27
+ field :id, &gibbler_id_processor
28
+
29
+ field :usecases
30
+ field :description
29
31
 
30
32
  def initialize(uris=[], opts={})
31
33
  self.description = "Test plan"
32
34
  @usecases = []
33
35
  @testplan_current_ratio = 0
34
- @stats = Stella::Testplan::Stats.new
35
-
36
+
36
37
  unless uris.empty?
37
38
  uris = [uris] unless Array === uris
38
39
  usecase = Stella::Testplan::Usecase.new
@@ -109,6 +110,8 @@ class Testplan
109
110
  self.description
110
111
  end
111
112
 
113
+
114
+
112
115
  def pretty(long=false)
113
116
  str = []
114
117
  dig = long ? self.digest_cache : self.digest_cache.shorter
@@ -125,8 +128,12 @@ class Testplan
125
128
  dig = long ? r.digest_cache : r.digest_cache.shorter
126
129
  str << " %-62s".bright % ["#{r.description} (#{dig})"]
127
130
  str << " %s" % [r]
128
- if Stella.stdout.lev > 2
131
+ if Stella.stdout.lev > 1
129
132
  [:wait].each { |i| str << " %s: %s" % [i, r.send(i)] }
133
+ str << ' %s: %s' % ['params', r.params.inspect]
134
+ r.response_handler.each do |status,proc|
135
+ str << " response: %s%s" % [status, proc.source.split($/).join("#{$/} ")]
136
+ end
130
137
  end
131
138
  end
132
139
  end
@@ -159,7 +166,7 @@ class Testplan
159
166
  # }
160
167
  # }
161
168
  #
162
- class Usecase
169
+ class Usecase < Storable
163
170
  include Gibbler::Complex
164
171
  include Stella::Data::Helpers
165
172
  extend Attic
@@ -170,14 +177,16 @@ class Testplan
170
177
 
171
178
  attic :base_path # we don't want gibbler to see this
172
179
  attic :plan_path
173
- attic :description
174
180
 
181
+ field :id, &gibbler_id_processor
175
182
 
176
- attr_writer :ratio
177
- attr_reader :http_auth
183
+ attic :description
184
+ field :description
178
185
 
179
- attr_accessor :requests
180
- attr_accessor :resources
186
+ field :ratio
187
+ field :http_auth
188
+ field :requests
189
+ field :resources
181
190
 
182
191
  class UnknownResource < Stella::Error
183
192
  def message; "UnknownResource: #{@obj}"; end
@@ -275,30 +284,3 @@ class Testplan
275
284
  end
276
285
  end
277
286
 
278
-
279
-
280
- module Stella
281
- class Testplan
282
-
283
- class Stats
284
- include Gibbler::Complex
285
- attr_reader :requests
286
-
287
- def initialize
288
- @requests = OpenStruct.new
289
- reset
290
- end
291
-
292
- def total_requests
293
- @requests.successful + @requests.failed
294
- end
295
-
296
- def reset
297
- @requests.successful = 0
298
- @requests.failed = 0
299
- end
300
-
301
- end
302
-
303
- end
304
- end
data/lib/stella.rb CHANGED
@@ -15,6 +15,7 @@ autoload :ERB, 'erb'
15
15
 
16
16
  require 'gibbler/aliases' # important for run time digests and freezes
17
17
  require 'benelux'
18
+ require 'proc_source'
18
19
 
19
20
  module Stella
20
21
  module VERSION
@@ -22,7 +23,7 @@ module Stella
22
23
  MAJOR = 0.freeze
23
24
  MINOR = 7.freeze
24
25
  TINY = 6.freeze
25
- PATCH = '001'.freeze
26
+ PATCH = '003'.freeze
26
27
  end
27
28
  def self.to_s; [MAJOR, MINOR, TINY].join('.'); end
28
29
  def self.to_f; self.to_s.to_f; end
@@ -113,5 +114,23 @@ Stella.stdout.autoflush!
113
114
 
114
115
 
115
116
 
117
+ class Storable
118
+ # These methods are used by Storable objects.
119
+ # See Stella::Testplan
120
+ module DefaultProcessors
121
+ # If the object already has a value for +@id+
122
+ # use it, otherwise return the current digest.
123
+ #
124
+ # This allows an object to have a preset ID.
125
+ #
126
+ # NOTE: Does not assign a value to +@id+.
127
+ def gibbler_id_processor
128
+ Proc.new do |val|
129
+ @id || self.gibbler
130
+ end
131
+ end
132
+ end
133
+ end
134
+
116
135
 
117
136
 
data/stella.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  @spec = Gem::Specification.new do |s|
2
2
  s.name = "stella"
3
3
  s.rubyforge_project = 'stella'
4
- s.version = "0.7.6.001"
4
+ s.version = "0.7.6.003"
5
5
  s.summary = "Blame Stella for breaking your web applications."
6
6
  s.description = s.summary
7
7
  s.author = "Delano Mandelbaum"
@@ -19,7 +19,7 @@
19
19
  s.add_dependency 'drydock', '>= 0.6.8'
20
20
  s.add_dependency 'gibbler', '>= 0.7.1'
21
21
  s.add_dependency 'sysinfo', '>= 0.7.1'
22
- s.add_dependency 'storable', '>= 0.5.8'
22
+ s.add_dependency 'storable', '>= 0.6.0'
23
23
  s.add_dependency 'nokogiri'
24
24
 
25
25
  # = MANIFEST =
@@ -38,6 +38,7 @@
38
38
  examples/essentials/plan.rb
39
39
  examples/essentials/search_terms.txt
40
40
  examples/exceptions/plan.rb
41
+ lib/proc_source.rb
41
42
  lib/stella.rb
42
43
  lib/stella/cli.rb
43
44
  lib/stella/client.rb
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stella
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.6.001
4
+ version: 0.7.6.003
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delano Mandelbaum
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-24 00:00:00 -05:00
12
+ date: 2009-11-28 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -60,7 +60,7 @@ dependencies:
60
60
  requirements:
61
61
  - - ">="
62
62
  - !ruby/object:Gem::Version
63
- version: 0.5.8
63
+ version: 0.6.0
64
64
  version:
65
65
  - !ruby/object:Gem::Dependency
66
66
  name: nokogiri
@@ -96,6 +96,7 @@ files:
96
96
  - examples/essentials/plan.rb
97
97
  - examples/essentials/search_terms.txt
98
98
  - examples/exceptions/plan.rb
99
+ - lib/proc_source.rb
99
100
  - lib/stella.rb
100
101
  - lib/stella/cli.rb
101
102
  - lib/stella/client.rb