meteoroid 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.travis.yml +5 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +30 -0
- data/LICENSE +20 -0
- data/README.html +23 -0
- data/README.markdown +22 -0
- data/Rakefile +8 -0
- data/bin/meteoroid +6 -0
- data/lib/meteoroid.rb +5 -0
- data/lib/meteoroid/file.rb +35 -0
- data/lib/meteoroid/parser.rb +17 -0
- data/lib/meteoroid/sample.rb +58 -0
- data/lib/meteoroid/version.rb +3 -0
- data/meteoroid.gemspec +26 -0
- data/spec/fixtures/example.jml +9 -0
- data/spec/fixtures/full.jml +5174 -0
- data/spec/fixtures/single.jml +6 -0
- data/spec/meteoroid/file_spec.rb +88 -0
- data/spec/meteoroid/parser_spec.rb +69 -0
- data/spec/meteoroid/sample_spec.rb +72 -0
- data/spec/spec_helper.rb +10 -0
- metadata +159 -0
@@ -0,0 +1,6 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<testResults version="1.2">
|
3
|
+
<httpSample t="2622" lt="2615" ts="1309883025068" s="true" lb="Federal Legislator Search" rc="200" rm="OK" tn="Monitored Pages 1-1" dt="text" by="87109">
|
4
|
+
<java.net.URL>http://foo.bar/federal_legislator_search</java.net.URL>
|
5
|
+
</httpSample>
|
6
|
+
</testResults>
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Meteoroid::File do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@xml = File.read(File.join(File.dirname(__FILE__), %w[ .. fixtures example.jml ]))
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "self.from" do
|
10
|
+
it "should create valid Meteoroid::File from args" do
|
11
|
+
File.expects(:open).times(2).returns(StringIO.new(@xml))
|
12
|
+
files = Meteoroid::File.from(["foo.jml", "bar.jml"])
|
13
|
+
files.collect(&:valid).should_not include(false)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should not return invalid files" do
|
17
|
+
Meteoroid::File.from(["foo.jml", "bar.jml"]).should be_empty
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should always return array of Meteoroid::File" do
|
21
|
+
File.expects(:open).times(1).returns(StringIO.new(@xml))
|
22
|
+
files = Meteoroid::File.from(["foo.jml"])
|
23
|
+
files.collect(&:valid).should_not include(false)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#samples" do
|
28
|
+
it "should return stuff" do
|
29
|
+
File.stubs(:open).with("foo.jml").times(1).returns(StringIO.new(@xml))
|
30
|
+
file = Meteoroid::File.new("foo.jml")
|
31
|
+
file.samples.should_not be_empty
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should only parse the file once" do
|
35
|
+
File.stubs(:open).with("foo.jml").times(1).returns(StringIO.new(@xml))
|
36
|
+
file = Meteoroid::File.new("foo.jml")
|
37
|
+
|
38
|
+
file.xml.expects(:xpath).times(1).returns([])
|
39
|
+
|
40
|
+
2.times { file.samples }
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "#xml" do
|
46
|
+
|
47
|
+
describe "valid file" do
|
48
|
+
it "should return a Nokogiri XML document" do
|
49
|
+
File.stubs(:open).with("foo.jml").returns(StringIO.new(@xml))
|
50
|
+
file = Meteoroid::File.new("foo.jml")
|
51
|
+
|
52
|
+
file.xml.should be_a(Nokogiri::XML::Document)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should mark the file as valid" do
|
56
|
+
File.stubs(:open).with("foo.jml").returns(StringIO.new(@xml))
|
57
|
+
file = Meteoroid::File.new("foo.jml")
|
58
|
+
|
59
|
+
file.valid.should be_true
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should only parse the document once" do
|
63
|
+
File.expects(:open).times(1).with("foo.jml").returns(StringIO.new(@xml))
|
64
|
+
file = Meteoroid::File.new("foo.jml")
|
65
|
+
|
66
|
+
2.times { file.xml }
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "invalid file" do
|
71
|
+
it "should swallow the exception" do
|
72
|
+
file = Meteoroid::File.new("foo.jml")
|
73
|
+
|
74
|
+
lambda {
|
75
|
+
file.xml
|
76
|
+
}.should_not raise_exception(Errno::ENOENT)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should flag the file as invalid" do
|
80
|
+
file = Meteoroid::File.new("foo.jml")
|
81
|
+
|
82
|
+
file.valid.should be_false
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Meteoroid::Parser do
|
4
|
+
|
5
|
+
describe "files" do
|
6
|
+
before :each do
|
7
|
+
@xml = File.read(File.join(File.dirname(__FILE__), %w[ .. fixtures example.jml ]))
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should initialize a single Meteoroid::File" do
|
11
|
+
File.expects(:open).times(1).returns(StringIO.new(@xml))
|
12
|
+
files = Meteoroid::Parser.new('foo.jml').files
|
13
|
+
|
14
|
+
files.should be_an(Array)
|
15
|
+
files.first.should be_an(Meteoroid::File)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should initialize Meteoroid::Files" do
|
19
|
+
File.expects(:open).times(2).returns(StringIO.new(@xml))
|
20
|
+
files = Meteoroid::Parser.new('foo.jml', 'bar.jml').files
|
21
|
+
|
22
|
+
files.should be_an(Array)
|
23
|
+
files.first.should be_an(Meteoroid::File)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "parse" do
|
28
|
+
it "should returns both samples from the file" do
|
29
|
+
xml = File.read(File.join(File.dirname(__FILE__), %w[ .. fixtures example.jml ]))
|
30
|
+
File.expects(:open).times(1).returns(StringIO.new(xml))
|
31
|
+
|
32
|
+
parsed = Meteoroid::Parser.new('foo.jml').parse
|
33
|
+
|
34
|
+
parsed.size.should == 2
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should returns samples from both files" do
|
38
|
+
foo = File.read(File.join(File.dirname(__FILE__), %w[ .. fixtures example.jml ]))
|
39
|
+
bar = File.read(File.join(File.dirname(__FILE__), %w[ .. fixtures full.jml ]))
|
40
|
+
|
41
|
+
File.expects(:open).with('foo.jml').times(1).returns(StringIO.new(foo))
|
42
|
+
File.expects(:open).with('bar.jml').times(1).returns(StringIO.new(bar))
|
43
|
+
|
44
|
+
parsed = Meteoroid::Parser.new('foo.jml', 'bar.jml').parse
|
45
|
+
|
46
|
+
parsed.size.should == 562
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should be able to handle a single example" do
|
50
|
+
xml = File.read(File.join(File.dirname(__FILE__), %w[ .. fixtures single.jml ]))
|
51
|
+
File.expects(:open).times(1).returns(StringIO.new(xml))
|
52
|
+
|
53
|
+
parsed = Meteoroid::Parser.new('foo.jml').parse
|
54
|
+
|
55
|
+
parsed.size.should == 1
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "self.parse!" do
|
60
|
+
it "should parse the passed in files" do
|
61
|
+
xml = File.read(File.join(File.dirname(__FILE__), %w[ .. fixtures example.jml ]))
|
62
|
+
File.expects(:open).times(1).returns(StringIO.new(xml))
|
63
|
+
|
64
|
+
parsed = Meteoroid::Parser.parse!('foo.jml')
|
65
|
+
|
66
|
+
parsed.size.should == 2
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Meteoroid::Sample do
|
4
|
+
|
5
|
+
describe "attribute mappings" do
|
6
|
+
Meteoroid::Sample::ATTRIBUTE_MAPPING.each do |key, value|
|
7
|
+
it "should allow #{key} accessible through #{value}" do
|
8
|
+
Meteoroid::Sample.new({}).should respond_to(value)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "convert" do
|
14
|
+
|
15
|
+
describe "Strings" do
|
16
|
+
{ 'time' => 't', 'latency' => 'lt', 'response_code' => 'rc', 'bytes' => 'by' }.each do |method, attribute|
|
17
|
+
it "#{method} should return a Integer" do
|
18
|
+
Meteoroid::Sample.new({ attribute => '100' }).send(method.to_sym).should be_a(Integer)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "Strings" do
|
24
|
+
{ 'label' => 'lb', 'response_message' => 'rm', 'thread_name' => 'tn' }.each do |method, attribute|
|
25
|
+
it "#{method} should return a String" do
|
26
|
+
Meteoroid::Sample.new({ attribute => 'foo' }).send(method.to_sym).should be_a(String)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "Timestamps" do
|
32
|
+
{ 'timestamp' => 'tn' }.each do |method, attribute|
|
33
|
+
it "#{method} should return a Time" do
|
34
|
+
Meteoroid::Sample.new({ attribute => '1' }).send(method.to_sym).should be_a(Time)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "Boolean" do
|
40
|
+
{ 'success' => 's' }.each do |method, attribute|
|
41
|
+
it "#{method} should return true" do
|
42
|
+
Meteoroid::Sample.new({ attribute => 'true' }).send(method).should == true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "from_xml" do
|
50
|
+
it "should initialize a Sample from the attribute_nodes" do
|
51
|
+
mock_node = [mock(:name => "lb", :value => "foo")]
|
52
|
+
sample = Meteoroid::Sample.from_xml(mock_node)
|
53
|
+
|
54
|
+
sample.label.should == "foo"
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should initialize a Sample without a URL" do
|
58
|
+
mock_node = [mock(:name => "lb", :value => "foo")]
|
59
|
+
sample = Meteoroid::Sample.from_xml(mock_node)
|
60
|
+
|
61
|
+
sample.url.should == ""
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should initialize a Sample with a URL" do
|
65
|
+
mock_node = [mock(:name => "lb", :value => "foo")]
|
66
|
+
sample = Meteoroid::Sample.from_xml(mock_node, "foo.bar")
|
67
|
+
|
68
|
+
sample.url.should == "foo.bar"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: meteoroid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Duncan Grazier
|
14
|
+
- Paul Guelpa
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2011-07-07 00:00:00 -04:00
|
20
|
+
default_executable:
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: mocha
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 35
|
31
|
+
segments:
|
32
|
+
- 0
|
33
|
+
- 9
|
34
|
+
- 12
|
35
|
+
version: 0.9.12
|
36
|
+
type: :development
|
37
|
+
version_requirements: *id001
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: rake
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
hash: 63
|
47
|
+
segments:
|
48
|
+
- 0
|
49
|
+
- 9
|
50
|
+
- 2
|
51
|
+
version: 0.9.2
|
52
|
+
type: :development
|
53
|
+
version_requirements: *id002
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: rspec
|
56
|
+
prerelease: false
|
57
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
hash: 23
|
63
|
+
segments:
|
64
|
+
- 2
|
65
|
+
- 6
|
66
|
+
- 0
|
67
|
+
version: 2.6.0
|
68
|
+
type: :development
|
69
|
+
version_requirements: *id003
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: nokogiri
|
72
|
+
prerelease: false
|
73
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ~>
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
hash: 3
|
79
|
+
segments:
|
80
|
+
- 1
|
81
|
+
- 5
|
82
|
+
- 0
|
83
|
+
version: 1.5.0
|
84
|
+
type: :runtime
|
85
|
+
version_requirements: *id004
|
86
|
+
description: Use this library to transform JML into other stuff
|
87
|
+
email:
|
88
|
+
- duncan@impossiblerocket.com
|
89
|
+
executables:
|
90
|
+
- meteoroid
|
91
|
+
extensions: []
|
92
|
+
|
93
|
+
extra_rdoc_files: []
|
94
|
+
|
95
|
+
files:
|
96
|
+
- .gitignore
|
97
|
+
- .travis.yml
|
98
|
+
- Gemfile
|
99
|
+
- Gemfile.lock
|
100
|
+
- LICENSE
|
101
|
+
- README.html
|
102
|
+
- README.markdown
|
103
|
+
- Rakefile
|
104
|
+
- bin/meteoroid
|
105
|
+
- lib/meteoroid.rb
|
106
|
+
- lib/meteoroid/file.rb
|
107
|
+
- lib/meteoroid/parser.rb
|
108
|
+
- lib/meteoroid/sample.rb
|
109
|
+
- lib/meteoroid/version.rb
|
110
|
+
- meteoroid.gemspec
|
111
|
+
- spec/fixtures/example.jml
|
112
|
+
- spec/fixtures/full.jml
|
113
|
+
- spec/fixtures/single.jml
|
114
|
+
- spec/meteoroid/file_spec.rb
|
115
|
+
- spec/meteoroid/parser_spec.rb
|
116
|
+
- spec/meteoroid/sample_spec.rb
|
117
|
+
- spec/spec_helper.rb
|
118
|
+
has_rdoc: true
|
119
|
+
homepage: http://github.com/itsmeduncan/meteoroid
|
120
|
+
licenses: []
|
121
|
+
|
122
|
+
post_install_message:
|
123
|
+
rdoc_options: []
|
124
|
+
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
none: false
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
hash: 3
|
133
|
+
segments:
|
134
|
+
- 0
|
135
|
+
version: "0"
|
136
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
hash: 3
|
142
|
+
segments:
|
143
|
+
- 0
|
144
|
+
version: "0"
|
145
|
+
requirements: []
|
146
|
+
|
147
|
+
rubyforge_project:
|
148
|
+
rubygems_version: 1.3.7
|
149
|
+
signing_key:
|
150
|
+
specification_version: 3
|
151
|
+
summary: Transform JMeter output into something useful
|
152
|
+
test_files:
|
153
|
+
- spec/fixtures/example.jml
|
154
|
+
- spec/fixtures/full.jml
|
155
|
+
- spec/fixtures/single.jml
|
156
|
+
- spec/meteoroid/file_spec.rb
|
157
|
+
- spec/meteoroid/parser_spec.rb
|
158
|
+
- spec/meteoroid/sample_spec.rb
|
159
|
+
- spec/spec_helper.rb
|