allotment 1.0.1 → 1.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ebc11149d0e75eab78814f7c06832ba1ebf09550
4
- data.tar.gz: ccd06e0b331f68b762c1d3d8363e314f1d7122fd
3
+ metadata.gz: e6417cf65f6cb61d3ea29b4270ad1c98e66d4945
4
+ data.tar.gz: 9948aa7f2e371bc100081451ce46607db0c09d69
5
5
  SHA512:
6
- metadata.gz: 288acb76f032599689b50bd687a683ec77ad6f931ab61f106b8cc5e0d953ac102ca6c1579691111913cdec5d752d9cceda8601ac514f0d4a58b6c8461bd9f187
7
- data.tar.gz: d41a2fe690bf038a3f20ff6a74679b555056e2d453bdbba44fd8d76a7919ff24962c213c846f694680c857c04f23e682062760db40021cdef3a822e58c9cdb63
6
+ metadata.gz: 2b285e0947b4a97ef2578cfd9706e17f2f480b65b3436d0e8c8593c921b4b34cedfc42f9b014ad6c451c1bc2d0b0ec69cb5156327686133c02ab075c5c07a6f6
7
+ data.tar.gz: 53f7a0b502ac4d7ee3b5371893c2785c2fdd85e58b10f124338942d657d0f1675d3cfe92e0290f5074b615330f4ec351618a2be7f6a51488fae331832f1c3677
data/README.md ADDED
@@ -0,0 +1,141 @@
1
+ # Allotment
2
+
3
+ [![Code Climate](https://codeclimate.com/github/benSlaughter/allotment.png)](https://codeclimate.com/github/benSlaughter/allotment)
4
+ [![Build Status](https://travis-ci.org/benSlaughter/allotment.png?branch=master)](https://travis-ci.org/benSlaughter/allotment)
5
+ [![Dependency Status](https://gemnasium.com/benSlaughter/allotment.png)](https://gemnasium.com/benSlaughter/allotment)
6
+ [![Coverage Status](https://coveralls.io/repos/benSlaughter/allotment/badge.png?branch=master)](https://coveralls.io/r/benSlaughter/allotment)
7
+ [![Gem Version](https://badge.fury.io/rb/allotment.png)](http://badge.fury.io/rb/allotment)
8
+
9
+ Allotment is a performance rubygem that records and stores the performance timing of running a block of code,
10
+ or from a from a chosen point, until a task or action is complete.
11
+
12
+ Each performance recording is stored with a recording name,
13
+ each following recording is added so that multiple recordings can be queried and assesed.
14
+
15
+ Allotment also stores all the results so that they can be easily accessed at any time.
16
+
17
+ ## Setup
18
+
19
+ Allotment has been tested with Ruby 1.9.2 and later.
20
+ To install, type:
21
+
22
+ ```bash
23
+ gem install allotment
24
+ ```
25
+
26
+ ## Using Allotment with Cucumber
27
+
28
+ If you are using Cucumber you can record each scenario, and report the results to the console, add this line into your env.rb file:
29
+
30
+ ```ruby
31
+ require 'allotment/cucumber'
32
+ ```
33
+
34
+ ## Using Allotment
35
+
36
+ Allotments main features are: the ability to record performance of ruby blocks; and record from point to point.
37
+
38
+ Require Allotment at the start of your code:
39
+
40
+ ```ruby
41
+ require 'allotment'
42
+ ```
43
+
44
+ ### Recording a Block
45
+
46
+ The basic way of recording a block is as follows:
47
+
48
+ ```ruby
49
+ Allotment.record_event('my_recording') { # code here }
50
+ ```
51
+ ```ruby
52
+ Allotment.record_event('my_recording') do
53
+ # code here
54
+ end
55
+ ```
56
+
57
+ When an event has been completed the performance timing is returned by the method:
58
+
59
+ ```ruby
60
+ performance = Allotment.record_event { # code here }
61
+ ```
62
+ ```ruby
63
+ performance = Allotment.record_event do
64
+ # code here
65
+ end
66
+ ```
67
+
68
+ ### Record point to point:
69
+
70
+ The basic way of recording point to point is as follows:
71
+
72
+ ```ruby
73
+ require 'allotment'
74
+
75
+ Allotment.start_recording 'my_recording'
76
+ # code here
77
+ Allotment.stop_recording 'my_recording'
78
+ ```
79
+
80
+ When stop recording is called the performance timing is returned by the method:
81
+
82
+ ```ruby
83
+ performance = Allotment.stop_recording 'my_recording'
84
+ ```
85
+
86
+ When start recording is called the timing stopwatch is returned by the method:
87
+
88
+ ```ruby
89
+ stopwatch = Allotment.start_recording 'my_recording'
90
+ ```
91
+
92
+ _More on [stopwatches](#allotment-stopwatches)_
93
+
94
+ If a recording name does not exists, then a NameError shall be raised.
95
+
96
+ ### Accessing performance results
97
+
98
+ Performance recordings are stored within a hash. The reperformance results are logged to an array under the recording name.
99
+ They can be access from Allotment at any time:
100
+
101
+ ```ruby
102
+ hash = Allotment.results
103
+ ```
104
+ ```ruby
105
+ array = Allotment.results["my_recording"]
106
+ ```
107
+ ```ruby
108
+ result = Allotment.results["my_recording"].first
109
+ ```
110
+ ```ruby
111
+ result = Allotment.results["my_recording"].average
112
+ ```
113
+
114
+ ### Allotment Stopwatches
115
+
116
+ TODO
117
+
118
+ ## Release Notes
119
+ ### Version 1.0.0
120
+ ###### Major: Inital release version.
121
+ * Allotment has the ablility to record blocks and procs, and to record from two separate points within the code.
122
+ * Stopwatch has been completed and can start, stop, split, lap and restart.
123
+ * There is an extention of Array for an average.
124
+ * There is Cucumber support, a cucumber file has been included that will record scenario and test time.
125
+
126
+ ### Version 1.0.1
127
+ ###### Patch: Added instance methods
128
+ * Added instance methods so that the module can be included into a class and allotment does not need to be called every time.
129
+ * Cleaned up stopwatch so that it had lap and split
130
+
131
+ ## Version 1.0.2
132
+ ###### Patch: Results returned as Hashie::Mash
133
+ * results methods now return results as a Hashie::Mash
134
+
135
+ ## Planned Releases
136
+ ### Version 1.1.0
137
+ ###### Minor: Improvements to recording events and stopwatch management
138
+ * Rescue within an event to ensure that the timing is stopped in the event of a failure
139
+ * Complete the readme with updated information on using stopwatches
140
+ * A complete record of all spawned stopwatches
141
+
data/allotment.gemspec ADDED
@@ -0,0 +1,27 @@
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 'coveralls'
19
+ spec.add_runtime_dependency 'hashie'
20
+
21
+ spec.files = ['README.md', 'allotment.gemspec']
22
+ spec.files += Dir.glob("lib/**/*.rb")
23
+ spec.files += Dir.glob("spec/**/*")
24
+ spec.test_files = Dir.glob("spec/**/*")
25
+ spec.require_path = 'lib'
26
+
27
+ end
data/lib/allotment.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'allotment/array'
2
2
  require 'allotment/stopwatch'
3
3
  require 'json'
4
+ require 'hashie'
4
5
 
5
6
  module Allotment
6
7
  class << self
@@ -11,7 +12,7 @@ module Allotment
11
12
  end
12
13
 
13
14
  def start_recording name = 'unnamed'
14
- @watches ||= Hash.new
15
+ @watches ||= Hashie::Mash.new
15
16
  @watches[name] = Stopwatch.new name
16
17
  end
17
18
 
@@ -20,9 +21,9 @@ module Allotment
20
21
  result = watch.stop
21
22
 
22
23
  # Dealing with the results
23
- @results ||= Hash.new
24
+ @results ||= Hashie::Mash.new
24
25
  @results[name] ||= Array.new
25
- @results[name].push result
26
+ @results[name] << result
26
27
 
27
28
  return result
28
29
  end
@@ -0,0 +1,4 @@
1
+ module Allotment
2
+ VERSION = "1.0.3".freeze
3
+ DATE = "2013-08-29".freeze
4
+ end
@@ -152,7 +152,7 @@ describe Allotment do
152
152
  describe ".results" do
153
153
  it "returns a hash" do
154
154
  Allotment.record_event('my_recording4') { sleep 0.01 }
155
- Allotment.results.class.should eq Hash
155
+ Allotment.results.class.should eq Hashie::Mash
156
156
  end
157
157
 
158
158
  it "returns a hash with the event in" do
@@ -180,7 +180,7 @@ describe Allotment do
180
180
 
181
181
  it "returns a hash" do
182
182
  @dummy_class.record_event('my_recording4') { sleep 0.01 }
183
- @dummy_class.results.class.should eq Hash
183
+ @dummy_class.results.class.should eq Hashie::Mash
184
184
  end
185
185
 
186
186
  it "returns a hash with the event in" do
metadata CHANGED
@@ -1,25 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allotment
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
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-08-28 00:00:00.000000000 Z
12
- dependencies: []
13
- description: A gem for recording performance and timings of blocks or from point to
14
- point
11
+ date: 2013-08-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: coveralls
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: hashie
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Simple performance recordings of blocks, procs or point to point
15
56
  email: b.p.slaughter@gmail.com
16
57
  executables: []
17
58
  extensions: []
18
59
  extra_rdoc_files: []
19
60
  files:
61
+ - README.md
62
+ - allotment.gemspec
20
63
  - lib/allotment/array.rb
21
64
  - lib/allotment/cucumber.rb
22
65
  - lib/allotment/stopwatch.rb
66
+ - lib/allotment/version.rb
23
67
  - lib/allotment.rb
24
68
  - spec/allotment_spec.rb
25
69
  - spec/helper.rb
@@ -48,7 +92,7 @@ rubyforge_project:
48
92
  rubygems_version: 2.0.3
49
93
  signing_key:
50
94
  specification_version: 4
51
- summary: Performance recording
95
+ summary: 'Allotment: Performance recording'
52
96
  test_files:
53
97
  - spec/allotment_spec.rb
54
98
  - spec/helper.rb