deploy_pin 1.3.8 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e3d6aa336c010d58ff4462cc64038351fa67432faf2f4dd3e094b12d3c912c9e
4
- data.tar.gz: a9e8d29ac5e8db0c207f2e40a59f6d77013c98efbf7e9cb38c5b1e1b6840f577
3
+ metadata.gz: 2862b9b718d5a1ce6d6b6af0c10846f1915d7c0a70f13e68c96b2f69d1304bcc
4
+ data.tar.gz: c849c787465e4022faf6f10674ce53c7e67c71b68f1a2921de3f3e71ae64f8ac
5
5
  SHA512:
6
- metadata.gz: bf2efc8fd1cc48f8e1bf5568bb11544d6a20510e7bbfa2ae81f63f831da6776945b6dc22e5d9befa444c77d042b3d6a9a87bb9b40f246c4a54e9801fd960069a
7
- data.tar.gz: 1527b98cccfec97dad84286cea3063c9a76a051f9286a8be01181bb1bd1c6032e94693b57ed1f3cfea7b1286a2849d5fa2e36a0d8e7a1fe90f41dba946212c63
6
+ metadata.gz: a6bfd839077a2ca9ccdc75232fb376707ac87475bc6504f365991d01fdd4da81c15617605cc746fb8b1ada5a6dc3da8465b2382b9811f108accbc9a45080e6ff
7
+ data.tar.gz: f7ef8afae96a3ab5802a5f91de36248637c8eb003a7cbfdb168006373e65c5669360f9cf618f51daff082d41efe34b6ce2c0172cca7e8570717c793a8bc05542
@@ -9,28 +9,15 @@ module DeployPin
9
9
  @identifiers = identifiers
10
10
  end
11
11
 
12
+ # :reek:TooManyStatements
12
13
  def run
13
14
  # cache tasks
14
15
  _tasks = tasks
15
16
  _tasks.each_with_index do |task, index|
16
- # run only uniq tasks
17
- executable = _tasks[0..index].none? { |_task| task.eql?(_task) }
18
-
19
- DeployPin.run_formatter.call(index, _tasks.count, task, executable, true)
20
-
21
- # run if executable
22
- if executable
23
- duration = execution_duration do
24
- run_with_timeout(task) { task.run }
25
- end
26
-
27
- DeployPin.run_formatter.call(index, _tasks.count, task, executable, false, duration)
28
- end
29
-
30
- # mark each task as done
31
- task.mark unless task.done?
17
+ DeployPin.task_wrapper.call(task, -> { process(_tasks, task, index) })
32
18
  end
33
19
  end
20
+ # :reek:TooManyStatements
34
21
 
35
22
  def list
36
23
  _tasks = tasks
@@ -53,6 +40,26 @@ module DeployPin
53
40
 
54
41
  private
55
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
+
56
63
  # :reek:UtilityFunction
57
64
  def files
58
65
  Dir["#{DeployPin.tasks_path}/*.rb"]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeployPin
4
- VERSION = '1.3.8'
4
+ VERSION = '1.4.0'
5
5
  end
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 @@#{option} unless val.present?
28
+ return @#{option} unless val.present?
28
29
 
29
- @@#{option} = val
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
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.3.8
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-03-23 00:00:00.000000000 Z
11
+ date: 2023-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize