stella 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/README.txt +135 -0
  2. data/Rakefile +100 -0
  3. data/bin/stella +12 -0
  4. data/lib/stella.rb +58 -0
  5. data/lib/stella/adapter/ab.rb +303 -0
  6. data/lib/stella/adapter/base.rb +87 -0
  7. data/lib/stella/adapter/httperf.rb +296 -0
  8. data/lib/stella/adapter/siege.rb +321 -0
  9. data/lib/stella/cli.rb +291 -0
  10. data/lib/stella/cli/agents.rb +73 -0
  11. data/lib/stella/cli/base.rb +19 -0
  12. data/lib/stella/cli/language.rb +18 -0
  13. data/lib/stella/cli/localtest.rb +80 -0
  14. data/lib/stella/command/base.rb +111 -0
  15. data/lib/stella/command/localtest.rb +339 -0
  16. data/lib/stella/logger.rb +63 -0
  17. data/lib/stella/response.rb +82 -0
  18. data/lib/stella/storable.rb +116 -0
  19. data/lib/stella/support.rb +106 -0
  20. data/lib/stella/test/base.rb +34 -0
  21. data/lib/stella/test/definition.rb +79 -0
  22. data/lib/stella/test/run/summary.rb +50 -0
  23. data/lib/stella/test/summary.rb +82 -0
  24. data/lib/stella/text.rb +64 -0
  25. data/lib/stella/text/resource.rb +39 -0
  26. data/lib/utils/crypto-key.rb +84 -0
  27. data/lib/utils/escape.rb +302 -0
  28. data/lib/utils/fileutil.rb +59 -0
  29. data/lib/utils/httputil.rb +210 -0
  30. data/lib/utils/mathutil.rb +78 -0
  31. data/lib/utils/textgraph.rb +267 -0
  32. data/lib/utils/timerutil.rb +58 -0
  33. data/support/text/en.yaml +54 -0
  34. data/support/text/nl.yaml +1 -0
  35. data/support/useragents.txt +75 -0
  36. data/vendor/useragent/MIT-LICENSE +20 -0
  37. data/vendor/useragent/README +21 -0
  38. data/vendor/useragent/init.rb +1 -0
  39. data/vendor/useragent/lib/user_agent.rb +83 -0
  40. data/vendor/useragent/lib/user_agent/browsers.rb +24 -0
  41. data/vendor/useragent/lib/user_agent/browsers/all.rb +69 -0
  42. data/vendor/useragent/lib/user_agent/browsers/gecko.rb +43 -0
  43. data/vendor/useragent/lib/user_agent/browsers/internet_explorer.rb +40 -0
  44. data/vendor/useragent/lib/user_agent/browsers/opera.rb +49 -0
  45. data/vendor/useragent/lib/user_agent/browsers/webkit.rb +94 -0
  46. data/vendor/useragent/lib/user_agent/comparable.rb +25 -0
  47. data/vendor/useragent/lib/user_agent/operating_systems.rb +19 -0
  48. data/vendor/useragent/spec/browsers/gecko_user_agent_spec.rb +209 -0
  49. data/vendor/useragent/spec/browsers/internet_explorer_user_agent_spec.rb +99 -0
  50. data/vendor/useragent/spec/browsers/opera_user_agent_spec.rb +59 -0
  51. data/vendor/useragent/spec/browsers/other_user_agent_spec.rb +19 -0
  52. data/vendor/useragent/spec/browsers/webkit_user_agent_spec.rb +373 -0
  53. data/vendor/useragent/spec/spec_helper.rb +1 -0
  54. data/vendor/useragent/spec/user_agent_spec.rb +331 -0
  55. data/vendor/useragent/useragent.gemspec +12 -0
  56. metadata +139 -0
