toji 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/example/koji_making.ipynb +7 -7
  3. data/example/koji_making.rb +5 -5
  4. data/example/koji_recipe.rb +1 -1
  5. data/example/moromi.ipynb +55 -21
  6. data/example/moromi.rb +5 -5
  7. data/example/rice_recipe.rb +2 -2
  8. data/example/shubo.ipynb +6 -6
  9. data/example/shubo.rb +5 -5
  10. data/example/three_step_mashing_recipe.rb +2 -2
  11. data/lib/toji/brew/base.rb +88 -0
  12. data/lib/toji/brew/builder.rb +27 -0
  13. data/lib/toji/brew/graph/ab.rb +85 -0
  14. data/lib/toji/brew/graph/bmd.rb +58 -0
  15. data/lib/toji/brew/graph/progress.rb +142 -0
  16. data/lib/toji/brew/graph.rb +10 -0
  17. data/lib/toji/{product/koji_making.rb → brew/koji.rb} +35 -43
  18. data/lib/toji/{product → brew}/moromi.rb +105 -96
  19. data/lib/toji/brew/shubo.rb +122 -0
  20. data/lib/toji/brew/state.rb +117 -0
  21. data/lib/toji/{product/job_accessor.rb → brew/state_accessor.rb} +4 -4
  22. data/lib/toji/brew/state_record.rb +82 -0
  23. data/lib/toji/brew.rb +21 -0
  24. data/lib/toji/recipe/ingredient/koji/actual.rb +23 -0
  25. data/lib/toji/recipe/ingredient/koji/actual_fermentable.rb +17 -0
  26. data/lib/toji/recipe/ingredient/koji/base.rb +28 -0
  27. data/lib/toji/recipe/ingredient/koji/expected.rb +53 -0
  28. data/lib/toji/recipe/ingredient/koji/expected_fermentable.rb +17 -0
  29. data/lib/toji/recipe/ingredient/koji.rb +21 -0
  30. data/lib/toji/recipe/ingredient/lactic_acid.rb +21 -0
  31. data/lib/toji/recipe/ingredient/rice/actual.rb +20 -0
  32. data/lib/toji/recipe/ingredient/rice/actual_steamable.rb +29 -0
  33. data/lib/toji/recipe/ingredient/rice/base.rb +42 -0
  34. data/lib/toji/recipe/ingredient/rice/expected.rb +48 -0
  35. data/lib/toji/recipe/ingredient/rice/expected_steamable.rb +31 -0
  36. data/lib/toji/recipe/ingredient/rice.rb +21 -0
  37. data/lib/toji/recipe/ingredient/yeast.rb +21 -0
  38. data/lib/toji/recipe/ingredient.rb +11 -0
  39. data/lib/toji/recipe/lactic_acid_rate.rb +17 -0
  40. data/lib/toji/recipe/three_step_mashing.rb +4 -2
  41. data/lib/toji/recipe/yeast_rate.rb +41 -0
  42. data/lib/toji/recipe.rb +3 -0
  43. data/lib/toji/version.rb +1 -1
  44. data/lib/toji.rb +1 -3
  45. metadata +32 -29
  46. data/lib/toji/graph/ab.rb +0 -79
  47. data/lib/toji/graph/bmd.rb +0 -56
  48. data/lib/toji/graph/progress.rb +0 -87
  49. data/lib/toji/graph.rb +0 -8
  50. data/lib/toji/ingredient/koji/actual.rb +0 -21
  51. data/lib/toji/ingredient/koji/actual_fermentable.rb +0 -15
  52. data/lib/toji/ingredient/koji/base.rb +0 -26
  53. data/lib/toji/ingredient/koji/expected.rb +0 -51
  54. data/lib/toji/ingredient/koji/expected_fermentable.rb +0 -15
  55. data/lib/toji/ingredient/koji.rb +0 -19
  56. data/lib/toji/ingredient/rice/actual.rb +0 -18
  57. data/lib/toji/ingredient/rice/actual_steamable.rb +0 -27
  58. data/lib/toji/ingredient/rice/base.rb +0 -40
  59. data/lib/toji/ingredient/rice/expected.rb +0 -46
  60. data/lib/toji/ingredient/rice/expected_steamable.rb +0 -29
  61. data/lib/toji/ingredient/rice.rb +0 -19
  62. data/lib/toji/ingredient/yeast/base.rb +0 -21
  63. data/lib/toji/ingredient/yeast/red_star.rb +0 -30
  64. data/lib/toji/ingredient/yeast.rb +0 -9
  65. data/lib/toji/ingredient.rb +0 -8
  66. data/lib/toji/product/base.rb +0 -74
  67. data/lib/toji/product/job.rb +0 -176
  68. data/lib/toji/product/shubo.rb +0 -130
  69. data/lib/toji/product.rb +0 -11
