toji 2.11.0 → 2.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/example/calendar.ipynb +42 -51
  3. data/example/calendar.yaml +6 -6
  4. data/example/calendar_file.ipynb +35 -35
  5. data/example/example_core.rb +882 -230
  6. data/example/kake_ingredient.rb +21 -15
  7. data/example/koji_ingredient.rb +31 -21
  8. data/example/{koji_making.ipynb → koji_progress.ipynb} +14 -14
  9. data/example/{koji_making.rb → koji_progress.rb} +3 -2
  10. data/example/{koji_making.yaml → koji_progress.yaml} +8 -9
  11. data/example/{koji_making_multi.ipynb → koji_progress_multi.ipynb} +21 -22
  12. data/example/{moromi.ipynb → moromi_progress.ipynb} +22 -22
  13. data/example/{moromi.rb → moromi_progress.rb} +3 -2
  14. data/example/{moromi.yaml → moromi_progress.yaml} +0 -0
  15. data/example/moto_progress.ipynb +121 -0
  16. data/example/{moto.rb → moto_progress.rb} +3 -2
  17. data/example/{moto.yaml → moto_progress.yaml} +14 -15
  18. data/example/recipe.rb +44 -32
  19. data/lib/toji.rb +4 -2
  20. data/lib/toji/calendar.rb +12 -12
  21. data/lib/toji/calendar/date_column.rb +8 -8
  22. data/lib/toji/calendar/date_row.rb +6 -6
  23. data/lib/toji/ingredient.rb +6 -2
  24. data/lib/toji/ingredient/alcohol.rb +14 -0
  25. data/lib/toji/ingredient/base.rb +11 -0
  26. data/lib/toji/ingredient/kake.rb +3 -9
  27. data/lib/toji/ingredient/koji.rb +19 -10
  28. data/lib/toji/ingredient/lactic_acid.rb +14 -0
  29. data/lib/toji/ingredient/rice.rb +50 -4
  30. data/lib/toji/ingredient/tanekoji.rb +29 -0
  31. data/lib/toji/ingredient/water.rb +18 -0
  32. data/lib/toji/ingredient/yeast.rb +20 -0
  33. data/lib/toji/processing.rb +18 -0
  34. data/lib/toji/processing/base.rb +7 -0
  35. data/lib/toji/processing/cooled_rice.rb +22 -0
  36. data/lib/toji/processing/cooled_rice_element.rb +8 -0
  37. data/lib/toji/processing/dekoji.rb +22 -0
  38. data/lib/toji/processing/dekoji_element.rb +8 -0
  39. data/lib/toji/processing/kake_processing.rb +7 -0
  40. data/lib/toji/processing/koji_processing.rb +10 -0
  41. data/lib/toji/processing/rice_processing.rb +19 -0
  42. data/lib/toji/processing/soaked_rice.rb +49 -0
  43. data/lib/toji/processing/soaked_rice_element.rb +18 -0
  44. data/lib/toji/processing/steamed_rice.rb +22 -0
  45. data/lib/toji/processing/steamed_rice_element.rb +8 -0
  46. data/lib/toji/product.rb +11 -32
  47. data/lib/toji/product/schedule_factory.rb +80 -0
  48. data/lib/toji/progress.rb +23 -0
  49. data/lib/toji/progress/base_progress.rb +37 -0
  50. data/lib/toji/progress/base_state.rb +39 -0
  51. data/lib/toji/progress/builder.rb +53 -0
  52. data/lib/toji/progress/graph.rb +11 -0
  53. data/lib/toji/{brew → progress}/graph/ab.rb +4 -4
  54. data/lib/toji/{brew → progress}/graph/bmd.rb +2 -2
  55. data/lib/toji/{brew/graph/multi_progress.rb → progress/graph/multi_progress_note.rb} +11 -11
  56. data/lib/toji/{brew/graph/progress.rb → progress/graph/progress_note.rb} +20 -18
  57. data/lib/toji/progress/koji_progress.rb +15 -0
  58. data/lib/toji/progress/koji_state.rb +23 -0
  59. data/lib/toji/{brew/moromi.rb → progress/moromi_progress.rb} +9 -5
  60. data/lib/toji/progress/moromi_state.rb +77 -0
  61. data/lib/toji/progress/moto_progress.rb +15 -0
  62. data/lib/toji/progress/moto_state.rb +31 -0
  63. data/lib/toji/progress/progress.rb +15 -0
  64. data/lib/toji/progress/state.rb +9 -0
  65. data/lib/toji/progress/state/baume_to_nihonshudo.rb +21 -0
  66. data/lib/toji/progress/state/nihonshudo_to_baume.rb +21 -0
  67. data/lib/toji/recipe.rb +51 -39
  68. data/lib/toji/recipe/ab_expect.rb +2 -2
  69. data/lib/toji/recipe/action.rb +2 -2
  70. data/lib/toji/recipe/step.rb +99 -71
  71. data/lib/toji/schedule.rb +5 -0
  72. data/lib/toji/schedule/action_schedule.rb +9 -0
  73. data/lib/toji/{event → schedule}/base.rb +1 -1
  74. data/lib/toji/schedule/kake_schedule.rb +11 -0
  75. data/lib/toji/schedule/koji_schedule.rb +11 -0
  76. data/lib/toji/schedule/rice_schedule.rb +16 -0
  77. data/lib/toji/utils.rb +43 -0
  78. data/lib/toji/version.rb +1 -1
  79. metadata +59 -45
  80. data/lib/toji/brew.rb +0 -18
  81. data/lib/toji/brew/base.rb +0 -55
  82. data/lib/toji/brew/builder.rb +0 -98
  83. data/lib/toji/brew/graph.rb +0 -11
  84. data/lib/toji/brew/koji.rb +0 -11
  85. data/lib/toji/brew/moto.rb +0 -11
  86. data/lib/toji/brew/state.rb +0 -122
  87. data/lib/toji/brew/wrapped_state.rb +0 -109
  88. data/lib/toji/event.rb +0 -5
  89. data/lib/toji/event/action_event.rb +0 -12
  90. data/lib/toji/event/kake_event.rb +0 -13
  91. data/lib/toji/event/koji_event.rb +0 -19
  92. data/lib/toji/event/rice_event.rb +0 -34
  93. data/lib/toji/ingredient/kake/actual.rb +0 -26
  94. data/lib/toji/ingredient/kake/base.rb +0 -18
  95. data/lib/toji/ingredient/kake/expected.rb +0 -40
  96. data/lib/toji/ingredient/koji/actual.rb +0 -29
  97. data/lib/toji/ingredient/koji/actual_fermentable.rb +0 -15
  98. data/lib/toji/ingredient/koji/base.rb +0 -35
  99. data/lib/toji/ingredient/koji/expected.rb +0 -45
  100. data/lib/toji/ingredient/koji/expected_fermentable.rb +0 -15
  101. data/lib/toji/ingredient/koji_rate.rb +0 -16
  102. data/lib/toji/ingredient/rice/actual_steamable.rb +0 -27
  103. data/lib/toji/ingredient/rice/base.rb +0 -40
  104. data/lib/toji/ingredient/rice/expected_steamable.rb +0 -27
  105. data/lib/toji/ingredient/rice_rate.rb +0 -23
  106. data/lib/toji/product/event_factory.rb +0 -70
