Skip to content

Commit

Permalink
Merge pull request #9 from benSlaughter/V1.0.2
Browse files Browse the repository at this point in the history
Updated code to use Hashie:Mash and updated specs to reflect.
  • Loading branch information
benSlaughter committed Aug 29, 2013
2 parents 1b365df + 273bbf9 commit 3fab88b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ source "http://rubygems.org"

gem 'coveralls', require: false
gem 'rspec'
gem 'hashie'
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ TODO
### Version 1.0.1
###### Patch: Added instance methods
* Added instance methods so that the module can be included into a class and allotment does not need to be called every time.
* Cleaned up stopwatch so that it had lap and split

## Version 1.0.2
###### Patch: Results returned as Hashie::Mash
* results methods now return results as a Hashie::Mash

## Planned Releases
### Version 1.1.0
Expand Down
4 changes: 2 additions & 2 deletions allotment.gemspec
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Gem::Specification.new do |spec|
spec.name = 'allotment'
spec.version = '1.0.1'
spec.version = '1.0.2'

spec.author = 'Ben Slaughter'
spec.email = '[email protected]'
spec.homepage = 'http://benslaughter.github.io/allotment/'

spec.summary = 'Performance recording'
spec.description = 'A gem for recording performance and timings of blocks or from point to point'
spec.description = 'A gem for recording performance and timings of blocks, procs or from point to point'
spec.require_path = 'lib'
spec.files = Dir['lib/**/*.rb']
spec.test_files = Dir['spec/**/*.rb']
Expand Down
7 changes: 4 additions & 3 deletions lib/allotment.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'allotment/array'
require 'allotment/stopwatch'
require 'json'
require 'hashie'

module Allotment
class << self
Expand All @@ -11,7 +12,7 @@ def record_event name = 'unnamed', &block
end

def start_recording name = 'unnamed'
@watches ||= Hash.new
@watches ||= Hashie::Mash.new
@watches[name] = Stopwatch.new name
end

Expand All @@ -20,9 +21,9 @@ def stop_recording name
result = watch.stop

# Dealing with the results
@results ||= Hash.new
@results ||= Hashie::Mash.new
@results[name] ||= Array.new
@results[name].push result
@results[name] << result

return result
end
Expand Down
4 changes: 2 additions & 2 deletions spec/allotment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class DummyClass
describe ".results" do
it "returns a hash" do
Allotment.record_event('my_recording4') { sleep 0.01 }
Allotment.results.class.should eq Hash
Allotment.results.class.should eq Hashie::Mash
end

it "returns a hash with the event in" do
Expand Down Expand Up @@ -180,7 +180,7 @@ class DummyClass

it "returns a hash" do
@dummy_class.record_event('my_recording4') { sleep 0.01 }
@dummy_class.results.class.should eq Hash
@dummy_class.results.class.should eq Hashie::Mash
end

it "returns a hash with the event in" do
Expand Down

0 comments on commit 3fab88b

Please sign in to comment.