stella 0.3.2 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. data/README.txt +24 -84
  2. data/Rakefile +1 -6
  3. data/doc/classes/Crypto.html +248 -0
  4. data/doc/classes/Crypto/Key.html +308 -0
  5. data/doc/classes/Enumerable.html +309 -0
  6. data/doc/classes/FileUtil.html +310 -0
  7. data/doc/classes/HTTPUtil.html +530 -0
  8. data/doc/classes/MathUtil.html +210 -0
  9. data/doc/classes/Stella.html +238 -0
  10. data/doc/classes/Stella/Adapter.html +127 -0
  11. data/doc/classes/Stella/Adapter/ApacheBench.html +1076 -0
  12. data/doc/classes/Stella/Adapter/Base.html +432 -0
  13. data/doc/classes/Stella/Adapter/CommandNotReady.html +146 -0
  14. data/doc/classes/Stella/Adapter/Httperf.html +949 -0
  15. data/doc/classes/Stella/Adapter/Siege.html +1011 -0
  16. data/doc/classes/Stella/CLI.html +914 -0
  17. data/doc/classes/Stella/CLI/Base.html +186 -0
  18. data/doc/classes/Stella/CLI/Language.html +149 -0
  19. data/doc/classes/Stella/CLI/LocalTest.html +268 -0
  20. data/doc/classes/Stella/Command.html +111 -0
  21. data/doc/classes/Stella/Command/Base.html +335 -0
  22. data/doc/classes/Stella/Config.html +292 -0
  23. data/doc/classes/Stella/InvalidArgument.html +242 -0
  24. data/doc/classes/Stella/LocalTest.html +450 -0
  25. data/doc/classes/Stella/Logger.html +548 -0
  26. data/doc/classes/Stella/Response.html +846 -0
  27. data/doc/classes/Stella/Storable.html +928 -0
  28. data/doc/classes/Stella/Test.html +142 -0
  29. data/doc/classes/Stella/Test/DaySummary.html +249 -0
  30. data/doc/classes/Stella/Test/Definition.html +294 -0
  31. data/doc/classes/Stella/Test/Definition/Rampup.html +215 -0
  32. data/doc/classes/Stella/Test/RunSummary.html +315 -0
  33. data/doc/classes/Stella/Test/SummaryBase.html +286 -0
  34. data/doc/classes/Stella/Test/TestSummary.html +200 -0
  35. data/doc/classes/Stella/Text.html +581 -0
  36. data/doc/classes/Stella/Text/Resource.html +289 -0
  37. data/doc/classes/Stella/UnavailableAdapter.html +242 -0
  38. data/doc/classes/Stella/UnknownValue.html +242 -0
  39. data/doc/classes/Stella/UnsupportedLanguage.html +115 -0
  40. data/doc/classes/Stella/Util.html +348 -0
  41. data/doc/classes/TextGraph.html +460 -0
  42. data/doc/classes/TimerUtil.html +431 -0
  43. data/doc/created.rid +1 -0
  44. data/doc/files/LICENSE_txt.html +129 -0
  45. data/doc/files/README_txt.html +209 -0
  46. data/doc/files/lib/stella/adapter/ab_rb.html +101 -0
  47. data/doc/files/lib/stella/adapter/base_rb.html +101 -0
  48. data/doc/files/lib/stella/adapter/httperf_rb.html +101 -0
  49. data/doc/files/lib/stella/adapter/siege_rb.html +101 -0
  50. data/doc/files/lib/stella/cli/base_rb.html +101 -0
  51. data/doc/files/lib/stella/cli/language_rb.html +101 -0
  52. data/doc/files/lib/stella/cli/localtest_rb.html +101 -0
  53. data/doc/files/lib/stella/cli_rb.html +112 -0
  54. data/doc/files/lib/stella/command/base_rb.html +101 -0
  55. data/doc/files/lib/stella/command/localtest_rb.html +101 -0
  56. data/doc/files/lib/stella/logger_rb.html +101 -0
  57. data/doc/files/lib/stella/response_rb.html +101 -0
  58. data/doc/files/lib/stella/storable_rb.html +109 -0
  59. data/doc/files/lib/stella/support_rb.html +101 -0
  60. data/doc/files/lib/stella/test/daysummary_rb.html +101 -0
  61. data/doc/files/lib/stella/test/definition_rb.html +101 -0
  62. data/doc/files/lib/stella/test/runsummary_rb.html +101 -0
  63. data/doc/files/lib/stella/test/summarybase_rb.html +101 -0
  64. data/doc/files/lib/stella/test/testsummary_rb.html +108 -0
  65. data/doc/files/lib/stella/text/resource_rb.html +108 -0
  66. data/doc/files/lib/stella/text_rb.html +108 -0
  67. data/doc/files/lib/stella_rb.html +128 -0
  68. data/doc/files/lib/utils/crypto-key_rb.html +116 -0
  69. data/doc/files/lib/utils/fileutil_rb.html +108 -0
  70. data/doc/files/lib/utils/httputil_rb.html +110 -0
  71. data/doc/files/lib/utils/mathutil_rb.html +101 -0
  72. data/doc/files/lib/utils/textgraph_rb.html +138 -0
  73. data/doc/files/lib/utils/timerutil_rb.html +108 -0
  74. data/doc/fr_class_index.html +66 -0
  75. data/doc/fr_file_index.html +62 -0
  76. data/doc/fr_method_index.html +309 -0
  77. data/doc/index.html +24 -0
  78. data/doc/rdoc-style.css +208 -0
  79. data/lib/stella.rb +5 -6
  80. data/lib/stella/adapter/ab.rb +4 -31
  81. data/lib/stella/adapter/base.rb +1 -15
  82. data/lib/stella/adapter/httperf.rb +4 -35
  83. data/lib/stella/adapter/siege.rb +29 -51
  84. data/lib/stella/cli.rb +22 -45
  85. data/lib/stella/cli/language.rb +0 -2
  86. data/lib/stella/cli/localtest.rb +0 -5
  87. data/lib/stella/command/base.rb +1 -1
  88. data/lib/stella/command/localtest.rb +68 -84
  89. data/lib/stella/test/daysummary.rb +93 -0
  90. data/lib/stella/test/definition.rb +5 -10
  91. data/lib/stella/test/{run/summary.rb → runsummary.rb} +6 -4
  92. data/lib/stella/test/{base.rb → summarybase.rb} +7 -3
  93. data/lib/stella/test/{summary.rb → testsummary.rb} +29 -27
  94. data/lib/utils/mathutil.rb +34 -36
  95. data/spec/base.rb +26 -0
  96. data/spec/shell_spec.rb +12 -0
  97. data/support/text/en.yaml +1 -7
  98. metadata +102 -8
  99. data/lib/stella/cli/agents.rb +0 -73
  100. data/lib/utils/escape.rb +0 -302
