toji 0.1.0 → 1.0.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.
@@ -1,142 +0,0 @@
1
- module Toji
2
- module Progress
3
- class Jobs
4
- include Enumerable
5
-
6
- attr_reader :day_offset
7
-
8
- def initialize(arr)
9
- @arr = []
10
- @hash = {}
11
- @day_offset = 0
12
-
13
- arr.each {|j|
14
- self << j
15
- }
16
- end
17
-
18
- def [](id)
19
- @hash[id]
20
- end
21
-
22
- def <<(job)
23
- if job.id
24
- if @hash[job.id]
25
- @arr.delete(@hash[job.id])
26
- end
27
- @hash[job.id] = job
28
- end
29
- @arr << job
30
- job.jobs = self
31
- normalization
32
- end
33
-
34
- def normalization
35
- min_time = @arr.select{|j| j.time}.map(&:time).sort.first
36
-
37
- if min_time
38
- @arr.each {|j|
39
- if j.time
40
- j.elapsed_time = (j.time - min_time).to_i
41
- else
42
- j.time = min_time + j.elapsed_time
43
- end
44
- }
45
- end
46
-
47
- @arr = @arr.sort{|a,b| a.elapsed_time<=>b.elapsed_time}
48
-
49
- t = @arr.first&.time
50
- if t
51
- @day_offset = t - Time.mktime(t.year, t.month, t.day)
52
- else
53
- @day_offset = 0
54
- end
55
- end
56
-
57
- def each(&block)
58
- normalization
59
- @arr.each(&block)
60
- end
61
-
62
- def plot_data(keys=nil)
63
- normalization
64
-
65
- data = map(&:to_h).map(&:compact)
66
- if !keys
67
- keys = data.map(&:keys).flatten.uniq
68
- end
69
-
70
- result = []
71
-
72
- if keys.include?(:temps)
73
- temps = data.map{|h| h[:temps]}
74
- if 0<temps.select{|a| a.present?}.size
75
- temps_x = []
76
- temps_y = []
77
- temps.each_with_index {|ts,i|
78
- ts.each_with_index {|t,j|
79
- temps_x << data[i][:elapsed_time] + j + day_offset
80
- temps_y << t
81
- }
82
- }
83
- result << {x: temps_x, y: temps_y, name: :temps}
84
- end
85
- end
86
-
87
- keys &= [:preset_temp, :room_temp, :room_psychrometry, :baume, :acid, :amino_acid, :alcohol]
88
-
89
- keys.each {|key|
90
- xs = []
91
- ys = []
92
- data.each {|h|
93
- if h[key]
94
- ys << h[key]
95
- xs << h[:elapsed_time] + day_offset
96
- end
97
- }
98
-
99
- line_shape = :linear
100
- if key==:preset_temp
101
- line_shape = :hv
102
- end
103
-
104
- result << {x: xs, y: ys, name: key, line: {shape: line_shape}}
105
- }
106
-
107
- if 0<day_offset
108
- result = result.map{|h|
109
- h[:x].unshift(0)
110
- h[:y].unshift(nil)
111
- h
112
- }
113
- end
114
-
115
- result
116
- end
117
-
118
- def bmd_plot_data
119
- normalization
120
-
121
- data = map{|j| [j.time || j.elapsed_time + day_offset, j.moromi_time, j.moromi_day, j.baume, j.bmd]}.select{|a| a[1] && a[4]}
122
- xs = data.map{|a| a[1]}
123
- ys = data.map{|a| a[4]}
124
- texts = data.map{|a| "%s<br />moromi day=%d, be=%s, bmd=%s" % [a[0], a[2], a[3], a[4]]}
125
-
126
- {x: xs, y: ys, text: texts, name: :bmd}
127
- end
128
-
129
- def ab_plot_data
130
- normalization
131
-
132
- result = []
133
-
134
- data = map{|j| [j.time || j.elapsed_time + day_offset, j.alcohol, j.baume]}.select{|a| a[1] && a[2]}
135
- xs = data.map{|a| a[1]}
136
- ys = data.map{|a| a[2]}
137
- texts = data.map{|a| "%s<br />alc=%s, be=%s" % a}
138
- {x: xs, y: ys, text: texts, name: :actual}
139
- end
140
- end
141
- end
142
- end
data/lib/toji/progress.rb DELETED
@@ -1,11 +0,0 @@
1
- require 'toji/progress/job'
2
- require 'toji/progress/jobs'
3
- require 'toji/progress/job_accessor'
4
- require 'toji/progress/make_koji'
5
- require 'toji/progress/shubo'
6
- require 'toji/progress/moromi'
7
-
8
- module Toji
9
- module Progress
10
- end
11
- end