deplomat 0.2.13 → 0.2.18

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: 06ea7373755469a175c961d68e8968cbcb183d44a938b50da8f87314a3032318
4
- data.tar.gz: 6947ac82c80f4f4bc702a21c9d5aa76ba6e03f243376619d266e8771519a74b8
3
+ metadata.gz: 5be39a71be9b135b2a5bd233ce808833deb860517af15ae03bb6723c13fd5e35
4
+ data.tar.gz: 95e328842dce669a4a8845d562eaa2cb8b8fb2e4cdda52f5c7fd5a818a99c235
5
5
  SHA512:
6
- metadata.gz: 757c22b3acfcca212194f2f7d7b2fd0b4f52751d328d88d995517acd85be43404319e8b735fd16dffcf433c2faebeaaf0e1ad41b5247f90a5ded36dd5163880e
7
- data.tar.gz: 077f00f699e37215daaf96dba5fd2a1c7666697d0f3e9448cf96d095295817d74e54bc050cb1217c73f890d4c6c01029ccc2fdebe208e9db8188514d45549832
6
+ metadata.gz: deb7c22ca7382f2376d3f0fbec59f6527514f631d4d6cf685551e2ac2f1dde028faf9949972bf302b444eed2d93f24ce070e6080fed5fd1228e19830da2c574c
7
+ data.tar.gz: 45f7bac07247125eb476a8b1355e869882c4822b4e8fcaf4ed6097689f0f9766e7e39024d3ec7c000757d4d63fc45853036ee10ec0efb55b25eb64b4dc594001
data/Gemfile CHANGED
@@ -1,9 +1,3 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "sys-proctable"
4
- gem "colorize"
5
-
6
- group :development do
7
- gem "bundler", "~> 2.0"
8
- gem "rspec"
9
- end
3
+ gemspec
@@ -1,9 +1,16 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ deplomat (0.2.18)
5
+ colorize
6
+ sys-proctable
7
+
1
8
  GEM
2
9
  remote: http://rubygems.org/
3
10
  specs:
4
11
  colorize (0.8.1)
5
12
  diff-lcs (1.3)
6
- ffi (1.11.1)
13
+ ffi (1.14.1)
7
14
  rspec (3.8.0)
8
15
  rspec-core (~> 3.8.0)
9
16
  rspec-expectations (~> 3.8.0)
@@ -17,7 +24,7 @@ GEM
17
24
  diff-lcs (>= 1.2.0, < 2.0)
18
25
  rspec-support (~> 3.8.0)
19
26
  rspec-support (3.8.2)
20
- sys-proctable (1.2.1)
27
+ sys-proctable (1.2.6)
21
28
  ffi
22
29
 
23
30
  PLATFORMS
@@ -25,9 +32,8 @@ PLATFORMS
25
32
 
26
33
  DEPENDENCIES
27
34
  bundler (~> 2.0)
28
- colorize
35
+ deplomat!
29
36
  rspec
30
- sys-proctable
31
37
 
32
38
  BUNDLED WITH
33
- 2.0.2
39
+ 2.1.4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.13
1
+ 0.2.18
@@ -16,4 +16,10 @@ Gem::Specification.new do |spec|
16
16
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
17
  end
18
18
  spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "colorize"
21
+ spec.add_dependency "sys-proctable"
22
+
23
+ spec.add_development_dependency "bundler", "~> 2.0"
24
+ spec.add_development_dependency "rspec"
19
25
  end
@@ -1,6 +1,7 @@
1
1
  $partials = {}
2
2
  $deplomat_tasks = []
3
3
  $deplomat_tasks_callbacks = {}
4
+ $log_tasks_status = true
4
5
 
5
6
  def execute_in(env:)
6
7
  yield if $env == env
@@ -26,26 +27,39 @@ def print_to_terminal(message, color: nil, newline: true)
26
27
  $stdout.print message
27
28
  end
28
29
 
30
+ def print_task_status(name, status)
31
+ print_to_terminal("\n--- #{name} task #{status.upcase}", color: :light_blue, newline: true)
32
+ end
33
+
29
34
  # This wrapper allows us to insert external before/after
30
35
  # tasks into every method executed by deplomat.
31
36
  # Very useful for the one-time-tasks implementation.
32
37
  def add_task(*tasks)
38
+ tasks.each do |t|
39
+ init_task_callbacks(t)
40
+ $deplomat_tasks_callbacks[t][:before] << lambda { print_task_status(t, "started") }
41
+ $deplomat_tasks_callbacks[t][:after] << lambda { print_task_status(t, "finished") }
42
+ end if $log_tasks_status
33
43
  $deplomat_tasks += tasks
34
44
  end
35
45
  alias :add_tasks :add_task
36
46
 
37
47
  def before_task(task_name, requisite_number, &block)
38
- $deplomat_tasks_callbacks[task_name] ||= {}
39
- $deplomat_tasks_callbacks[task_name][:before] ||= []
48
+ init_task_callbacks(task_name)
40
49
  $deplomat_tasks_callbacks[task_name][:before] << lambda { block.call; update_requisite_number!(requisite_number) }