@@ -0,0 +1,40 @@
1
+ class UserAgent
2
+ module Browsers
3
+ module InternetExplorer
4
+ def self.extend?(agent)
5
+ agent.application &&
6
+ agent.application.comment &&
7
+ agent.application.comment[0] == "compatible" &&
8
+ agent.application.comment[1].match(/^MSIE/)
9
+ end
10
+
11
+ def browser
12
+ "Internet Explorer"
13
+ end
14
+
15
+ def version=(v)
16
+ application.comment[1] = "MSIE #{v}"
17
+ end
18
+
19
+ def version
20
+ application.comment[1].sub("MSIE ", "")
21
+ end
22
+
23
+ def compatibility
24
+ application.comment[0]
25
+ end
26
+
27
+ def compatible?
28
+ compatibility == "compatible"
29
+ end
30
+
31
+ def platform
32
+ "Windows"
33
+ end
34
+
35
+ def os
36
+ OperatingSystems.normalize_os(application.comment[2])
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,49 @@
1
+ class UserAgent
2
+ module Browsers
3
+ module Opera
4
+ def self.extend?(agent)
5
+ agent.application && agent.application.product == "Opera"
6
+ end
7
+
8
+ def platform
9
+ if application.comment[0] =~ /Windows/
10
+ "Windows"
11
+ else
12
+ application.comment[0]
13
+ end
14
+ end
15
+
16
+ def security
17
+ if platform == "Macintosh"
18
+ Security[application.comment[2]]
19
+ else
20
+ Security[application.comment[1]]
21
+ end
22
+ end
23
+
24
+ def version
25
+ application.version
26
+ end
27
+
28
+ def version=(v)
29
+ application.version = v
30
+ end
31
+
32
+ def os
33
+ if application.comment[0] =~ /Windows/
34
+ OperatingSystems.normalize_os(application.comment[0])
35
+ else
36
+ application.comment[1]
37
+ end
38
+ end
39
+
40
+ def localization
41
+ if platform == "Macintosh"
42
+ application.comment[3]
43
+ else
44
+ application.comment[2]
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,94 @@
1
+ class UserAgent
2
+ module Browsers
3
+ module Webkit
4
+ def self.extend?(agent)
5
+ agent.detect { |useragent| useragent.product == "Safari" }
6
+ end
7
+
8
+ def browser
9
+ if detect_product("Chrome")
10
+ "Chrome"
11
+ else
12
+ "Safari"
13
+ end
14
+ end
15
+
16
+ def build
17
+ safari.version
18
+ end
19
+
20
+ # TODO: Complete this mapping
21
+ # See: http://www.useragentstring.com/pages/Safari/
22
+ BuildVersions = {
23
+ "125.12" => "1.2.4",
24
+ "312.6" => "1.3.2",
25
+ "412.2.2" => "2.0",
26
+ "412.5" => "2.0.1",
27
+ "416.13" => "2.0.2",
28
+ "417.9.3" => "2.0.3",
29
+ "525.13" => "2.2",
30
+ "522.11.3" => "3.0",
31
+ "523.15" => "3.0",
32
+ "523.12.9" => "3.0",
33
+ "522.12.2" => "3.0.1",
34
+ "522.13.1" => "3.0.2",
35
+ "522.15.5" => "3.0.3",
36
+ "523.10" => "3.0.4",
37
+ "523.15" => "3.0.4",
38
+ "523.12" => "3.0.4",
39
+ "523.12.2" => "3.0.4",
40
+ "525.13" => "3.1",
41
+ "525.13.3" => "3.1",
42
+ "525.9" => "3.1",
43
+ "525.17" => "3.1.1",
44
+ "525.9" => "3.1.1",
45
+ "525.20" => "3.1.1",
46
+ "525.18" => "3.1.1",
47
+ "525.21" => "3.1.2",
48
+ "525.26.13" => "3.2",
49
+ "525.26.12" => "3.2",
50
+ "528.1" => "4.0"
51
+
52
+ }.freeze unless defined? BuildVersions
53
+
54
+ # Prior to Safari 3, the user agent did not include a version number
55
+ def version
56
+ if browser == "Chrome"
57
+ chrome.version
58
+ elsif product = detect_product("Version")
59
+ product.version
60
+ else
61
+ BuildVersions[build]
62
+ end
63
+ end
64
+
65
+ def version=(v)
66
+ if browser == "Chrome"
67
+ chrome.version = v
68
+ elsif product = detect_product("Version")
69
+ product.version = v
70
+ end
71
+ end
72
+
73
+ def platform
74
+ application.comment[0]
75
+ end
76
+
77
+ def webkit
78
+ detect { |useragent| useragent.product == "AppleWebKit" }
79
+ end
80
+
81
+ def security
82
+ Security[application.comment[1]]
83
+ end
84
+
85
+ def os
86
+ OperatingSystems.normalize_os(application.comment[2])
87
+ end
88
+
89
+ def localization
90
+ application.comment[3]
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,25 @@
1
+ class UserAgent
2
+ # A custom Comparable module that will always return false
3
+ # if the <=> returns false
4
+ module Comparable
5
+ def <(other)
6
+ (c = self <=> other) ? c == -1 : false
7
+ end
8
+
9
+ def <=(other)
10
+ (c = self <=> other) ? c == -1 || c == 0 : false
11
+ end
12
+
13
+ def ==(other)
14
+ (c = self <=> other) ? c == 0 : false
15
+ end
16
+
17
+ def >(other)
18
+ (c = self <=> other) ? c == 1 : false
19
+ end
20
+
21
+ def >=(other)
22
+ (c = self <=> other) ? c == 1 || c == 0 : false
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,19 @@
1
+ class UserAgent
2
+ module OperatingSystems
3
+ Windows = {
4
+ "Windows NT 6.0" => "Windows Vista",
5
+ "Windows NT 5.2" => "Windows XP x64 Edition",
6
+ "Windows NT 5.1" => "Windows XP",
7
+ "Windows NT 5.01" => "Windows 2000, Service Pack 1 (SP1)",
8
+ "Windows NT 5.0" => "Windows 2000",
9
+ "Windows NT 4.0" => "Windows NT 4.0",
10
+ "Windows 98" => "Windows 98",
11
+ "Windows 95" => "Windows 95",
12
+ "Windows CE" => "Windows CE"
13
+ }.freeze unless defined? Windows
14
+
15
+ def self.normalize_os(os)
16
+ Windows[os] || os
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,209 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+ describe "Firefox browser", :shared => true do
4
+ it "should return 'Firefox' as its browser" do
5
+ @useragent.browser.should == "Firefox"
6
+ end
7
+
8
+ it "should return :strong as its security" do
9
+ @useragent.security.should == :strong
10
+ end
11
+ end
12
+
13
+ describe "UserAgent: 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1'" do
14
+ before do
15
+ @useragent = UserAgent.parse("Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1")
16
+ end
17
+
18
+ it_should_behave_like "Firefox browser"
19
+
20
+ it "should return '3.0.1' as its version" do
21
+ @useragent.version.should == "3.0.1"
22
+ end
23
+
24
+ it "should return '2008070206' as its gecko version" do
25
+ @useragent.gecko.version.should == "2008070206"
26
+ end
27
+
28
+ it "should return 'X11' as its platform" do
29
+ @useragent.platform.should == "X11"
30
+ end
31
+
32
+ it "should return 'Linux i686' as its os" do
33
+ @useragent.os.should == "Linux i686"
34
+ end
35
+
36
+ it "should return 'en-US' as its localization" do
37
+ @useragent.localization.should == "en-US"
38
+ end
39
+ end
40
+
41
+ describe "UserAgent: 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14'" do
42
+ before do
43
+ @useragent = UserAgent.parse("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14")
44
+ end
45
+
46
+ it_should_behave_like "Firefox browser"
47
+
48
+ it "should return '2.0.0.14' as its version" do
49
+ @useragent.version.should == "2.0.0.14"
50
+ end
51
+
52
+ it "should return '20080404' as its gecko version" do
53
+ @useragent.gecko.version.should == "20080404"
54
+ end
55
+
56
+ it "should return 'Macintosh' as its platform" do
57
+ @useragent.platform.should == "Macintosh"
58
+ end
59
+
60
+ it "should return 'Intel Mac OS X' as its os" do
61
+ @useragent.os.should == "Intel Mac OS X"
62
+ end
63
+
64
+ it "should return 'en-US' as its localization" do
65
+ @useragent.localization.should == "en-US"
66
+ end
67
+ end
68
+
69
+ describe "UserAgent: 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14'" do
70
+ before do
71
+ @useragent = UserAgent.parse("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14")
72
+ end
73
+
74
+ it_should_behave_like "Firefox browser"
75
+
76
+ it "should return '2.0.0.14' as its version" do
77
+ @useragent.version.should == "2.0.0.14"
78
+ end
79
+
80
+ it "should return '20080404' as its gecko version" do
81
+ @useragent.gecko.version.should == "20080404"
82
+ end
83
+
84
+ it "should return 'Windows' as its platform" do
85
+ @useragent.platform.should == "Windows"
86
+ end
87
+
88
+ it "should return 'Windows XP' as its os" do
89
+ @useragent.os.should == "Windows XP"
90
+ end
91
+
92
+ it "should return 'en-US' as its localization" do
93
+ @useragent.localization.should == "en-US"
94
+ end
95
+ end
96
+
97
+ describe "UserAgent: 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.0.12) Gecko/20070508 Firefox/1.5.0.12'" do
98
+ before do
99
+ @useragent = UserAgent.parse("Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.0.12) Gecko/20070508 Firefox/1.5.0.12")
100
+ end
101
+
102
+ it_should_behave_like "Firefox browser"
103
+
104
+ it "should return '1.5.0.12' as its version" do
105
+ @useragent.version.should == "1.5.0.12"
106
+ end
107
+
108
+ it "should return '20070508' as its gecko version" do
109
+ @useragent.gecko.version.should == "20070508"
110
+ end
111
+
112
+ it "should return 'Macintosh' as its platform" do
113
+ @useragent.platform.should == "Macintosh"
114
+ end
115
+
116
+ it "should return 'PPC Mac OS X Mach-O' as its os" do
117
+ @useragent.os.should == "PPC Mac OS X Mach-O"
118
+ end
119
+
120
+ it "should return 'en-US' as its localization" do
121
+ @useragent.localization.should == "en-US"
122
+ end
123
+ end
124
+
125
+ describe "UserAgent: 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.12) Gecko/20070508 Firefox/1.5.0.12'" do
126
+ before do
127
+ @useragent = UserAgent.parse("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.12) Gecko/20070508 Firefox/1.5.0.12")
128
+ end
129
+
130
+ it_should_behave_like "Firefox browser"
131
+
132
+ it "should return '1.5.0.12' as its version" do
133
+ @useragent.version.should == "1.5.0.12"
134
+ end
135
+
136
+ it "should return '20070508' as its gecko version" do
137
+ @useragent.gecko.version.should == "20070508"
138
+ end
139
+
140
+ it "should return 'Windows' as its platform" do
141
+ @useragent.platform.should == "Windows"
142
+ end
143
+
144
+ it "should return 'Windows XP' as its os" do
145
+ @useragent.os.should == "Windows XP"
146
+ end
147
+
148
+ it "should return 'en-US' as its localization" do
149
+ @useragent.localization.should == "en-US"
150
+ end
151
+ end
152
+
153
+ describe "UserAgent: 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.4) Gecko/20060612 Firefox/1.5.0.4 Flock/0.7.0.17.1'" do
154
+ before do
155
+ @useragent = UserAgent.parse("Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.4) Gecko/20060612 Firefox/1.5.0.4 Flock/0.7.0.17.1")
156
+ end
157
+
158
+ it_should_behave_like "Firefox browser"
159
+
160
+ it "should return '1.5.0.4' as its version" do
161
+ @useragent.version.should == "1.5.0.4"
162
+ end
163
+
164
+ it "should return '20060612' as its gecko version" do
165
+ @useragent.gecko.version.should == "20060612"
166
+ end
167
+
168
+ it "should return 'X11' as its platform" do
169
+ @useragent.platform.should == "X11"
170
+ end
171
+
172
+ it "should return 'Linux i686' as its os" do
173
+ @useragent.os.should == "Linux i686"
174
+ end
175
+
176
+ it "should return 'en-US' as its localization" do
177
+ @useragent.localization.should == "en-US"
178
+ end
179
+ end
180
+
181
+ describe "UserAgent: 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en; rv:1.8.1.14) Gecko/20080409 Camino/1.6 (like Firefox/2.0.0.14)'" do
182
+ before do
183
+ @useragent = UserAgent.parse("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en; rv:1.8.1.14) Gecko/20080409 Camino/1.6 (like Firefox/2.0.0.14)")
184
+ end
185
+
186
+ it "should return 'Camino' as its browser" do
187
+ @useragent.browser.should == "Camino"
188
+ end
189
+
190
+ it "should return '1.6' as its version" do
191
+ @useragent.version.should == "1.6"
192
+ end
193
+
194
+ it "should return '20080409' as its gecko version" do
195
+ @useragent.gecko.version.should == "20080409"
196
+ end
197
+
198
+ it "should return 'Macintosh' as its platform" do
199
+ @useragent.platform.should == "Macintosh"
200
+ end
201
+
202
+ it "should return 'Intel Mac OS X' as its os" do
203
+ @useragent.os.should == "Intel Mac OS X"
204
+ end
205
+
206
+ it "should return 'en' as its localization" do
207
+ @useragent.localization.should == "en"
208
+ end
209
+ end
@@ -0,0 +1,99 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+ describe "Internet Explorer browser", :shared => true do
4
+ it "should return 'Internet Explorer' as its browser" do
5
+ @useragent.browser.should == "Internet Explorer"
6
+ end
7
+
8
+ it "should return 'Windows' as its platform" do
9
+ @useragent.platform.should == "Windows"
10
+ end
11
+
12
+ it "should return 'compatible' as its compatibility" do
13
+ @useragent.compatibility.should == "compatible"
14
+ end
15
+
16
+ it "should be compatible" do
17
+ @useragent.should be_compatible
18
+ end
19
+ end
20
+
21
+ describe "UserAgent: 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)'" do
22
+ before do
23
+ @useragent = UserAgent.parse("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)")
24
+ end
25
+
26
+ it_should_behave_like "Internet Explorer browser"
27
+
28
+ it "should return '7.0' as its version" do
29
+ @useragent.version.should == "7.0"
30
+ end
31
+
32
+ it "should return 'Windows Vista' as its os" do
33
+ @useragent.os.should == "Windows Vista"
34
+ end
35
+ end
36
+
37
+ describe "UserAgent: 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)'" do
38
+ before do
39
+ @useragent = UserAgent.parse("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)")
40
+ end
41
+
42
+ it_should_behave_like "Internet Explorer browser"
43
+
44
+ it "should return '6.0' as its version" do
45
+ @useragent.version.should == "6.0"
46
+ end
47
+
48
+ it "should return 'Windows XP' as its os" do
49
+ @useragent.os.should == "Windows XP"
50
+ end
51
+
52
+ it "should be == 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)'" do
53
+ @useragent.should == @useragent
54
+ end
55
+
56
+ it "should not be == 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)'" do
57
+ @useragent.should_not == UserAgent.parse("Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)")
58
+ end
59
+
60
+ it "should be > 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)'" do
61
+ @useragent.should > UserAgent.parse("Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)")
62
+ end
63
+
64
+ it "should not be < 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)'" do
65
+ @useragent.should_not < UserAgent.parse("Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)")
66
+ end
67
+
68
+ it "should be >= 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)'" do
69
+ @useragent.should >= UserAgent.parse("Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)")
70
+ end
71
+
72
+ it "should not be >= 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)'" do
73
+ @useragent.should_not >= UserAgent.parse("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)")
74
+ end
75
+
76
+ it "should be <= 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)'" do
77
+ @useragent.should <= UserAgent.parse("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)")
78
+ end
79
+
80
+ it "should not be <= 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)'" do
81
+ @useragent.should_not <= UserAgent.parse("Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)")
82
+ end
83
+ end
84
+
85
+ describe "UserAgent: 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)'" do
86
+ before do
87
+ @useragent = UserAgent.parse("Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)")
88
+ end
89
+
90
+ it_should_behave_like "Internet Explorer browser"
91
+
92
+ it "should return '5.5' as its version" do
93
+ @useragent.version.should == "5.5"
94
+ end
95
+
96
+ it "should return 'Windows XP' as its os" do
97
+ @useragent.os.should == "Windows XP"
98
+ end
99
+ end