deplomat 0.2.18 → 0.2.19

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: 5be39a71be9b135b2a5bd233ce808833deb860517af15ae03bb6723c13fd5e35
4
- data.tar.gz: 95e328842dce669a4a8845d562eaa2cb8b8fb2e4cdda52f5c7fd5a818a99c235
3
+ metadata.gz: a5a59554a67370399c1549d1efaa1900ff11f5dfffff2da0279c8faf0df56ce5
4
+ data.tar.gz: 2a4194a7208c310ec6ec5c365ce27bf71d577bfca25934e97e6544e19db501d7
5
5
  SHA512:
6
- metadata.gz: deb7c22ca7382f2376d3f0fbec59f6527514f631d4d6cf685551e2ac2f1dde028faf9949972bf302b444eed2d93f24ce070e6080fed5fd1228e19830da2c574c
7
- data.tar.gz: 45f7bac07247125eb476a8b1355e869882c4822b4e8fcaf4ed6097689f0f9766e7e39024d3ec7c000757d4d63fc45853036ee10ec0efb55b25eb64b4dc594001
6
+ metadata.gz: e6ebf8007e6bd9e4e22a969e91246d267b7e01df0d68899300b24654f257e0e3bad60c1af7515bcd2e76f656076b8f0da3171aa64156ae0b2ff3d935d0899ba5
7
+ data.tar.gz: ce1470376799e1572739dde2ea14df4d62a4374afac0a658c632d1e2f447e46bd7db61d6e3c6ac01b9eefb4d2eef16dda085ce52368dd0080c7812b5983b0eae
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- deplomat (0.2.18)
4
+ deplomat (0.2.19)
5
5
  colorize
6
6
  sys-proctable
7
7
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.18
1
+ 0.2.19
@@ -6,6 +6,14 @@ module Deplomat
6
6
  super
7
7
  end
8
8
 
9
+ def path_exist?(path)
10
+ exists = File.exist?(adjusted_path(path))
11
+ print_to_terminal((exists ? "EXISTS: #{path}" : "NOT FOUND: #{path}"))
12
+ exists
13
+ end
14
+ alias :path_exists? :path_exist?
15
+ alias :file_exists? :path_exist?
16
+
9
17
  end
10
18
 
11
19
  end
@@ -105,29 +105,25 @@ module Deplomat
105
105
  alias :mkdir :create_dir
106
106
 
107
107
  def create_symlink(source, target)
108
- execute("ln -s #{source} #{target}")
108
+ execute("ln -sf #{source} #{target}")
109
109
  end
110
110
  alias :ln :create_symlink
111
111
 
112
- def path_exist?(path)
113
- execute("[ -e #{path} ]", @current_path, log_command: false, _raise_exceptions: true) && true
114
- rescue Deplomat::ExecutionError # returned 1, file doesn't exist
115
- false
112
+ def adjusted_path(path)
113
+ if !path.match(/\A\/|~\//)
114
+ path = "#{@current_path}/#{path}".sub("//", "/")
115
+ end
116
+ File.absolute_path(path)
116
117
  end
117
- alias :path_exists? :path_exist?
118
- alias :file_exists? :path_exist?
119
118
 
120
119
  def cd(path)
121
- raise Deplomat::NoSuchPathError, path if !path.nil? && !path_exist?(path)
122
-
123
- @current_path = if path =~ /\A[\/~]/ || path.nil?
120
+ path = adjusted_path(path)
121
+ raise Deplomat::NoSuchPathError, path unless path_exist?(path)
122
+ @current_path = if path.match(/\A\/|~\//)
124
123
  path
125
124
  else
126
- File.expand_path("#{@current_path}/#{path}")
127
- end
128
-
129
- # Remove / from the end of the current path
130
- @current_path.sub!(/\/+\Z/, '')
125
+ "#{@current_path}/#{path}"
126
+ end.sub(/\/+\Z/, '')
131
127
  end
132
128
 
133
129
  def git_push(remote="origin", branch="master")
@@ -50,6 +50,15 @@ module Deplomat
50
50
  super("#{@ssh_command} '#{command}'", nil, message: message, stdout_source: stdout_source, log_command: false, _raise_exceptions: _raise_exceptions)
51
51
  end
52
52
 
53
+ def path_exist?(path)
54
+ path = adjusted_path(path)
55
+ status = execute("test -f #{path} || test -d #{path}", nil, log_command: true, _raise_exceptions: false)[:status]
56
+ log((status == 1 ? "NOT FOUND: #{path}" : "EXISTS: #{path}"))
57
+ status == 0
58
+ end
59
+ alias :path_exists? :path_exist?
60
+ alias :file_exists? :path_exist?
61
+
53
62
  def upload(what, where, except: nil)
54
63
  except = "--exclude '#{except}'" if except
55
64
  local_execute "rsync -arzve 'ssh #{@port ? "-p #{@port.to_s} " : ""}' #{except} --delete #{what} #{@user}@#{@host}:#{where}", nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deplomat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.18
4
+ version: 0.2.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - romanitup