allotment 1.0.4 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.md +52 -0
- data/{LICENSE.md → License.md} +0 -0
- data/README.md +121 -33
- data/lib/allotment.rb +80 -45
- data/lib/allotment/array.rb +4 -0
- data/lib/allotment/cucumber.rb +2 -6
- data/lib/allotment/stopwatch.rb +98 -41
- data/lib/allotment/version.rb +5 -3
- data/spec/allotment_spec.rb +66 -76
- data/spec/{stopwatch/array_spec.rb → array_spec.rb} +2 -0
- data/spec/helper.rb +2 -4
- data/spec/stopwatch_spec.rb +268 -0
- metadata +30 -18
- data/allotment.gemspec +0 -29
- data/lib/allotment/methods.rb +0 -23
- data/spec/stopwatch/methods_spec.rb +0 -130
- data/spec/stopwatch/stopwatch_spec.rb +0 -145
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: allotment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Slaughter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '>='
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: yard
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - '>='
|
@@ -53,13 +53,13 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
-
type: :
|
62
|
+
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
@@ -67,7 +67,21 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: coveralls
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: hashie
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - '>='
|
@@ -80,26 +94,24 @@ dependencies:
|
|
80
94
|
- - '>='
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
83
|
-
description:
|
97
|
+
description: Recording performance simple, powerful and flexible.
|
84
98
|
email: b.p.slaughter@gmail.com
|
85
99
|
executables: []
|
86
100
|
extensions: []
|
87
101
|
extra_rdoc_files: []
|
88
102
|
files:
|
89
103
|
- README.md
|
90
|
-
-
|
91
|
-
-
|
104
|
+
- License.md
|
105
|
+
- History.md
|
92
106
|
- lib/allotment/array.rb
|
93
107
|
- lib/allotment/cucumber.rb
|
94
|
-
- lib/allotment/methods.rb
|
95
108
|
- lib/allotment/stopwatch.rb
|
96
109
|
- lib/allotment/version.rb
|
97
110
|
- lib/allotment.rb
|
98
111
|
- spec/allotment_spec.rb
|
112
|
+
- spec/array_spec.rb
|
99
113
|
- spec/helper.rb
|
100
|
-
- spec/
|
101
|
-
- spec/stopwatch/methods_spec.rb
|
102
|
-
- spec/stopwatch/stopwatch_spec.rb
|
114
|
+
- spec/stopwatch_spec.rb
|
103
115
|
homepage: http://benslaughter.github.io/allotment/
|
104
116
|
licenses:
|
105
117
|
- MIT
|
@@ -123,10 +135,10 @@ rubyforge_project:
|
|
123
135
|
rubygems_version: 2.0.3
|
124
136
|
signing_key:
|
125
137
|
specification_version: 4
|
126
|
-
summary:
|
138
|
+
summary: Performance time recording gem
|
127
139
|
test_files:
|
128
140
|
- spec/allotment_spec.rb
|
141
|
+
- spec/array_spec.rb
|
129
142
|
- spec/helper.rb
|
130
|
-
- spec/
|
131
|
-
|
132
|
-
- spec/stopwatch/stopwatch_spec.rb
|
143
|
+
- spec/stopwatch_spec.rb
|
144
|
+
has_rdoc:
|
data/allotment.gemspec
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
lib = File.expand_path('../lib', __FILE__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require 'allotment/version'
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = 'allotment'
|
7
|
-
spec.summary = 'Allotment: Performance recording'
|
8
|
-
spec.description = 'Simple performance recordings of blocks, procs or point to point'
|
9
|
-
spec.homepage = 'http://benslaughter.github.io/allotment/'
|
10
|
-
spec.version = Allotment::VERSION
|
11
|
-
spec.date = Allotment::DATE
|
12
|
-
spec.license = 'MIT'
|
13
|
-
|
14
|
-
spec.author = 'Ben Slaughter'
|
15
|
-
spec.email = 'b.p.slaughter@gmail.com'
|
16
|
-
|
17
|
-
spec.add_development_dependency 'rspec'
|
18
|
-
spec.add_development_dependency 'pry'
|
19
|
-
spec.add_development_dependency 'coveralls'
|
20
|
-
spec.add_runtime_dependency 'hashie'
|
21
|
-
spec.add_runtime_dependency 'hooks'
|
22
|
-
|
23
|
-
spec.files = ['README.md', 'LICENSE.md', 'allotment.gemspec']
|
24
|
-
spec.files += Dir.glob("lib/**/*.rb")
|
25
|
-
spec.files += Dir.glob("spec/**/*")
|
26
|
-
spec.test_files = Dir.glob("spec/**/*")
|
27
|
-
spec.require_path = 'lib'
|
28
|
-
|
29
|
-
end
|
data/lib/allotment/methods.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
class Allotment
|
2
|
-
module Methods
|
3
|
-
def record_event name = 'unnamed', &block
|
4
|
-
Allotment.record_event name, &block
|
5
|
-
end
|
6
|
-
|
7
|
-
def start_recording name = 'unnamed'
|
8
|
-
Allotment.start_recording name
|
9
|
-
end
|
10
|
-
|
11
|
-
def stop_recording name
|
12
|
-
Allotment.stop_recording name
|
13
|
-
end
|
14
|
-
|
15
|
-
def results
|
16
|
-
Allotment.results
|
17
|
-
end
|
18
|
-
|
19
|
-
def results_string
|
20
|
-
Allotment.results_string
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,130 +0,0 @@
|
|
1
|
-
class DummyClass
|
2
|
-
include Allotment::Methods
|
3
|
-
end
|
4
|
-
|
5
|
-
describe Allotment::Methods do
|
6
|
-
it "is a module" do
|
7
|
-
Allotment::Methods.class.should eq Module
|
8
|
-
end
|
9
|
-
|
10
|
-
describe "#record_event" do
|
11
|
-
before(:each) do
|
12
|
-
@dummy_class = DummyClass.new
|
13
|
-
end
|
14
|
-
|
15
|
-
it "records the time for the block" do
|
16
|
-
@dummy_class.record_event('my_recording 0.1') { sleep 0.01 }
|
17
|
-
end
|
18
|
-
|
19
|
-
it "records the time for the proc" do
|
20
|
-
@dummy_class.record_event 'my_recording 0.2' do
|
21
|
-
sleep 0.01
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
it "returns a float" do
|
26
|
-
result = @dummy_class.record_event('my_recording 0.3') { sleep 0.01 }
|
27
|
-
result.class.should eq Float
|
28
|
-
end
|
29
|
-
|
30
|
-
it "returns the execute time of the block" do
|
31
|
-
result = @dummy_class.record_event('my_recording 0.4') { sleep 0.01 }
|
32
|
-
result.round(2).should eq 0.01
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "#start_recording" do
|
37
|
-
before(:each) do
|
38
|
-
@dummy_class = DummyClass.new
|
39
|
-
end
|
40
|
-
|
41
|
-
it "returns a stopwatch instance" do
|
42
|
-
result = @dummy_class.start_recording
|
43
|
-
result.class.should eq Allotment::Stopwatch
|
44
|
-
end
|
45
|
-
|
46
|
-
it "returns an unnamed stopwatch if no name given" do
|
47
|
-
result = @dummy_class.start_recording
|
48
|
-
result.name.should eq 'unnamed'
|
49
|
-
end
|
50
|
-
|
51
|
-
it "returns a stopwatch with the given name" do
|
52
|
-
result = @dummy_class.start_recording 'my_recording'
|
53
|
-
result.name.should eq 'my_recording'
|
54
|
-
end
|
55
|
-
|
56
|
-
it "returns a stopwatch that is 'running'" do
|
57
|
-
result = @dummy_class.start_recording
|
58
|
-
result.status.should eq 'running'
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe "#stop_recording" do
|
63
|
-
before(:each) do
|
64
|
-
@dummy_class = DummyClass.new
|
65
|
-
end
|
66
|
-
|
67
|
-
it "returns a float" do
|
68
|
-
@dummy_class.start_recording 'my_recording1'
|
69
|
-
sleep 0.01
|
70
|
-
result = @dummy_class.stop_recording 'my_recording1'
|
71
|
-
result.class.should eq Float
|
72
|
-
end
|
73
|
-
|
74
|
-
it "returns the execute time of the code" do
|
75
|
-
@dummy_class.start_recording 'my_recording2'
|
76
|
-
sleep 0.01
|
77
|
-
result = @dummy_class.stop_recording 'my_recording2'
|
78
|
-
result.round(2).should eq 0.01
|
79
|
-
end
|
80
|
-
|
81
|
-
it "raises an error if the recording does not exist" do
|
82
|
-
expect { @dummy_class.stop_recording 'my_recording3' }.to raise_error NameError, "No recording:my_recording3"
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
describe "#results" do
|
87
|
-
before(:each) do
|
88
|
-
@dummy_class = DummyClass.new
|
89
|
-
end
|
90
|
-
|
91
|
-
it "returns a hash" do
|
92
|
-
@dummy_class.record_event('my_recording4') { sleep 0.01 }
|
93
|
-
@dummy_class.results.class.should eq Hashie::Mash
|
94
|
-
end
|
95
|
-
|
96
|
-
it "returns a hash with the event in" do
|
97
|
-
@dummy_class.record_event('my_recording5') { sleep 0.01 }
|
98
|
-
@dummy_class.results.should include('my_recording5')
|
99
|
-
end
|
100
|
-
|
101
|
-
it "stores the result under the event" do
|
102
|
-
@dummy_class.record_event('my_recording6') { sleep 0.01 }
|
103
|
-
@dummy_class.results['my_recording6'][0].round(2).should eq 0.01
|
104
|
-
end
|
105
|
-
|
106
|
-
it "stores each result of each event" do
|
107
|
-
@dummy_class.record_event('my_recording7') { sleep 0.01 }
|
108
|
-
@dummy_class.record_event('my_recording7') { sleep 0.02 }
|
109
|
-
@dummy_class.results['my_recording7'][0].round(2).should eq 0.01
|
110
|
-
@dummy_class.results['my_recording7'][1].round(2).should eq 0.02
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
describe "#results_string" do
|
115
|
-
before(:each) do
|
116
|
-
@dummy_class = DummyClass.new
|
117
|
-
end
|
118
|
-
|
119
|
-
it "returns a string" do
|
120
|
-
@dummy_class.record_event('my_recording8') { sleep 0.01 }
|
121
|
-
@dummy_class.results_string.class.should eq String
|
122
|
-
end
|
123
|
-
|
124
|
-
it "returns a string with the event in" do
|
125
|
-
@dummy_class.record_event('my_recording9') { sleep 0.03 }
|
126
|
-
@dummy_class.results_string.should include('my_recording9')
|
127
|
-
@dummy_class.results_string.should include('0.03')
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
@@ -1,145 +0,0 @@
|
|
1
|
-
describe Allotment::Stopwatch do
|
2
|
-
it "is a class" do
|
3
|
-
Allotment::Stopwatch.class.should eq Class
|
4
|
-
end
|
5
|
-
|
6
|
-
describe ".new" do
|
7
|
-
it "returns a class of Stopwatch" do
|
8
|
-
Allotment::Stopwatch.new.class.should eq Allotment::Stopwatch
|
9
|
-
end
|
10
|
-
|
11
|
-
it "sets the stopwatch status to running" do
|
12
|
-
Allotment::Stopwatch.new.status.should eq 'running'
|
13
|
-
end
|
14
|
-
|
15
|
-
it "gives the stopwatch a name if none given" do
|
16
|
-
Allotment::Stopwatch.new.name.should =~ /stopwatch_\d+/
|
17
|
-
end
|
18
|
-
|
19
|
-
it "sets the name of the stopwatch" do
|
20
|
-
Allotment::Stopwatch.new('stopwatch').name.should eq 'stopwatch'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "#stop" do
|
25
|
-
it "returns a float" do
|
26
|
-
sw = Allotment::Stopwatch.new
|
27
|
-
sw.stop.class.should eq Float
|
28
|
-
end
|
29
|
-
|
30
|
-
it "returns the correct time" do
|
31
|
-
sw = Allotment::Stopwatch.new
|
32
|
-
sleep 0.01
|
33
|
-
sw.stop.round(2).should eq 0.01
|
34
|
-
end
|
35
|
-
|
36
|
-
it "sets the stopwatch status to stopped" do
|
37
|
-
sw = Allotment::Stopwatch.new
|
38
|
-
sw.stop
|
39
|
-
sw.status.should eq 'stopped'
|
40
|
-
end
|
41
|
-
|
42
|
-
it "keeps its stopwatch name" do
|
43
|
-
sw = Allotment::Stopwatch.new('stopwatch')
|
44
|
-
sw.stop
|
45
|
-
sw.name.should eq 'stopwatch'
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe "#start" do
|
50
|
-
it "sets the stopwatch status to running" do
|
51
|
-
sw = Allotment::Stopwatch.new
|
52
|
-
sw.stop
|
53
|
-
sw.start
|
54
|
-
sw.status.should eq 'running'
|
55
|
-
end
|
56
|
-
|
57
|
-
it "keeps track of total time" do
|
58
|
-
sw = Allotment::Stopwatch.new
|
59
|
-
sleep 0.01
|
60
|
-
sw.stop
|
61
|
-
sw.start
|
62
|
-
sleep 0.01
|
63
|
-
sw.stop.round(2).should eq 0.02
|
64
|
-
end
|
65
|
-
|
66
|
-
it "keeps its stopwatch name" do
|
67
|
-
sw = Allotment::Stopwatch.new('stopwatch')
|
68
|
-
sw.stop
|
69
|
-
sw.start
|
70
|
-
sw.name.should eq 'stopwatch'
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe "#reset" do
|
75
|
-
it "resets the stopwatch total time when stopped" do
|
76
|
-
sw = Allotment::Stopwatch.new
|
77
|
-
sleep 0.01
|
78
|
-
sw.stop
|
79
|
-
sw.status.should eq 'stopped'
|
80
|
-
sw.reset
|
81
|
-
sw.start
|
82
|
-
sleep 0.01
|
83
|
-
sw.stop.round(2).should eq 0.01
|
84
|
-
end
|
85
|
-
|
86
|
-
it "resets the stopwatch total time when running" do
|
87
|
-
sw = Allotment::Stopwatch.new
|
88
|
-
sleep 0.01
|
89
|
-
sw.status.should eq 'running'
|
90
|
-
sw.reset
|
91
|
-
sleep 0.01
|
92
|
-
sw.stop.round(2).should eq 0.01
|
93
|
-
end
|
94
|
-
|
95
|
-
it "keeps its stopwatch name" do
|
96
|
-
sw = Allotment::Stopwatch.new('stopwatch')
|
97
|
-
sw.reset
|
98
|
-
sw.name.should eq 'stopwatch'
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
describe "#split" do
|
103
|
-
it "returns a float" do
|
104
|
-
sw = Allotment::Stopwatch.new
|
105
|
-
sw.split.class.should eq Float
|
106
|
-
end
|
107
|
-
|
108
|
-
it "returns the correct time" do
|
109
|
-
sw = Allotment::Stopwatch.new
|
110
|
-
sleep 0.01
|
111
|
-
sw.split.round(2).should eq 0.01
|
112
|
-
sleep 0.01
|
113
|
-
sw.split.round(2).should eq 0.02
|
114
|
-
sw.stop.round(2).should eq 0.02
|
115
|
-
end
|
116
|
-
|
117
|
-
it "keeps its stopwatch name" do
|
118
|
-
sw = Allotment::Stopwatch.new('stopwatch')
|
119
|
-
sw.split
|
120
|
-
sw.name.should eq 'stopwatch'
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
describe "#lap" do
|
125
|
-
it "returns a float" do
|
126
|
-
sw = Allotment::Stopwatch.new
|
127
|
-
sw.lap.class.should eq Float
|
128
|
-
end
|
129
|
-
|
130
|
-
it "returns the correct time" do
|
131
|
-
sw = Allotment::Stopwatch.new
|
132
|
-
sleep 0.01
|
133
|
-
sw.lap.round(2).should eq 0.01
|
134
|
-
sleep 0.01
|
135
|
-
sw.lap.round(2).should eq 0.01
|
136
|
-
sw.stop.round(2).should eq 0.02
|
137
|
-
end
|
138
|
-
|
139
|
-
it "keeps its stopwatch name" do
|
140
|
-
sw = Allotment::Stopwatch.new('stopwatch')
|
141
|
-
sw.lap
|
142
|
-
sw.name.should eq 'stopwatch'
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|