toji 1.6.8 → 2.3.0

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.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/example/calendar.ipynb +383 -0
  3. data/example/{schedule.yaml → calendar.yaml} +6 -30
  4. data/example/calendar_file.ipynb +338 -0
  5. data/example/example_core.rb +354 -0
  6. data/example/kake_ingredient.rb +26 -0
  7. data/example/{koji_recipe.rb → koji_ingredient.rb} +1 -2
  8. data/example/koji_making.ipynb +16 -15
  9. data/example/koji_making.rb +2 -1
  10. data/example/koji_making.yaml +10 -9
  11. data/example/koji_making_multi.ipynb +27 -61
  12. data/example/moromi.ipynb +25 -24
  13. data/example/moromi.rb +1 -0
  14. data/example/moromi.yaml +10 -4
  15. data/example/recipe.rb +75 -0
  16. data/example/shubo.ipynb +15 -14
  17. data/example/shubo.rb +2 -1
  18. data/example/shubo.yaml +12 -11
  19. data/lib/toji.rb +3 -1
  20. data/lib/toji/brew.rb +4 -3
  21. data/lib/toji/brew/base.rb +8 -92
  22. data/lib/toji/brew/builder.rb +77 -6
  23. data/lib/toji/brew/graph/bmd.rb +1 -2
  24. data/lib/toji/brew/graph/multi_progress.rb +0 -121
  25. data/lib/toji/brew/graph/progress.rb +17 -52
  26. data/lib/toji/brew/koji.rb +2 -11
  27. data/lib/toji/brew/moromi.rb +4 -37
  28. data/lib/toji/brew/shubo.rb +2 -6
  29. data/lib/toji/brew/state.rb +90 -103
  30. data/lib/toji/brew/wrapped_state.rb +136 -0
  31. data/lib/toji/calendar.rb +123 -0
  32. data/lib/toji/{schedule → calendar}/date_column.rb +3 -6
  33. data/lib/toji/{schedule → calendar}/date_row.rb +6 -6
  34. data/lib/toji/ingredient.rb +10 -0
  35. data/lib/toji/ingredient/kake.rb +17 -0
  36. data/lib/toji/ingredient/kake/actual.rb +26 -0
  37. data/lib/toji/ingredient/kake/base.rb +18 -0
  38. data/lib/toji/ingredient/kake/expected.rb +40 -0
  39. data/lib/toji/ingredient/koji.rb +19 -0
  40. data/lib/toji/ingredient/koji/actual.rb +29 -0
  41. data/lib/toji/ingredient/koji/actual_fermentable.rb +15 -0
  42. data/lib/toji/ingredient/koji/base.rb +35 -0
  43. data/lib/toji/ingredient/koji/expected.rb +45 -0
  44. data/lib/toji/ingredient/koji/expected_fermentable.rb +15 -0
  45. data/lib/toji/{recipe → ingredient}/koji_rate.rb +1 -1
  46. data/lib/toji/ingredient/rice.rb +10 -0
  47. data/lib/toji/ingredient/rice/actual_steamable.rb +27 -0
  48. data/lib/toji/ingredient/rice/base.rb +40 -0
  49. data/lib/toji/ingredient/rice/expected_steamable.rb +27 -0
  50. data/lib/toji/ingredient/rice_rate.rb +23 -0
  51. data/lib/toji/product.rb +65 -0
  52. data/lib/toji/{schedule/product_event.rb → product/event.rb} +4 -4
  53. data/lib/toji/recipe.rb +111 -5
  54. data/lib/toji/recipe/step.rb +49 -64
  55. data/lib/toji/version.rb +1 -1
  56. metadata +33 -39
  57. data/example/rice_recipe.rb +0 -28
  58. data/example/schedule.ipynb +0 -393
  59. data/example/schedule_file.ipynb +0 -337
  60. data/example/three_step_mashing_recipe.rb +0 -67
  61. data/lib/toji/brew/state_accessor.rb +0 -13
  62. data/lib/toji/brew/state_record.rb +0 -72
  63. data/lib/toji/recipe/ingredient.rb +0 -10
  64. data/lib/toji/recipe/ingredient/koji.rb +0 -21
  65. data/lib/toji/recipe/ingredient/koji/actual.rb +0 -32
  66. data/lib/toji/recipe/ingredient/koji/actual_fermentable.rb +0 -17
  67. data/lib/toji/recipe/ingredient/koji/base.rb +0 -37
  68. data/lib/toji/recipe/ingredient/koji/expected.rb +0 -48
  69. data/lib/toji/recipe/ingredient/koji/expected_fermentable.rb +0 -17
  70. data/lib/toji/recipe/ingredient/rice.rb +0 -21
  71. data/lib/toji/recipe/ingredient/rice/actual.rb +0 -29
  72. data/lib/toji/recipe/ingredient/rice/actual_steamable.rb +0 -29
  73. data/lib/toji/recipe/ingredient/rice/base.rb +0 -51
  74. data/lib/toji/recipe/ingredient/rice/expected.rb +0 -43
  75. data/lib/toji/recipe/ingredient/rice/expected_steamable.rb +0 -31
  76. data/lib/toji/recipe/ingredient/yeast.rb +0 -21
  77. data/lib/toji/recipe/rice_rate.rb +0 -10
  78. data/lib/toji/recipe/rice_rate/base.rb +0 -21
  79. data/lib/toji/recipe/rice_rate/cooked.rb +0 -67
  80. data/lib/toji/recipe/rice_rate/steamed.rb +0 -30
  81. data/lib/toji/recipe/three_step_mashing.rb +0 -274
  82. data/lib/toji/recipe/yeast_rate.rb +0 -41
  83. data/lib/toji/schedule.rb +0 -11
  84. data/lib/toji/schedule/calendar.rb +0 -139
  85. data/lib/toji/schedule/date_interval_enumerator.rb +0 -45
  86. data/lib/toji/schedule/product.rb +0 -117