@@ -1,74 +0,0 @@
1
- module Toji
2
- module Product
3
- class Base
4
- include Enumerable
5
- extend JobAccessor
6
-
7
- attr_accessor :date_line
8
- attr_reader :day_offset
9
-
10
- def initialize(arr=[], date_line: 0)
11
- @_arr = []
12
- @_hash = {}
13
- @date_line = date_line
14
- @day_offset = 0
15
-
16
- arr.each {|j|
17
- self << j
18
- }
19
- end
20
-
21
- def [](id)
22
- @_hash[id]
23
- end
24
-
25
- def <<(job)
26
- job = Job.create(job)
27
- if job.id
28
- if @_hash[job.id]
29
- @_arr.delete(@_hash[job.id])
30
- end
31
- @_hash[job.id] = job
32
- end
33
- @_arr << job
34
- job.jobs = self
35
- _normalization
36
- self
37
- end
38
- alias_method :add, :<<
39
-
40
- def _normalization
41
- min_time = @_arr.select{|j| j.time}.map(&:time).sort.first
42
-
43
- if min_time
44
- @_arr.each {|j|
45
- if j.time
46
- j.elapsed_time = (j.time - min_time).to_i
47
- else
48
- j.time = min_time + j.elapsed_time
49
- end
50
- }
51
- end
52
-
53
- @_arr = @_arr.sort{|a,b| a.elapsed_time<=>b.elapsed_time}
54
-
55
- t = @_arr.first&.time
56
- if t
57
- @day_offset = t - Time.mktime(t.year, t.month, t.day)
58
- else
59
- @day_offset = 0
60
- end
61
- @day_offset += ((24 - @date_line) % 24) * Job::HOUR
62
- end
63
-
64
- def each(&block)
65
- _normalization
66
- @_arr.each(&block)
67
- end
68
-
69
- def days
70
- ((to_a.last.elapsed_time.to_f + @date_line * Job::HOUR) / Job::DAY).ceil + 1
71
- end
72
- end
73
- end
74
- end
@@ -1,176 +0,0 @@
1
- module Toji
2
- module Product
3
- class Job
4
- HOUR = 60 * 60
5
- DAY = 24 * HOUR
6
-
7
- WARM_DAKI = 1
8
- WARM_ANKA = 1<<1
9
- WARM_MAT = 1<<2
10
-
11
- attr_accessor :jobs
12
-
13
- attr_accessor :time
14
- attr_accessor :elapsed_time
15
- attr_accessor :id
16
- attr_accessor :temps
17
-
18
- attr_accessor :preset_temp
19
- attr_accessor :room_temp
20
- attr_accessor :room_psychrometry
21
-
22
- attr_accessor :baume
23
- attr_accessor :nihonshudo
24
- attr_accessor :acid
25
- attr_accessor :amino_acid
26
- attr_accessor :alcohol
27
-
28
- attr_accessor :warming
29
- attr_accessor :note
30
-
31
- def initialize(
32
- time: nil, elapsed_time: nil, id: nil, temps: nil,
33
- preset_temp: nil, room_temp: nil, room_psychrometry: nil,
34
- baume: nil, nihonshudo: nil, acid: nil, amino_acid: nil, alcohol: nil,
35
- warming: nil, note: nil)
36
- @time = time
37
- @elapsed_time = elapsed_time
38
- @id = id
39
- self.temps = temps
40
-
41
- @preset_temp = preset_temp
42
- @room_temp = room_temp
43
- @room_psychrometry = room_psychrometry
44
-
45
- @baume = baume
46
- @nihonshudo = nihonshudo
47
- @acid = acid
48
- @amino_acid = amino_acid
49
- @alcohol = alcohol
50
-
51
- @warming = warming
52
- @note = note
53
- end
54
-
55
- def temps=(val)
56
- @temps = [val].flatten.select{|t| t}
57
- end
58
-
59
- def baume
60
- if @baume
61
- @baume
62
- elsif @nihonshudo
63
- @nihonshudo * -0.1
64
- end
65
- end
66
-
67
- def nihonshudo
68
- if @nihonshudo
69
- @nihonshudo
70
- elsif @baume
71
- @baume * -10
72
- else
73
- nil
74
- end
75
- end
76
-
77
- def display_baume
78
- if @baume || @nihonshudo
79
- b = baume
80
- if b<3.0
81
- nihonshudo
82
- else
83
- b
84
- end
85
- end
86
- end
87
-
88
- def display_time(format="%m/%d %H:%M")
89
- if @time
90
- time.strftime(format)
91
- else
92
- Time.at(elapsed_time).strftime(format)
93
- end
94
- end
95
-
96
- def moromi_time
97
- tome = jobs[:tome]
98
- if tome
99
- time = elapsed_time - tome.elapsed_time
100
- if 0<time
101
- return time
102
- end
103
- end
104
- nil
105
- end
106
-
107
- def moromi_day
108
- moromi_t = moromi_time
109
- if moromi_t
110
- (moromi_t.to_f / Job::DAY).floor + 1
111
- end
112
- end
113
-
114
- def bmd
115
- _moromi_day = moromi_day
116
- _baume = baume
117
-
118
- if _moromi_day && _baume
119
- _moromi_day * _baume
120
- end
121
- end
122
-
123
- def expected_alcohol(target_alc, target_nihonshudo, coef)
124
- _baume = baume
125
-
126
- if _baume
127
- target_alc - (_baume - target_nihonshudo * -0.1) * coef
128
- end
129
- end
130
-
131
- def warmings
132
- result = []
133
- if @warming & WARM_DAKI
134
- result << :daki
135
- end
136
- if @warming & WARM_ANKA
137
- result << :anka
138
- end
139
- if @warming & WARM_MAT
140
- result << :mat
141
- end
142
- result
143
- end
144
-
145
- def to_h
146
- {
147
- time: time,
148
- elapsed_time: elapsed_time,
149
- display_time: display_time,
150
- id: id,
151
- preset_temp: preset_temp,
152
- temps: temps,
153
- room_temp: room_temp,
154
- room_psychrometry: room_psychrometry,
155
- baume: baume,
156
- nihonshudo: nihonshudo,
157
- acid: acid,
158
- amino_acid: amino_acid,
159
- alcohol: alcohol,
160
- warmings: warmings,
161
- moromi_day: moromi_day,
162
- bmd: bmd,
163
- note: note,
164
- }
165
- end
166
-
167
- def self.create(j)
168
- if Job===j
169
- j
170
- else
171
- new(**j.to_h)
172
- end
173
- end
174
- end
175
- end
176
- end
@@ -1,130 +0,0 @@
1
- module Toji
2
- module Product
3
- class Shubo < Base
4
-
5
- TEMPLATES = {
6
- default: [
7
- Job.new(
8
- elapsed_time: 0 * Job::DAY,
9
- id: :mizukoji,
10
- temps: 12.0,
11
- acid: 13.0,
12
- ),
13
- Job.new(
14
- elapsed_time: 0 * Job::DAY + 1 * Job::HOUR,
15
- id: :shikomi,
16
- temps: 20.0,
17
- acid: 13.0,
18
- ),
19
- Job.new(
20
- elapsed_time: 1 * Job::DAY,
21
- id: :utase,
22
- temps: 14.0,
23
- baume: 15.0,
24
- acid: 13.0,
25
- ),
26
- Job.new(
27
- elapsed_time: 2 * Job::DAY,
28
- temps: [8.0, 11.0],
29
- baume: 16.0,
30
- acid: 13.0,
31
- warming: Job::WARM_DAKI,
32
- ),
33
- Job.new(
34
- elapsed_time: 3 * Job::DAY,
35
- temps: [10.0, 13.0],
36
- baume: 16.5,
37
- acid: 13.5,
38
- warming: Job::WARM_DAKI,
39
- ),
40
- Job.new(
41
- elapsed_time: 4 * Job::DAY,
42
- temps: [12.0, 15.0],
43
- baume: 17.0,
44
- acid: 13.5,
45
- warming: Job::WARM_DAKI,
46
- ),
47
- Job.new(
48
- elapsed_time: 5 * Job::DAY,
49
- temps: 14.0,
50
- baume: 17.0,
51
- acid: 14.0,
52
- warming: Job::WARM_ANKA,
53
- ),
54
- Job.new(
55
- elapsed_time: 6 * Job::DAY,
56
- temps: 20.0,
57
- baume: 17.0,
58
- acid: 14.5,
59
- warming: Job::WARM_ANKA,
60
- ),
61
- Job.new(
62
- elapsed_time: 7 * Job::DAY,
63
- temps: 20.0,
64
- baume: 14.0,
65
- acid: 15.5,
66
- ),
67
- Job.new(
68
- elapsed_time: 8 * Job::DAY,
69
- temps: 20.0,
70
- baume: 12.0,
71
- acid: 16.0,
72
- ),
73
- Job.new(
74
- elapsed_time: 9 * Job::DAY,
75
- id: :wake,
76
- temps: 20.0,
77
- baume: 9.0,
78
- acid: 16.0,
79
- ),
80
- Job.new(
81
- elapsed_time: 10 * Job::DAY,
82
- temps: 15.0,
83
- baume: 8.0,
84
- acid: 16.5,
85
- ),
86
- Job.new(
87
- elapsed_time: 11 * Job::DAY,
88
- temps: 12.0,
89
- baume: 7.0,
90
- acid: 17.0,
91
- ),
92
- Job.new(
93
- elapsed_time: 12 * Job::DAY,
94
- temps: 10.0,
95
- baume: 6.0,
96
- acid: 17.5,
97
- ),
98
- Job.new(
99
- elapsed_time: 13 * Job::DAY,
100
- temps: 9.0,
101
- baume: 5.0,
102
- acid: 17.5,
103
- ),
104
- ],
105
- }
106
-
107
-
108
- job_reader :mizukoji
109
- job_reader :shikomi
110
- job_reader :utase
111
- job_reader :wake
112
-
113
- def initialize(jobs=[])
114
- super(jobs)
115
- end
116
-
117
- def day_labels
118
- days.times.map(&:succ)
119
- end
120
-
121
- def progress(enable_annotations: true)
122
- Graph::Progress.new(self, enable_annotations: enable_annotations)
123
- end
124
-
125
- def self.template(key=:default)
126
- new(TEMPLATES[key])
127
- end
128
- end
129
- end
130
- end
data/lib/toji/product.rb DELETED
@@ -1,11 +0,0 @@
1
- require 'toji/product/job'
2
- require 'toji/product/job_accessor'
3
- require 'toji/product/base'
4
- require 'toji/product/koji_making'
5
- require 'toji/product/shubo'
6
- require 'toji/product/moromi'
7
-
8
- module Toji
9
- module Product
10
- end
11
- end