41
50
  end
42
51
 
43
52
  def after_task(task_name, requisite_number, &block)
44
- $deplomat_tasks_callbacks[task_name] ||= {}
45
- $deplomat_tasks_callbacks[task_name][:after] ||= []
53
+ init_task_callbacks(task_name)
46
54
  $deplomat_tasks_callbacks[task_name][:after] << lambda { block.call; update_requisite_number!(requisite_number) }
47
55
  end
48
56
 
57
+ def init_task_callbacks(task_name)
58
+ $deplomat_tasks_callbacks[task_name] ||= {}
59
+ $deplomat_tasks_callbacks[task_name][:before] ||= []
60
+ $deplomat_tasks_callbacks[task_name][:after] ||= []
61
+ end
62
+
49
63
  def execute_tasks!
50
64
  $deplomat_tasks.each do |t|
51
65
  $deplomat_tasks_callbacks[t][:before].each { |block| block.call } if $deplomat_tasks_callbacks[t] && $deplomat_tasks_callbacks[t][:before]
@@ -2,8 +2,7 @@ module Deplomat
2
2
 
3
3
  class Node
4
4
 
5
- attr_accessor :log_to, :raise_exceptions, :logfile, :wrap_in
6
- attr_reader :current_path
5
+ attr_accessor :log_to, :raise_exceptions, :logfile, :wrap_in, :current_path
7
6
  attr_writer :stdout_lines_to_ignore
8
7
 
9
8
  def stdout_lines_to_ignore
@@ -14,11 +13,12 @@ module Deplomat
14
13
  end.compact
15
14
  end
16
15
 
17
- def initialize(logfile: "#{Dir.pwd}/deplomat.log", log_to: [:stdout], path: nil, raise_exceptions: true)
16
+ def initialize(logfile: "#{Dir.pwd}/deplomat.log", log_to: [:stdout], path: nil, log_tasks_status: true, raise_exceptions: true)
18
17
  @log_to = log_to
18
+ @log_tasks_status = log_tasks_status
19
19
  @logfile = logfile
20
20
  @raise_exceptions = raise_exceptions
21
- @current_path = path if path_exist?(path)
21
+ @current_path = path.sub(/\/+\Z/, '') if !path.nil? && path_exist?(path)
22
22
  end
23
23
 
24
24
  def execute(command, path=@current_path, message: [], stdout_source: :stdout, log_command: true, _raise_exceptions: @raise_exceptions)
@@ -123,11 +123,11 @@ module Deplomat
123
123
  @current_path = if path =~ /\A[\/~]/ || path.nil?
124
124
  path
125
125
  else
126
- File.expand_path("#{@current_path}#{path}")
126
+ File.expand_path("#{@current_path}/#{path}")
127
127
  end
128
128
 
129
- # Making sure we don't end up with double // at the end of the path
130
- @current_path = @current_path.chomp("/") + "/"
129
+ # Remove / from the end of the current path
130
+ @current_path.sub!(/\/+\Z/, '')
131
131
  end
132
132
 
133
133
  def git_push(remote="origin", branch="master")
@@ -184,7 +184,7 @@ module Deplomat
184
184
  entries_by_date.reverse! if leave[1] == :first
185
185
  entries_by_date = entries_by_date[leave[0]..entries_by_date.length]
186
186
  end
187
- entries_by_date.each { |entry| remove("#{path}#{entry}") } if entries_by_date
187
+ entries_by_date.each { |entry| remove("#{path}/#{entry}") } if entries_by_date
188
188
  end
189
189
  end
190
190
 
@@ -24,7 +24,7 @@ module Deplomat
24
24
  end
25
25
  @pids.compact!
26
26
  if @pids.empty?
27
- raise Error.new("ERROR: no ssh pid found for\n\t#{first_ssh_command}.\nThis is weird.", color: "red")
27
+ raise Deplomat::ExecutionError.new("ERROR: no ssh pid found for\n\t#{first_ssh_command}.\nThis is weird.")
28
28
  elsif @pids.length > 1
29
29
  log("Connected with ssh, host #{host}, but looks like another connection has been opened before...", color: "white")
30
30
  log("connection pids: #{@pids.join(", ")}. We'll be closing them all when finished.", color: "white")
metadata CHANGED
@@ -1,15 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deplomat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.13
4
+ version: 0.2.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - romanitup
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-09 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2020-12-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: colorize
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sys-proctable
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
13
69
  description: Stack agnostic deployment system that uses bash and ssh commands
14
70
  email:
15
71
  executables: []
@@ -53,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
53
109
  - !ruby/object:Gem::Version
54
110
  version: '0'
55
111
  requirements: []
56
- rubygems_version: 3.0.3
112
+ rubygems_version: 3.1.2
57
113
  signing_key:
58
114
  specification_version: 4
59
115
  summary: Deplomat