@@ -1,18 +0,0 @@
1
- module Toji
2
- module Brew
3
- SECOND = 1
4
- MINUTE = 60 * SECOND
5
- HOUR = 60 * MINUTE
6
- DAY = 24 * HOUR
7
- end
8
- end
9
-
10
- require 'toji/brew/base'
11
- require 'toji/brew/wrapped_state'
12
- require 'toji/brew/state'
13
- require 'toji/brew/builder'
14
- require 'toji/brew/graph'
15
-
16
- require 'toji/brew/koji'
17
- require 'toji/brew/moto'
18
- require 'toji/brew/moromi'
@@ -1,55 +0,0 @@
1
- module Toji
2
- module Brew
3
- module Base
4
- REQUIRED_KEYS = [
5
- :time,
6
- :elapsed_time,
7
- :day,
8
- :day_label,
9
- :display_time,
10
- ].freeze
11
-
12
- OPTIONAL_KEYS = [
13
- :moromi_day,
14
- :mark,
15
- :temps,
16
- :preset_temp,
17
- :room_temp,
18
- :room_psychrometry,
19
- :baume,
20
- :nihonshudo,
21
- :display_baume,
22
- :acid,
23
- :amino_acid,
24
- :alcohol,
25
- :bmd,
26
- :warmings,
27
- :note,
28
- ].freeze
29
-
30
- attr_accessor :wrapped_states
31
- attr_accessor :day_offset
32
- attr_accessor :base_time
33
-
34
- def days
35
- ((wrapped_states.last.elapsed_time_with_offset.to_f + 1) / DAY).ceil
36
- end
37
-
38
- def day_labels
39
- days.times.map(&:succ).map(&:to_s)
40
- end
41
-
42
- def moromi_tome_day
43
- nil
44
- end
45
-
46
- def has_keys
47
- result = REQUIRED_KEYS.dup
48
-
49
- result += OPTIONAL_KEYS.select {|k|
50
- wrapped_states.find {|s| s.send(k).present?}
51
- }
52
- end
53
- end
54
- end
55
- end
@@ -1,98 +0,0 @@
1
- module Toji
2
- module Brew
3
- class Builder
4
-
5
- def initialize(cls)
6
- @cls = cls
7
- @states = []
8
- @date_line = 0
9
- @prefix_day_labels = nil
10
- @base_time = nil
11
- @time_interpolation = false
12
- @elapsed_time_interpolation = false
13
- end
14
-
15
- def <<(state)
16
- @states += [state].flatten.map {|state|
17
- State.create(state)
18
- }
19
- self
20
- end
21
- alias_method :add, :<<
22
-
23
- def date_line(val, unit=SECOND)
24
- @date_line = (val * unit).to_i
25
- self
26
- end
27
-
28
- def prefix_day_labels(val)
29
- @prefix_day_labels = val
30
- self
31
- end
32
-
33
- def time_interpolation(base_time)
34
- @base_time = base_time&.to_time
35
- @time_interpolation = true
36
- #@elapsed_time_interpolation = false
37
- self
38
- end
39
-
40
- def elapsed_time_interpolation
41
- #@base_time = nil
42
- #@time_interpolation = false
43
- @elapsed_time_interpolation = true
44
- self
45
- end
46
-
47
- def build
48
- brew = @cls.new
49
-
50
- wrapped_states = @states.map{|s| WrappedState.new(s, brew)}
51
-
52
- # time interpolation
53
- if @time_interpolation
54
- base_time = @base_time
55
-
56
- base_state = wrapped_states.select{|w| w.time && w.elapsed_time}.first
57
- if base_state
58
- base_time = base_state.time - base_state.elapsed_time
59
- end
60
-
61
- wrapped_states.each {|w|
62
- if w.elapsed_time
63
- w.time = base_time + w.elapsed_time
64
- end
65
- }
66
- end
67
-
68
- # elapsed_time interpolation
69
- if @elapsed_time_interpolation
70
- base_time = wrapped_states.map(&:time).sort.first
71
- wrapped_states.each {|w|
72
- if w.time
73
- w.elapsed_time = (w.time - base_time).to_i
74
- end
75
- }
76
- end
77
-
78
- wrapped_states = wrapped_states.sort_by(&:elapsed_time)
79
- base_time = wrapped_states.first&.time
80
-
81
- # day_offset
82
- day_offset = 0
83
- if base_time
84
- day_offset = base_time - Time.mktime(base_time.year, base_time.month, base_time.day)
85
- end
86
- day_offset = (DAY - @date_line + day_offset) % DAY
87
-
88
- brew.wrapped_states = wrapped_states
89
- brew.day_offset = day_offset
90
- brew.base_time = base_time
91
- if Moromi===brew
92
- brew.prefix_day_labels = @prefix_day_labels
93
- end
94
- brew
95
- end
96
- end
97
- end
98
- end
@@ -1,11 +0,0 @@
1
- require 'toji/brew/graph/progress'
2
- require 'toji/brew/graph/multi_progress'
3
- require 'toji/brew/graph/bmd'
4
- require 'toji/brew/graph/ab'
5
-
6
- module Toji
7
- module Brew
8
- module Graph
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Toji
2
- module Brew
3
- module Koji
4
- include Base
5
-
6
- def progress(name: nil, dash: :solid, enable_annotations: true)
7
- Graph::Progress.new(self, name: name, dash: dash, enable_annotations: enable_annotations)
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Toji
2
- module Brew
3
- module Moto
4
- include Base
5
-
6
- def progress(name: nil, dash: :solid, enable_annotations: true)
7
- Graph::Progress.new(self, name: name, dash: dash, enable_annotations: enable_annotations)
8
- end
9
- end
10
- end
11
- end
@@ -1,122 +0,0 @@
1
- module Toji
2
- module Brew
3
- module State
4
- KEYS = [
5
- :time,
6
- :elapsed_time,
7
- :mark,
8
- :temps,
9
- :preset_temp,
10
- :room_temp,
11
- :room_psychrometry,
12
- :baume,
13
- :nihonshudo,
14
- :acid,
15
- :amino_acid,
16
- :alcohol,
17
- :warmings,
18
- :note,
19
- ].freeze
20
-
21
- attr_accessor :time
22
- attr_accessor :elapsed_time
23
- attr_accessor :mark
24
- attr_accessor :temps
25
-
26
- attr_accessor :preset_temp
27
- attr_accessor :room_temp
28
- attr_accessor :room_psychrometry
29
-
30
- attr_accessor :baume
31
- attr_accessor :nihonshudo
32
- attr_accessor :acid
33
- attr_accessor :amino_acid
34
- attr_accessor :alcohol
35
-
36
- attr_accessor :warmings
37
- attr_accessor :note
38
-
39
-
40
- def self.included(cls)
41
- cls.prepend PrependMethods
42
- end
43
-
44
- module PrependMethods
45
- def temps
46
- (super || []).map(&:to_f)
47
- end
48
-
49
- def temps=(val)
50
- super([val].flatten.compact.map(&:to_f))
51
- end
52
-
53
- def time=(val)
54
- super(val&.to_time)
55
- end
56
-
57
- def warmings
58
- super || []
59
- end
60
-
61
- def warmings=(val)
62
- super([val].flatten.compact)
63
- end
64
- end
65
-
66
- module BaumeToNihonshudo
67
- def nihonshudo
68
- if self.baume
69
- self.baume * -10
70
- end
71
- end
72
-
73
- def nihonshudo=(val)
74
- if val
75
- self.baume = val.to_f / -10.0
76
- else
77
- self.baume = nil
78
- end
79
- end
80
- end
81
-
82
- module NihonshudoToBaume
83
- def baume
84
- if self.nihonshudo
85
- self.nihonshudo / -10.0
86
- end
87
- end
88
-
89
- def baume=(val)
90
- if val
91
- self.nihonshudo = val.to_f * -10
92
- else
93
- self.nihonshudo = nil
94
- end
95
- end
96
- end
97
-
98
- def self.create(val)
99
- if State===val
100
- val
101
- elsif WrappedState==val
102
- val.state
103
- #elsif Hash===val
104
- # #s = Class.new {
105
- # # include State
106
- # #}.new
107
- # s = Object.new.tap {|o|
108
- # o.extend State
109
- # o.extend State::PrependMethods
110
- # }
111
-
112
- # KEYS.each {|k|
113
- # s.send("#{k}=", val[k])
114
- # }
115
- # s
116
- else
117
- raise Error, "ArgumentError: cant cast to Toji::Brew::State"
118
- end
119
- end
120
- end
121
- end
122
- end
@@ -1,109 +0,0 @@
1
- require 'forwardable'
2
-
3
- module Toji
4
- module Brew
5
- class WrappedState
6
- extend Forwardable
7
-
8
- attr_accessor :elapsed_time
9
- attr_accessor :time
10
- attr_reader :state
11
- attr_reader :brew
12
-
13
- def_delegators :@state, :mark
14
- def_delegators :@state, :temps
15
- def_delegators :@state, :preset_temp
16
- def_delegators :@state, :room_temp
17
- def_delegators :@state, :room_psychrometry
18
- def_delegators :@state, :acid
19
- def_delegators :@state, :amino_acid
20
- def_delegators :@state, :alcohol
21
- def_delegators :@state, :warmings
22
- def_delegators :@state, :note
23
-
24
- def initialize(state, brew)
25
- @elapsed_time = state.elapsed_time
26
- @time = state.time
27
- @state = state
28
- @brew = brew
29
- end
30
-
31
- def day
32
- ((elapsed_time_with_offset.to_f + 1) / DAY).ceil
33
- end
34
-
35
- def day_label
36
- @brew.day_labels[day - 1]
37
- end
38
-
39
- def elapsed_time_with_offset
40
- @elapsed_time + @brew.day_offset
41
- end
42
-
43
- def baume
44
- if @state.baume
45
- @state.baume
46
- elsif @state.nihonshudo
47
- @state.nihonshudo * -0.1
48
- end
49
- end
50
-
51
- def nihonshudo
52
- if @state.nihonshudo
53
- @state.nihonshudo
54
- elsif @state.baume
55
- @state.baume * -10
56
- end
57
- end
58
-
59
- def display_baume
60
- if @state.baume || @state.nihonshudo
61
- b = baume
62
- if b<3.0
63
- nihonshudo
64
- else
65
- b
66
- end
67
- end
68
- end
69
-
70
- def display_time(format="%m/%d %H:%M")
71
- if @time
72
- @time.strftime(format)
73
- elsif @brew.base_time
74
- time = @brew.base_time + @elapsed_time
75
- time.strftime(format)
76
- else
77
- utc_offset = Time.at(0).utc_offset
78
- Time.at(@elapsed_time - utc_offset).strftime(format)
79
- end
80
- end
81
-
82
- def moromi_day
83
- _tome_day = @brew.moromi_tome_day
84
- _now_day = day
85
-
86
- if _tome_day && _tome_day < _now_day
87
- _now_day - _tome_day + 1
88
- end
89
- end
90
-
91
- def bmd
92
- _moromi_day = moromi_day
93
- _baume = baume
94
-
95
- if _moromi_day && _baume
96
- _moromi_day * _baume
97
- end
98
- end
99
-
100
- def expected_alcohol(target_alc, target_nihonshudo, coef)
101
- _baume = baume
102
-
103
- if _baume
104
- target_alc - (_baume - target_nihonshudo * -0.1) * coef
105
- end
106
- end
107
- end
108
- end
109
- end
@@ -1,5 +0,0 @@
1
- require 'toji/event/base'
2
- require 'toji/event/rice_event'
3
- require 'toji/event/koji_event'
4
- require 'toji/event/kake_event'
5
- require 'toji/event/action_event'