montecasting 0.5.2 → 0.5.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
  SHA256:
3
- metadata.gz: 5664fa998c043f2136808d18abba13a43a3e6a4e0b2830687f069bb6e7e8b835
4
- data.tar.gz: 6f437089f9d6744d9d0756ac3fa00c18bb1ab4fb76424a6147b2f8be3131ed85
3
+ metadata.gz: fc1cea3cdc7c44a967d906b100e06a369241c85f226de705e062e488ec62144a
4
+ data.tar.gz: 26b3795439c0546b875e413da6799237db3d1fb99568a110f67bf26f64c3ebfb
5
5
  SHA512:
6
- metadata.gz: 3e6d64829b1485611fcc53c62f22fc36d0f643674b82b9dd9f11926ae266066cd6a156e84c017bf712acb95e322e5dc5266d0af3e308193882660beb37be9b7b
7
- data.tar.gz: 210a65bdc6626228efe9e2bf5647abc708bc10c3d623890ef48746446039496f89f8009dc7576a0bd33c3df95b02f08d15b09cd68b305a911cc6eacfcf519789
6
+ metadata.gz: 6fc675a2715ca09b946efd0ea0098c8f495283bbe0efab39b152b6136e4ddc2c5194d032904cb73166d56ff294d678508b3334ccae1257e3d3df14a8a85b6055
7
+ data.tar.gz: 22fca78398acc802f8c79175d741ae44c4ff6340d1cf97b62b3f8d3cadb9e76a4c865866b5b0f2e35da6aaa62d2199c55e25e4f16f2db9cdcd3e994a743df023
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- montecasting (0.5.1)
4
+ montecasting (0.5.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -24,44 +24,44 @@ Or install it yourself as:
24
24
  ## Usage
25
25
  #### Metrics
26
26
 
27
- Montecasting::Metrics.variance array_of_time = []
27
+ Montecasting::Metrics.variance(array_of_time = []) → int or nil
28
28
 
29
- Montecasting::Metrics.wip_limit array_of_time = [], start_date, end_date
29
+ Montecasting::Metrics.wip_limit(array_of_time = [], start_date, end_date) → int or nil
30
30
 
31
- Montecasting::Metrics.thoughtput number_or_items, start_date, end_date
32
-
33
- Montecasting::Metrics.week_days start_date, end_date
31
+ Montecasting::Metrics.thoughtput(number_or_items, start_date, end_date) → int or nil
34
32
 
33
+ Montecasting::Metrics.week_days(start_date, end_date) → new_ary
34
+
35
+ #### Forecasting
36
+
37
+ Montecasting::Forecasting.takt_times(cycle_time = [], rand_generator = 1000) → new_ary or nil
38
+
39
+ Montecasting::Forecasting.montecarlo(takt_times = [], backlog_items = 0, days_iteration = 0) → new_ary or nil
40
+
35
41
  #### Charts
36
- All methods in this section will be returned in a format that, so far, has been tested using rickshaw JavaScript toolkit for creating interactive real-time graphs.
37
- Checkout https://github.com/shutterstock/rickshaw for more information.
38
42
 
39
- > Montecasting::Charts.chart_cycle_time array_of_time = [], round_to = 0.5
40
- > [[{:x=>0, :y=>0},
43
+ Montecasting::Charts.chart_takt_times(array_of_times = []) [[{:x=> X,:y=> Y}]] or nil
44
+
45
+ Montecasting::Charts.chart_montecarlo(array_of_times = [], backlog_items = 0, days_iteration = 0) → [[{:x=> X,:y=> Y}]] or nil
46
+
47
+ Montecasting::Charts.chart_cycle_time(array_of_time = [], round_to = 0.5) → [[{:x=> X,:y=> Y}]] or nil
48
+
49
+ As a result of calling any method from Charts class, the message retrieved will have the following format
50
+
51
+ [[{:x=>0, :y=>0},
41
52
  {:x=>1, :y=>1},
42
- {:x=>2, :y=>2},
43
- {:x=>3, :y=>3},
44
- {:x=>4, :y=>4},
45
53
  ...
46
54
  {:x=>15, :y=>15}],
47
55
  [{:x=>0, :y=>5},
48
- {:x=>1, :y=>20},
49
- {:x=>2, :y=>8},
50
- {:x=>3, :y=>3},
51
- {:x=>4, :y=>0},
52
56
  ...
53
57
  {:x=>15, :y=>1}],
54
58
  [{:x=>0, :y=>0.0},
55
- {:x=>1, :y=>13.5},
56
- {:x=>2, :y=>67.6},
57
- {:x=>3, :y=>89.2},
58
- {:x=>4, :y=>97.3},
59
59
  ...
60
60
  {:x=>15, :y=>97.3}]]
61
-
62
- #### Forecasting
63
- Nothing implemented yet :-)
64
-
61
+
62
+ So far, this format has been tested using rickshaw JavaScript toolkit for creating interactive real-time graphs.
63
+ Checkout https://github.com/shutterstock/rickshaw for more information.
64
+
65
65
  ## Development
66
66
 
67
67
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,7 +1,7 @@
1
1
  require 'montecasting/version'
2
2
  require 'montecasting/numeric'
3
- require 'montecasting/array'
4
- require 'montecasting/hash'
3
+ require 'montecasting/chart'
4
+
5
5
  require 'matrix'
6
6
 
7
7
  module Montecasting
@@ -52,7 +52,7 @@ module Montecasting
52
52
  result.row_vectors.map {|r| (r.inject(:+).to_f / cycle_time.count).round(2)}
53
53
  end
54
54
 
55
- def self.montecarlo(takt_times = [], backlog_items = 0, days_iteration = 0)
55
+ def self.montecarlo(takt_times = [], backlog_items = 1, days_iteration = 1)
56
56
  return nil unless takt_times.all? Numeric
57
57
  takt_times.map {|tt| ((tt * backlog_items) / days_iteration).round(0)}.sort
58
58
  end
@@ -64,31 +64,27 @@ module Montecasting
64
64
 
65
65
  def self.chart_takt_times(array_of_times = [])
66
66
  return nil unless array_of_times.all? Numeric
67
- result = Forecasting.takt_times(array_of_times)&.sort.group_to_hash
68
- legend = result.to_chart(&:to_i)
69
- x_axis = result.to_chart { |value| value.percent_of(1000).ceil(0) }
70
- y_axis = result.keys.to_chart { |index| result.values.take(index).inject(0) {|acc, elem| acc + elem}.percent_of(1000).ceil(0) }
71
- [legend,x_axis,y_axis]
67
+ chart_builder Forecasting.takt_times(array_of_times)&.sort
72
68
  end
73
69
 
74
70
  def self.chart_montecarlo(array_of_times = [], backlog_items = 0, days_iteration = 0)
75
71
  return nil unless array_of_times.all? Numeric
76
- result = Forecasting.takt_times(array_of_times)&.map! {|elem| ((elem * backlog_items) / days_iteration).ceil(0)}.group_to_hash
77
- legend = result.to_chart(&:to_i)
78
- x_axis = result.to_chart { |value| value.percent_of(1000).ceil(0) }
79
- y_axis = result.keys.to_chart { |index| result.values.take(index).inject(0) {|acc, elem| acc + elem}.percent_of(1000).ceil(0) }
80
- [legend,x_axis,y_axis]
72
+ chart_builder Forecasting.takt_times(array_of_times)&.map! {|elem| ((elem * backlog_items) / days_iteration).ceil(0)}
81
73
  end
82
74
 
83
75
  def self.chart_cycle_time(array_of_times = [], round_to = 0.5)
84
76
  return nil unless array_of_times.all? Numeric
85
- data = Array.new {Array.new}
86
77
  ct_sorted = array_of_times.sort.map {|ct| ct.abs.to_f.round(round_to)}
87
- max_index = ct_sorted.last
88
- data[0] = [*0..max_index].map {|index| {x: index, y: index}}
89
- data[1] = [*0..max_index].map {|index| {x: index, y: ct_sorted.count {|elem| elem.eql? index}}}
90
- data[2] = data[1].map.with_index {|sc, index| {x: index, y: data[1].take(index).inject(0) {|acc, elem| acc + elem[:y]}.percent_of(ct_sorted.count).round(1)}}
91
- data
78
+ chart = Chart.new(ct_sorted)
79
+ [chart.group_by,chart.cumulative(ct_sorted.count)]
92
80
  end
81
+
82
+ private
83
+
84
+ def self.chart_builder chart_hash
85
+ chart = Chart.new(chart_hash)
86
+ [chart.group_by, chart.percent_of, chart.cumulative]
87
+ end
88
+
93
89
  end
94
90
  end
@@ -1,11 +1,4 @@
1
1
  class Array
2
- def array_to_hash
3
- each {|sprint|
4
- #the string must contain a par elements, first would be the kay and the next one the value
5
- #Fist step it transforma a string into an array and then creates a hash getting pairs.
6
- yield Hash[*sprint.chop[(sprint.index('[') + 1)..-1].gsub!('=', ',').split(',')]
7
- }
8
- end
9
2
 
10
3
  def average
11
4
  inject {|sum, el| sum + el}.to_f / size
@@ -17,10 +10,6 @@ class Array
17
10
  (sorted[(len - 1) / 2] + sorted[len / 2]) / 2.0
18
11
  end
19
12
 
20
- def group_to_hash
21
- uniq.sort.to_h {|s| [s, count{|elem| elem.equal? s}]}
22
- end
23
-
24
13
  def to_chart
25
14
  result = Array.new
26
15
  each_with_index {|value, index| result << {x: value, y: yield(index)} }
@@ -0,0 +1,40 @@
1
+ require 'montecasting/array'
2
+ require 'montecasting/hash'
3
+
4
+ class Chart
5
+ include Enumerable
6
+
7
+ def initialize(arry_times)
8
+ @elements = arry_times
9
+ end
10
+
11
+ def each(&block)
12
+ @elements.each(&block)
13
+ end
14
+
15
+ def <=>(other_value)
16
+ self <=> other_value
17
+ end
18
+
19
+ def legend
20
+ to_h.to_chart()
21
+ end
22
+
23
+ def group_by
24
+ to_h.to_chart(&:to_i)
25
+ end
26
+
27
+ def percent_of
28
+ to_h.to_chart {|value| value.percent_of(1000).ceil(0)}
29
+ end
30
+
31
+ def cumulative percent = 1000
32
+ to_h.keys.to_chart {|index| to_h.values.take(index).inject(0) {|acc, elem| acc + elem}.percent_of(percent).ceil(0)}
33
+
34
+ end
35
+
36
+ def to_h
37
+ uniq.sort.to_h {|s| [s, count{|elem| elem.equal? s}]}
38
+ end
39
+
40
+ end
@@ -2,5 +2,5 @@ module Montecasting
2
2
  # MAJOR version when you make incompatible API changes,
3
3
  # MINOR version when you add functionality in a backwards compatible manner, and
4
4
  # PATCH version when you make backwards compatible bug fixes.
5
- VERSION = "0.5.2"
5
+ VERSION = "0.5.3"
6
6
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: montecasting
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduard Garcia Castello
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-22 00:00:00.000000000 Z
11
+ date: 2019-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -75,6 +75,7 @@ files:
75
75
  - bin/setup
76
76
  - lib/montecasting.rb
77
77
  - lib/montecasting/array.rb
78
+ - lib/montecasting/chart.rb
78
79
  - lib/montecasting/hash.rb
79
80
  - lib/montecasting/numeric.rb
80
81
  - lib/montecasting/version.rb
@@ -87,6 +88,7 @@ files:
87
88
  - montecasting-0.3.0.gem
88
89
  - montecasting-0.4.0.gem
89
90
  - montecasting-0.5.0.gem
91
+ - montecasting-0.5.2.gem
90
92
  - montecasting.gemspec
91
93
  homepage: https://github.com/eddygarcas/montecasting
92
94
  licenses: