rukawa 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rukawa/abstract_job.rb +6 -5
- data/lib/rukawa/dag.rb +28 -0
- data/lib/rukawa/job_net.rb +1 -1
- data/lib/rukawa/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3708a96687aab4647f068cda298ad49619ae352d
|
4
|
+
data.tar.gz: 27ac524cfb1eeb05a479e93e6f433a17a6498842
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad83b7c946d04cccfee6e16b3ac6b30d7421e361ece92287d0de503f380d1c9bda1e88b087f750b8cb994f0aca007e113008d028110f2ef959073277ef0fcd7a
|
7
|
+
data.tar.gz: 51aae209a567c73ce9fa031e91423c37facd25f93829d1c08a1467b73561d238a4fbbe9f56f3d85718d1586d57309d3ab5cac0cc2dfcba0afad0faef56a2f087
|
data/lib/rukawa/abstract_job.rb
CHANGED
@@ -42,15 +42,16 @@ module Rukawa
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def formatted_elapsed_time_from(time = Time.now)
|
45
|
-
|
46
|
-
return "N/A" unless
|
45
|
+
elapsed = elapsed_time_from(time)
|
46
|
+
return "N/A" unless elapsed
|
47
47
|
|
48
|
-
hour =
|
49
|
-
min =
|
48
|
+
hour = elapsed.to_i / 3600
|
49
|
+
min = elapsed.to_i / 60
|
50
|
+
sec = (elapsed - hour * 3600 - min * 60).to_i
|
50
51
|
|
51
52
|
hour_format = min > 0 ? "%dh " % hour : ""
|
52
53
|
min_format = min > 0 ? "%dm " % min : ""
|
53
|
-
sec_format = "#{sec
|
54
|
+
sec_format = "#{sec}s"
|
54
55
|
"#{hour_format}#{min_format}#{sec_format}"
|
55
56
|
end
|
56
57
|
end
|
data/lib/rukawa/dag.rb
CHANGED
@@ -11,6 +11,7 @@ module Rukawa
|
|
11
11
|
def initialize
|
12
12
|
@nodes = Set.new
|
13
13
|
@jobs = Set.new
|
14
|
+
@start_jobs = Set.new
|
14
15
|
@edges = Set.new
|
15
16
|
end
|
16
17
|
|
@@ -21,6 +22,7 @@ module Rukawa
|
|
21
22
|
job = job_class.new(job_net)
|
22
23
|
@nodes << job
|
23
24
|
@jobs << job if job.is_a?(Job)
|
25
|
+
@start_jobs << job if job.is_a?(Job) && dependencies[job_class].empty?
|
24
26
|
|
25
27
|
dependencies[job_class].each do |depend_job_class|
|
26
28
|
depend_job = @nodes.find { |j| j.instance_of?(depend_job_class) }
|
@@ -67,6 +69,32 @@ module Rukawa
|
|
67
69
|
end
|
68
70
|
end
|
69
71
|
|
72
|
+
def leveled_each
|
73
|
+
visited = Set.new
|
74
|
+
queue = []
|
75
|
+
queue.push(*@start_jobs)
|
76
|
+
|
77
|
+
if block_given?
|
78
|
+
until queue.empty?
|
79
|
+
next_job = queue.shift
|
80
|
+
yield next_job unless visited.include?(next_job)
|
81
|
+
queue.push(*next_job.out_goings.map(&:to)) if visited.add?(next_job)
|
82
|
+
end
|
83
|
+
else
|
84
|
+
Enumerator.new do |y|
|
85
|
+
until queue.empty?
|
86
|
+
next_job = queue.shift
|
87
|
+
y << next_job unless visited.include?(next_job)
|
88
|
+
queue.push(*next_job.out_goings.map(&:to)) if visited.add?(next_job)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def start_jobs
|
95
|
+
@start_jobs
|
96
|
+
end
|
97
|
+
|
70
98
|
private
|
71
99
|
|
72
100
|
def tsortable_hash(hash)
|
data/lib/rukawa/job_net.rb
CHANGED
data/lib/rukawa/version.rb
CHANGED