deploy_pin 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/deploy_pin/engine.rb +4 -2
- data/lib/deploy_pin/runner.rb +32 -30
- data/lib/deploy_pin/task.rb +31 -29
- data/lib/deploy_pin/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f5e269526d154387064c2c9fd9d1014bbbfda16535fd01c572eab890f58fe2a
|
4
|
+
data.tar.gz: d891eead06e94bdea1cb5033e99f290a12219402fa8f3eaea4cfbc6d971b937c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58d60a88a350239da715e3e7d3182afbadbd43c4c6da92c4e44dbe26c34541b68df0abcc908a04a07108ea92d3bb7fea4a0092803db490bff4a83bad8bd903e4
|
7
|
+
data.tar.gz: 56435db402d2cd35b67332021bf9ee6c444a1461e394eaf4eb1ee18a2423088d28f02ba1bdbeb1c50dd32dea49e2bdda993b1131a43b5ff40f9077fa4b017e81
|
data/lib/deploy_pin/engine.rb
CHANGED
data/lib/deploy_pin/runner.rb
CHANGED
@@ -1,44 +1,46 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# executes tasks
|
4
|
-
module DeployPin
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
module DeployPin
|
5
|
+
module Runner
|
6
|
+
def self.run(groups:)
|
7
|
+
tasks = pending(groups: groups)
|
8
|
+
tasks.each_with_index do |task, index|
|
9
|
+
puts "[#{index + 1}/#{tasks.count}] Task UUID #{task.uuid}"
|
10
|
+
task.run
|
11
|
+
puts ""
|
12
|
+
end
|
11
13
|
end
|
12
|
-
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
def self.list(groups:)
|
16
|
+
pending(groups: groups).each_with_index do |task, index|
|
17
|
+
puts "======= Task ##{index} ========"
|
18
|
+
puts task.script
|
19
|
+
puts ""
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
puts "======= summary ========"
|
23
|
+
puts "tasks number: #{pending(groups: groups).count}"
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
def self.pending(groups:)
|
27
|
+
files = Dir["#{DeployPin.tasks_path}/*.rb"]
|
27
28
|
|
28
|
-
|
29
|
-
|
29
|
+
# get done records uuids
|
30
|
+
records = DeployPin::Record.pluck(:uuid)
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
files.map do |file|
|
33
|
+
task = DeployPin::Task.new(file)
|
34
|
+
task.parse_file
|
34
35
|
|
35
|
-
|
36
|
-
|
36
|
+
# task is done
|
37
|
+
next if records.include?(task.uuid)
|
37
38
|
|
38
|
-
|
39
|
-
|
39
|
+
# group mismatch
|
40
|
+
next unless groups.include?(task.group)
|
40
41
|
|
41
|
-
|
42
|
-
|
42
|
+
task
|
43
|
+
end.compact.sort # sort by group position in config
|
44
|
+
end
|
43
45
|
end
|
44
46
|
end
|
data/lib/deploy_pin/task.rb
CHANGED
@@ -1,40 +1,42 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Task wrapper
|
4
|
-
|
5
|
-
|
6
|
-
:
|
7
|
-
|
8
|
-
|
4
|
+
module DeployPin
|
5
|
+
class Task
|
6
|
+
attr_reader :file,
|
7
|
+
:group,
|
8
|
+
:uuid,
|
9
|
+
:script
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
def initialize(file)
|
12
|
+
@file = file
|
13
|
+
@uuid = nil
|
14
|
+
@group = nil
|
15
|
+
@script = ""
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
def run
|
19
|
+
eval(@script)
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
def parse_file
|
23
|
+
@script = File.read(file)
|
24
|
+
@script.lines[0] =~ /\A# (\d+):(\w+)/
|
25
|
+
@uuid = $1
|
26
|
+
@group = $2
|
27
|
+
end
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
def details
|
30
|
+
puts @uuid, @group, @script
|
31
|
+
end
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
# for sorting
|
34
|
+
def <=>(task_b)
|
35
|
+
group_index <=> task_b.group_index
|
36
|
+
end
|
36
37
|
|
37
|
-
|
38
|
-
|
38
|
+
def group_index
|
39
|
+
DeployPin.groups.index(group)
|
40
|
+
end
|
39
41
|
end
|
40
42
|
end
|
data/lib/deploy_pin/version.rb
CHANGED