diff --git a/Gemfile b/Gemfile index dab29c3..8c6a2a4 100644 --- a/Gemfile +++ b/Gemfile @@ -2,3 +2,4 @@ source "http://rubygems.org" gem 'coveralls', require: false gem 'rspec' +gem 'hashie' diff --git a/README.md b/README.md index 710e2cd..aca0a24 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/allotment.gemspec b/allotment.gemspec index aceecd0..6d726a4 100644 --- a/allotment.gemspec +++ b/allotment.gemspec @@ -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 = 'b.p.slaughter@gmail.com' 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'] diff --git a/lib/allotment.rb b/lib/allotment.rb index 6708d59..9f151c0 100644 --- a/lib/allotment.rb +++ b/lib/allotment.rb @@ -1,6 +1,7 @@ require 'allotment/array' require 'allotment/stopwatch' require 'json' +require 'hashie' module Allotment class << self @@ -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 @@ -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 diff --git a/spec/allotment_spec.rb b/spec/allotment_spec.rb index f55088c..ef156c9 100644 --- a/spec/allotment_spec.rb +++ b/spec/allotment_spec.rb @@ -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 @@ -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