deploy_pin 1.3.7 → 1.4.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.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/deploy_pin/collector.rb +25 -20
- data/lib/deploy_pin/version.rb +1 -1
- data/lib/deploy_pin.rb +9 -2
- data/lib/generators/deploy_pin/install/templates/deploy_pin.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2862b9b718d5a1ce6d6b6af0c10846f1915d7c0a70f13e68c96b2f69d1304bcc
|
4
|
+
data.tar.gz: c849c787465e4022faf6f10674ce53c7e67c71b68f1a2921de3f3e71ae64f8ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6bfd839077a2ca9ccdc75232fb376707ac87475bc6504f365991d01fdd4da81c15617605cc746fb8b1ada5a6dc3da8465b2382b9811f108accbc9a45080e6ff
|
7
|
+
data.tar.gz: f7ef8afae96a3ab5802a5f91de36248637c8eb003a7cbfdb168006373e65c5669360f9cf618f51daff082d41efe34b6ce2c0172cca7e8570717c793a8bc05542
|
data/README.md
CHANGED
@@ -143,7 +143,7 @@ end
|
|
143
143
|
Check the documentation [here](lib/deploy_pin/parallel_wrapper.rb).
|
144
144
|
|
145
145
|
## Formatting
|
146
|
-
`run_formatter` is used to format the output of a `run` task
|
146
|
+
`run_formatter` is used to format the output of a `run` task
|
147
147
|
`list_formatter` is used to format the output of a `list` task
|
148
148
|
|
149
149
|
A default value must be defined in the deploy_pin initializer. Ex.:
|
@@ -151,9 +151,9 @@ A default value must be defined in the deploy_pin initializer. Ex.:
|
|
151
151
|
# config/initializers/deploy_pin.rb
|
152
152
|
DeployPin.setup do
|
153
153
|
run_formatter(
|
154
|
-
lambda do |index, task_count, task, executable, start,
|
154
|
+
lambda do |index, task_count, task, executable, start, duration = nil|
|
155
155
|
end_of_msg = if executable
|
156
|
-
start ? '(Started)' : "(Done in #{
|
156
|
+
start ? '(Started)' : "(Done in #{duration})\n\n"
|
157
157
|
else
|
158
158
|
"(Skipped)\n\n"
|
159
159
|
end
|
data/lib/deploy_pin/collector.rb
CHANGED
@@ -3,36 +3,21 @@
|
|
3
3
|
# executes tasks
|
4
4
|
module DeployPin
|
5
5
|
class Collector
|
6
|
-
include ActionView::Helpers::DateHelper
|
7
|
-
|
8
6
|
attr_reader :identifiers, :formatter
|
9
7
|
|
10
8
|
def initialize(identifiers:)
|
11
9
|
@identifiers = identifiers
|
12
10
|
end
|
13
11
|
|
12
|
+
# :reek:TooManyStatements
|
14
13
|
def run
|
15
14
|
# cache tasks
|
16
15
|
_tasks = tasks
|
17
16
|
_tasks.each_with_index do |task, index|
|
18
|
-
|
19
|
-
executable = _tasks[0..index].none? { |_task| task.eql?(_task) }
|
20
|
-
|
21
|
-
DeployPin.run_formatter.call(index, _tasks.count, task, executable, true)
|
22
|
-
|
23
|
-
# run if executable
|
24
|
-
if executable
|
25
|
-
time = execution_time do
|
26
|
-
run_with_timeout(task) { task.run }
|
27
|
-
end
|
28
|
-
|
29
|
-
DeployPin.run_formatter.call(index, _tasks.count, task, executable, false, time)
|
30
|
-
end
|
31
|
-
|
32
|
-
# mark each task as done
|
33
|
-
task.mark unless task.done?
|
17
|
+
DeployPin.task_wrapper.call(task, -> { process(_tasks, task, index) })
|
34
18
|
end
|
35
19
|
end
|
20
|
+
# :reek:TooManyStatements
|
36
21
|
|
37
22
|
def list
|
38
23
|
_tasks = tasks
|
@@ -55,6 +40,26 @@ module DeployPin
|
|
55
40
|
|
56
41
|
private
|
57
42
|
|
43
|
+
# :reek:FeatureEnvy
|
44
|
+
# :reek:TooManyStatements
|
45
|
+
def process(cached_tasks, task, index)
|
46
|
+
# run only uniq tasks
|
47
|
+
executable = cached_tasks[0..index].none? { |_task| task.eql?(_task) }
|
48
|
+
|
49
|
+
DeployPin.run_formatter.call(index, cached_tasks.count, task, executable, true)
|
50
|
+
|
51
|
+
# run if executable
|
52
|
+
if executable
|
53
|
+
duration = execution_duration { run_with_timeout(task) { task.run } }
|
54
|
+
DeployPin.run_formatter.call(index, cached_tasks.count, task, executable, false, duration)
|
55
|
+
end
|
56
|
+
|
57
|
+
# mark each task as done
|
58
|
+
task.mark unless task.done?
|
59
|
+
end
|
60
|
+
# :reek:TooManyStatements
|
61
|
+
# :reek:FeatureEnvy
|
62
|
+
|
58
63
|
# :reek:UtilityFunction
|
59
64
|
def files
|
60
65
|
Dir["#{DeployPin.tasks_path}/*.rb"]
|
@@ -81,12 +86,12 @@ module DeployPin
|
|
81
86
|
DeployPin::Database.execute_with_timeout(DeployPin.statement_timeout, **{}, &block)
|
82
87
|
end
|
83
88
|
|
84
|
-
def
|
89
|
+
def execution_duration
|
85
90
|
start_time = Time.now
|
86
91
|
|
87
92
|
yield
|
88
93
|
|
89
|
-
|
94
|
+
Time.now - start_time
|
90
95
|
end
|
91
96
|
end
|
92
97
|
end
|
data/lib/deploy_pin/version.rb
CHANGED
data/lib/deploy_pin.rb
CHANGED
@@ -19,14 +19,15 @@ module DeployPin
|
|
19
19
|
statement_timeout
|
20
20
|
run_formatter
|
21
21
|
list_formatter
|
22
|
+
task_wrapper
|
22
23
|
].freeze
|
23
24
|
|
24
25
|
OPTIONS.each do |option|
|
25
26
|
instance_eval %{
|
26
27
|
def #{option}(val = nil)
|
27
|
-
return
|
28
|
+
return @#{option} unless val.present?
|
28
29
|
|
29
|
-
|
30
|
+
@#{option} = val
|
30
31
|
end
|
31
32
|
}, __FILE__, __LINE__ - 6
|
32
33
|
end
|
@@ -34,4 +35,10 @@ module DeployPin
|
|
34
35
|
def self.setup(&block)
|
35
36
|
instance_eval(&block)
|
36
37
|
end
|
38
|
+
|
39
|
+
def self.setup_defaults!
|
40
|
+
@task_wrapper = ->(_task, task_runner) { task_runner.call }
|
41
|
+
end
|
42
|
+
|
43
|
+
setup_defaults!
|
37
44
|
end
|
@@ -6,9 +6,9 @@ DeployPin.setup do
|
|
6
6
|
fallback_group 'II'
|
7
7
|
statement_timeout 10.minutes
|
8
8
|
run_formatter(
|
9
|
-
lambda do |index, task_count, task, executable, start,
|
9
|
+
lambda do |index, task_count, task, executable, start, duration = nil|
|
10
10
|
end_of_msg = if executable
|
11
|
-
start ? '(Started)' : "(Done in #{
|
11
|
+
start ? '(Started)' : "(Done in #{duration})\n\n"
|
12
12
|
else
|
13
13
|
"(Skipped)\n\n"
|
14
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deploy_pin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Viktor Sych
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|