@@ -1,45 +0,0 @@
1
- module Toji
2
- module Schedule
3
- class DateIntervalEnumerator
4
- include Enumerable
5
-
6
- def initialize(intervals, afterwards)
7
- @intervals = intervals
8
- @afterwards = afterwards
9
- end
10
-
11
- def each(&block)
12
- Enumerator.new do |y|
13
- y << 0
14
- @intervals.each {|interval|
15
- y << interval
16
- }
17
- loop {
18
- y << @afterwards
19
- }
20
- end.each(&block)
21
- end
22
-
23
- def merge(dates, length)
24
- dates = [dates].flatten
25
- enum = each
26
-
27
- length.times {|i|
28
- add = enum.next
29
-
30
- if i==0
31
- dates[i] = dates[i].to_time
32
- elsif Integer===dates[i] && dates[i-1]
33
- dates[i] = dates[i-1].since(dates[i].days)
34
- elsif !dates[i] && dates[i-1]
35
- dates[i] = dates[i-1].since(add.days)
36
- else
37
- dates[i] = dates[i].to_time
38
- end
39
- }
40
-
41
- dates
42
- end
43
- end
44
- end
45
- end
@@ -1,117 +0,0 @@
1
- module Toji
2
- module Schedule
3
- class Product
4
- attr_reader :id
5
- attr_reader :name
6
- attr_reader :description
7
- attr_reader :recipe
8
-
9
- attr_reader :koji_dates
10
- attr_reader :rice_dates
11
-
12
- attr_reader :color
13
-
14
- def initialize(id, name, description, recipe, koji_dates, rice_dates, color=nil)
15
- @id = id
16
- @name = name
17
- @description = description
18
- @recipe = recipe
19
-
20
- @koji_dates = DateIntervalEnumerator.new([], 0).merge(koji_dates, recipe.steps.length)
21
- @rice_dates = DateIntervalEnumerator.new([recipe.moto_days, recipe.odori_days+1, 1], 1).merge(rice_dates, recipe.steps.length)
22
-
23
- @color = color
24
- end
25
-
26
- def events
27
- events = []
28
-
29
- @koji_dates.length.times {|i|
30
- events << ProductEvent.new(self, :koji, i)
31
- }
32
-
33
- @rice_dates.length
34
- .times.map {|i|
35
- ProductEvent.new(self, :rice, i)
36
- }
37
- .delete_if {|e|
38
- 4<=e.index && e.weight==0
39
- }
40
- .each {|e|
41
- events << e
42
- }
43
-
44
- events
45
- end
46
-
47
- def events_group
48
- events.group_by{|event|
49
- event.group_key
50
- }.map {|group_key,events|
51
- breakdown = events.map {|event|
52
- {index: event.index, weight: event.weight}
53
- }
54
- if 1<breakdown.length
55
- breakdown = breakdown.select{|event| 0<event[:weight]}
56
- end
57
-
58
- {
59
- date: events.first.date,
60
- type: events.first.type,
61
- weight: events.map(&:weight).sum,
62
- breakdown: breakdown,
63
- }
64
- }
65
- end
66
-
67
- def to_h
68
- {
69
- id: @id,
70
- name: @name,
71
- description: @description,
72
- recipe: @recipe.table_data,
73
- koji_dates: @koji_dates,
74
- rice_dates: @rice_dates,
75
- events: events.map(&:to_h),
76
- events_group: events_group,
77
- color: @color,
78
- }
79
- end
80
-
81
- def self.create(args)
82
- if self===args
83
- args
84
- elsif Hash===args
85
- recipe = args.fetch(:recipe)
86
- if Symbol===recipe
87
- recipe = Recipe::ThreeStepMashing::TEMPLATES.fetch(recipe)
88
- end
89
- if args[:scale]
90
- recipe = recipe.scale(args[:scale])
91
- end
92
- if args[:round]
93
- recipe = recipe.round(args[:round])
94
- end
95
- if args[:moto_days]
96
- recipe.moto_days = args[:moto_days]
97
- end
98
- if args[:odori_days]
99
- recipe.odori_days = args[:odori_days]
100
- end
101
-
102
- new(
103
- args[:id],
104
- args[:name],
105
- args[:description],
106
- recipe,
107
- args[:koji_dates],
108
- args[:rice_dates],
109
- args[:color]
110
- )
111
- else
112
- raise "not supported class: #{args.class}"
113
- end
114
- end
115
- end
116
- end
117
- end