@@ -1,73 +0,0 @@
1
-
2
-
3
-
4
- module Stella
5
- class CLI
6
-
7
- class Agents < Stella::CLI::Base
8
-
9
- attr_accessor :full
10
- attr_accessor :list
11
- attr_accessor :search
12
- attr_accessor :help
13
-
14
- def initialize(adapter)
15
- super(adapter)
16
- @full = false
17
- @list = false
18
- @help = false
19
- end
20
-
21
- def run
22
- process_options
23
-
24
- if @help
25
- process_options(:display)
26
- return
27
- end
28
-
29
- # The LocalTest command is the keeper of the user agents
30
- localtest = Stella::LocalTest.new
31
-
32
- agents = []
33
- all_agents = localtest.available_agents
34
- all_agents.each_pair do |key,value|
35
- if (@full)
36
- value.each do |full_value|
37
- agent = full_value.join(' ')
38
- agents << agent if (!@search || agent.to_s.match(/#{search}/i))
39
- end
40
- else
41
- agents << key.to_s if (!@search || key.to_s.match(/#{search}/i))
42
- end
43
- end
44
-
45
- puts (@list) ? agents.uniq.sort.join("\n") : Stella::TEXT.msg(:agents_count_message, agents.uniq.size)
46
-
47
- end
48
-
49
- def process_options(display=false)
50
-
51
- opts = OptionParser.new
52
- opts.banner = Stella::TEXT.msg(:option_help_usage)
53
- opts.on('-h', '--help', Stella::TEXT.msg(:option_help_help)) { @help = true }
54
- opts.on('-f', '--full', Stella::TEXT.msg(:agents_option_full)) { @full = true }
55
- opts.on('-l', '--list', Stella::TEXT.msg(:agents_option_list)) { @list = true }
56
- # TODO: display agents based on shortnames. This is important to maintain continuity with the stella option.
57
- #opts.on('-a', '--agent', Stella::TEXT.msg(:agents_option_list)) { @list = true }
58
- opts.on('-s', '--search=S', String, Stella::TEXT.msg(:agents_option_search)) { |v| @search = v }
59
-
60
- opts.parse!(@arguments)
61
-
62
- if display
63
- Stella::LOGGER.info opts
64
- return
65
- end
66
-
67
- end
68
-
69
- end
70
-
71
- @@commands['agents'] = Stella::CLI::Agents
72
- end
73
- end
@@ -1,302 +0,0 @@
1
- # escape.rb - escape/unescape library for several formats
2
- #
3
- # Copyright (C) 2006,2007 Tanaka Akira <akr@fsij.org>
4
- #
5
- # Redistribution and use in source and binary forms, with or without
6
- # modification, are permitted provided that the following conditions are met:
7
- #
8
- # 1. Redistributions of source code must retain the above copyright notice, this
9
- # list of conditions and the following disclaimer.
10
- # 2. Redistributions in binary form must reproduce the above copyright notice,
11
- # this list of conditions and the following disclaimer in the documentation
12
- # and/or other materials provided with the distribution.
13
- # 3. The name of the author may not be used to endorse or promote products
14
- # derived from this software without specific prior written permission.
15
- #
16
- # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17
- # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18
- # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19
- # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20
- # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21
- # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22
- # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23
- # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24
- # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25
- # OF SUCH DAMAGE.
26
-
27
- # Escape module provides several escape functions.
28
- # * URI
29
- # * HTML
30
- # * shell command
31
- module EscapeUtil
32
- module_function
33
-
34
- class StringWrapper
35
- class << self
36
- alias new_no_dup new
37
- def new(str)
38
- new_no_dup(str.dup)
39
- end
40
- end
41
-
42
- def initialize(str)
43
- @str = str
44
- end
45
-
46
- def to_s
47
- @str.dup
48
- end
49
-
50
- def inspect
51
- "\#<#{self.class}: #{@str}>"
52
- end
53
-
54
- def ==(other)
55
- other.class == self.class && @str == other.instance_variable_get(:@str)
56
- end
57
- alias eql? ==
58
-
59
- def hash
60
- @str.hash
61
- end
62
- end
63
-
64
- class ShellEscaped < StringWrapper
65
- end
66
-
67
- # Escape.shell_command composes
68
- # a sequence of words to
69
- # a single shell command line.
70
- # All shell meta characters are quoted and
71
- # the words are concatenated with interleaving space.
72
- # It returns an instance of ShellEscaped.
73
- #
74
- # Escape.shell_command(["ls", "/"]) #=> #<Escape::ShellEscaped: ls />
75
- # Escape.shell_command(["echo", "*"]) #=> #<Escape::ShellEscaped: echo '*'>
76
- #
77
- # Note that system(*command) and
78
- # system(Escape.shell_command(command)) is roughly same.
79
- # There are two exception as follows.
80
- # * The first is that the later may invokes /bin/sh.
81
- # * The second is an interpretation of an array with only one element:
82
- # the element is parsed by the shell with the former but
83
- # it is recognized as single word with the later.
84
- # For example, system(*["echo foo"]) invokes echo command with an argument "foo".
85
- # But system(Escape.shell_command(["echo foo"])) invokes "echo foo" command without arguments (and it probably fails).
86
- def shell_command(command)
87
- s = command.map {|word| shell_single_word(word) }.join(' ')
88
- ShellEscaped.new_no_dup(s)
89
- end
90
-
91
- # Escape.shell_single_word quotes shell meta characters.
92
- # It returns an instance of ShellEscaped.
93
- #
94
- # The result string is always single shell word, even if
95
- # the argument is "".
96
- # Escape.shell_single_word("") returns #<Escape::ShellEscaped: ''>.
97
- #
98
- # Escape.shell_single_word("") #=> #<Escape::ShellEscaped: ''>
99
- # Escape.shell_single_word("foo") #=> #<Escape::ShellEscaped: foo>
100
- # Escape.shell_single_word("*") #=> #<Escape::ShellEscaped: '*'>
101
- def shell_single_word(str)
102
- if str && str.empty?
103
- ShellEscaped.new_no_dup("''")
104
- elsif %r{\A[0-9A-Za-z+,./:=@_-]+\z} =~ str
105
- ShellEscaped.new(str)
106
- else
107
- result = ''
108
- str.scan(/('+)|[^']+/) {
109
- if $1
110
- result << %q{\'} * $1.length
111
- else
112
- result << "'#{$&}'"
113
- end
114
- }
115
- ShellEscaped.new_no_dup(result)
116
- end
117
- end
118
-
119
- class PercentEncoded < StringWrapper
120
- end
121
-
122
- # Escape.uri_segment escapes URI segment using percent-encoding.
123
- # It returns an instance of PercentEncoded.
124
- #
125
- # Escape.uri_segment("a/b") #=> #<Escape::PercentEncoded: a%2Fb>
126
- #
127
- # The segment is "/"-splitted element after authority before query in URI, as follows.
128
- #
129
- # scheme://authority/segment1/segment2/.../segmentN?query#fragment
130
- #
131
- # See RFC 3986 for details of URI.
132
- def uri_segment(str)
133
- # pchar - pct-encoded = unreserved / sub-delims / ":" / "@"
134
- # unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
135
- # sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
136
- s = str.gsub(%r{[^A-Za-z0-9\-._~!$&'()*+,;=:@]}n) {
137
- '%' + $&.unpack("H2")[0].upcase
138
- }
139
- PercentEncoded.new_no_dup(s)
140
- end
141
-
142
- # Escape.uri_path escapes URI path using percent-encoding.
143
- # The given path should be a sequence of (non-escaped) segments separated by "/".
144
- # The segments cannot contains "/".
145
- # It returns an instance of PercentEncoded.
146
- #
147
- # Escape.uri_path("a/b/c") #=> #<Escape::PercentEncoded: a/b/c>
148
- # Escape.uri_path("a?b/c?d/e?f") #=> #<Escape::PercentEncoded: a%3Fb/c%3Fd/e%3Ff>
149
- #
150
- # The path is the part after authority before query in URI, as follows.
151
- #
152
- # scheme://authority/path#fragment
153
- #
154
- # See RFC 3986 for details of URI.
155
- #
156
- # Note that this function is not appropriate to convert OS path to URI.
157
- def uri_path(str)
158
- s = str.gsub(%r{[^/]+}n) { uri_segment($&) }
159
- PercentEncoded.new_no_dup(s)
160
- end
161
-
162
- # :stopdoc:
163
- def html_form_fast(pairs, sep='&')
164
- s = pairs.map {|k, v|
165
- # query-chars - pct-encoded - x-www-form-urlencoded-delimiters =
166
- # unreserved / "!" / "$" / "'" / "(" / ")" / "*" / "," / ":" / "@" / "/" / "?"
167
- # query-char - pct-encoded = unreserved / sub-delims / ":" / "@" / "/" / "?"
168
- # query-char = pchar / "/" / "?" = unreserved / pct-encoded / sub-delims / ":" / "@" / "/" / "?"
169
- # unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
170
- # sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
171
- # x-www-form-urlencoded-delimiters = "&" / "+" / ";" / "="
172
- k = k.gsub(%r{[^0-9A-Za-z\-\._~:/?@!\$'()*,]}n) {
173
- '%' + $&.unpack("H2")[0].upcase
174
- }
175
- v = v.gsub(%r{[^0-9A-Za-z\-\._~:/?@!\$'()*,]}n) {
176
- '%' + $&.unpack("H2")[0].upcase
177
- }
178
- "#{k}=#{v}"
179
- }.join(sep)
180
- PercentEncoded.new_no_dup(s)
181
- end
182
- # :startdoc:
183
-
184
- # Escape.html_form composes HTML form key-value pairs as a x-www-form-urlencoded encoded string.
185
- # It returns an instance of PercentEncoded.
186
- #
187
- # Escape.html_form takes an array of pair of strings or
188
- # an hash from string to string.
189
- #
190
- # Escape.html_form([["a","b"], ["c","d"]]) #=> #<Escape::PercentEncoded: a=b&c=d>
191
- # Escape.html_form({"a"=>"b", "c"=>"d"}) #=> #<Escape::PercentEncoded: a=b&c=d>
192
- #
193
- # In the array form, it is possible to use same key more than once.
194
- # (It is required for a HTML form which contains
195
- # checkboxes and select element with multiple attribute.)
196
- #
197
- # Escape.html_form([["k","1"], ["k","2"]]) #=> #<Escape::PercentEncoded: k=1&k=2>
198
- #
199
- # If the strings contains characters which must be escaped in x-www-form-urlencoded,
200
- # they are escaped using %-encoding.
201
- #
202
- # Escape.html_form([["k=","&;="]]) #=> #<Escape::PercentEncoded: k%3D=%26%3B%3D>
203
- #
204
- # The separator can be specified by the optional second argument.
205
- #
206
- # Escape.html_form([["a","b"], ["c","d"]], ";") #=> #<Escape::PercentEncoded: a=b;c=d>
207
- #
208
- # See HTML 4.01 for details.
209
- def html_form(pairs, sep='&')
210
- r = ''
211
- first = true
212
- pairs.each {|k, v|
213
- # query-chars - pct-encoded - x-www-form-urlencoded-delimiters =
214
- # unreserved / "!" / "$" / "'" / "(" / ")" / "*" / "," / ":" / "@" / "/" / "?"
215
- # query-char - pct-encoded = unreserved / sub-delims / ":" / "@" / "/" / "?"
216
- # query-char = pchar / "/" / "?" = unreserved / pct-encoded / sub-delims / ":" / "@" / "/" / "?"
217
- # unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
218
- # sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
219
- # x-www-form-urlencoded-delimiters = "&" / "+" / ";" / "="
220
- r << sep if !first
221
- first = false
222
- k.each_byte {|byte|
223
- ch = byte.chr
224
- if %r{[^0-9A-Za-z\-\._~:/?@!\$'()*,]}n =~ ch
225
- r << "%" << ch.unpack("H2")[0].upcase
226
- else
227
- r << ch
228
- end
229
- }
230
- r << '='
231
- v.each_byte {|byte|
232
- ch = byte.chr
233
- if %r{[^0-9A-Za-z\-\._~:/?@!\$'()*,]}n =~ ch
234
- r << "%" << ch.unpack("H2")[0].upcase
235
- else
236
- r << ch
237
- end
238
- }
239
- }
240
- PercentEncoded.new_no_dup(r)
241
- end
242
-
243
- class HTMLEscaped < StringWrapper
244
- end
245
-
246
- # :stopdoc:
247
- HTML_TEXT_ESCAPE_HASH = {
248
- '&' => '&amp;',
249
- '<' => '&lt;',
250
- '>' => '&gt;',
251
- }
252
- # :startdoc:
253
-
254
- # Escape.html_text escapes a string appropriate for HTML text using character references.
255
- # It returns an instance of HTMLEscaped.
256
- #
257
- # It escapes 3 characters:
258
- # * '&' to '&amp;'
259
- # * '<' to '&lt;'
260
- # * '>' to '&gt;'
261
- #
262
- # Escape.html_text("abc") #=> #<Escape::HTMLEscaped: abc>
263
- # Escape.html_text("a & b < c > d") #=> #<Escape::HTMLEscaped: a &amp; b &lt; c &gt; d>
264
- #
265
- # This function is not appropriate for escaping HTML element attribute
266
- # because quotes are not escaped.
267
- def html_text(str)
268
- s = str.gsub(/[&<>]/) {|ch| HTML_TEXT_ESCAPE_HASH[ch] }
269
- HTMLEscaped.new_no_dup(s)
270
- end
271
-
272
- # :stopdoc:
273
- HTML_ATTR_ESCAPE_HASH = {
274
- '&' => '&amp;',
275
- '<' => '&lt;',
276
- '>' => '&gt;',
277
- '"' => '&quot;',
278
- }
279
- # :startdoc:
280
-
281
- class HTMLAttrValue < StringWrapper
282
- end
283
-
284
- # Escape.html_attr_value encodes a string as a double-quoted HTML attribute using character references.
285
- # It returns an instance of HTMLAttrValue.
286
- #
287
- # Escape.html_attr_value("abc") #=> #<Escape::HTMLAttrValue: "abc">
288
- # Escape.html_attr_value("a&b") #=> #<Escape::HTMLAttrValue: "a&amp;b">
289
- # Escape.html_attr_value("ab&<>\"c") #=> #<Escape::HTMLAttrValue: "ab&amp;&lt;&gt;&quot;c">
290
- # Escape.html_attr_value("a'c") #=> #<Escape::HTMLAttrValue: "a'c">
291
- #
292
- # It escapes 4 characters:
293
- # * '&' to '&amp;'
294
- # * '<' to '&lt;'
295
- # * '>' to '&gt;'
296
- # * '"' to '&quot;'
297
- #
298
- def html_attr_value(str)
299
- s = '"' + str.gsub(/[&<>"]/) {|ch| HTML_ATTR_ESCAPE_HASH[ch] } + '"'
300
- HTMLAttrValue.new_no_dup(s)
301
- end
302
- end