monte_carlo 0.0.2 → 0.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: 27d0d6f2d94ff5bae23bdce1a811746b7565ac72
4
- data.tar.gz: 5abd18cc7ddaab12b7c3b3517bf116bff212e5ca
3
+ metadata.gz: ef6a0aa8d4fd8f0b8f60700ad4549563952f69fe
4
+ data.tar.gz: 1d15e936a13cb0bfdaaeb2a36b752d06d26459f7
5
5
  SHA512:
6
- metadata.gz: 622bf094b783f579e2562c7b1198c59471f20d14f2d3090a7f7e8c70a9d030cd80787dab016260a81c5bf99333ed336b31082f3deee072a61c575c64565712a9
7
- data.tar.gz: d6ffd095586563317402af2b8e019763428f625aad0be7383e5839f1e15b7661c76604da6884da57b2b50d6679cd45ecc4a092d1f12920bfe8bd64de156e2b76
6
+ metadata.gz: 81940955856dda65cbb0984657db4aa294c7121fd554810987c96a141c8a1a89c6739cf111f8220589f23412536cd98fc9d18a37e178eb2cd6b1fe88acbb346c
7
+ data.tar.gz: 29a87e308d27eb64762c7b12201a99ad7bb94d4ba68720b0331ed7ccbfd51768a8c0378612956a667239e5ca68101e4ac3f8df06c6aaf6019682abb6119c8e53
data/README.md CHANGED
@@ -24,7 +24,7 @@ Each experiment conatins:
24
24
  - `times`: the number of sample to create (defaults to 10,000)
25
25
  - `sample_method`: the method with which to generate a sample each iteration
26
26
  - `computation`: an optional coputation method to run on each sample to obtain a result
27
- - `before_each` & `after_each`: optional methods to run before and after each iteration
27
+ - `setup` & `reset`: optional methods to run before and after each iteration
28
28
 
29
29
  For example;
30
30
 
@@ -3,7 +3,7 @@ module MonteCarlo
3
3
 
4
4
  DEFAULT_TIMES = 10000
5
5
 
6
- attr_accessor :times, :sample_method, :computation, :before_each, :after_each
6
+ attr_accessor :times, :sample_method, :computation, :setup, :reset
7
7
 
8
8
  def self.run(times = DEFAULT_TIMES, &block)
9
9
  MonteCarlo::Experiment.new(times, &block).run
@@ -23,10 +23,10 @@ module MonteCarlo
23
23
 
24
24
  @times.times do |index|
25
25
  begin
26
- @before_each.call() unless @before_each.nil?
26
+ @setup.call() unless @setup.nil?
27
27
  results << run_sample(index)
28
28
  ensure
29
- @after_each.call() unless @after_each.nil?
29
+ @reset.call() unless @reset.nil?
30
30
  end
31
31
  end
32
32
 
@@ -1,3 +1,3 @@
1
1
  module MonteCarlo
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -44,30 +44,30 @@ describe MonteCarlo::Experiment do
44
44
  end
45
45
  end
46
46
 
47
- describe :before_each do
48
- let(:before) { double(call: nil) }
47
+ describe :setup do
48
+ let(:setup) { double(call: nil) }
49
49
 
50
- before { experiment.before_each = before }
50
+ before { experiment.setup = setup }
51
51
 
52
- it 'should run the before_each method before each run' do
53
- expect(before).to receive(:call).exactly(times).times
52
+ it 'should run the setup method before each run' do
53
+ expect(setup).to receive(:call).exactly(times).times
54
54
  experiment.run
55
55
  end
56
56
  end
57
57
 
58
- describe :after_each do
59
- let(:after) { double(call: nil) }
58
+ describe :reset do
59
+ let(:reset) { double(call: nil) }
60
60
 
61
- before { experiment.after_each = after }
61
+ before { experiment.reset = reset }
62
62
 
63
- it 'should run the after_each method after each run' do
64
- expect(after).to receive(:call).exactly(times).times
63
+ it 'should run the reset method after each run' do
64
+ expect(reset).to receive(:call).exactly(times).times
65
65
  experiment.run
66
66
  end
67
67
 
68
- it 'should run even when sample method raises exception' do
68
+ it 'should run reset method even when sample method raises exception' do
69
69
  experiment.sample_method = -> { raise }
70
- expect(after).to receive(:call).exactly(:once)
70
+ expect(reset).to receive(:call).exactly(:once)
71
71
  experiment.run rescue nil
72
72
  end
73
73
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monte_carlo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Assaf Gelber
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-03 00:00:00.000000000 Z
11
+ date: 2014-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler