deplomat 0.1.3 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19c9e18dffd7b609ac6fa97ed1dfba3657dac02f
4
- data.tar.gz: 56669fbf77b52f128336a5e2195df31bfc12dc9f
3
+ metadata.gz: dde00e6d13b40e55c1da3dec35d12123cd524434
4
+ data.tar.gz: 0de6af01c6d1e4be9f207246db8775489743f0ab
5
5
  SHA512:
6
- metadata.gz: 9aab773fa6a23eb5025dcd73bc83ab614d1c4e4c463bd436e3ed42d20ca81625abb9c25ff65be28b8c04b8f0b19815ffc5123726c5cb11c0140139a8378f333c
7
- data.tar.gz: 3264cff003a6f8b327e98a516d97ee49b51aa8753035e003bacfbb42664b6844cf21cf0920f4aa487c52e369fbc95f638b941696d8e4bfa134d998e144b59fa9
6
+ metadata.gz: edc64328013f3783e9ab4fb0469848b38a216b8ae525587b525142d9a7b6f98e4a8a83592dba8f5a92e36a9ca9682543c1a762ab29964132b2fd1d17fabb183c
7
+ data.tar.gz: c1a84e27eb85e34c1467c76a7f645e2fa70bd8c6fcb220f85fc477cee9e1fd9620c9a9f3fc3c9bbf0bb61b701e28f717b71ef50f2d9ff98518daac065af6e1a5
data/Gemfile.lock CHANGED
@@ -2,7 +2,7 @@ GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
4
  addressable (2.4.0)
5
- builder (3.2.2)
5
+ builder (3.2.3)
6
6
  colorize (0.7.7)
7
7
  descendants_tracker (0.0.4)
8
8
  thread_safe (~> 0.3, >= 0.3.1)
@@ -10,43 +10,44 @@ GEM
10
10
  faraday (0.9.2)
11
11
  multipart-post (>= 1.2, < 3)
12
12
  git (1.3.0)
13
- github_api (0.13.1)
13
+ github_api (0.16.0)
14
14
  addressable (~> 2.4.0)
15
15
  descendants_tracker (~> 0.0.4)
16
16
  faraday (~> 0.8, < 0.10)
17
17
  hashie (>= 3.4)
18
- multi_json (>= 1.7.5, < 2.0)
19
- oauth2
20
- hashie (3.4.4)
18
+ mime-types (>= 1.16, < 3.0)
19
+ oauth2 (~> 1.0)
20
+ hashie (3.5.6)
21
21
  highline (1.7.8)
22
- jeweler (2.1.1)
22
+ jeweler (2.3.7)
23
23
  builder
24
- bundler (>= 1.0)
24
+ bundler (>= 1)
25
25
  git (>= 1.2.5)
26
- github_api
26
+ github_api (~> 0.16.0)
27
27
  highline (>= 1.6.15)
28
28
  nokogiri (>= 1.5.10)
29
+ psych (~> 2.2)
29
30
  rake
30
31
  rdoc
31
- semver
32
- json (1.8.3)
33
- jwt (1.5.1)
34
- mini_portile2 (2.0.0)
35
- multi_json (1.11.3)
36
- multi_xml (0.5.5)
32
+ semver2
33
+ jwt (1.5.6)
34
+ mime-types (2.99.3)
35
+ mini_portile2 (2.3.0)
36
+ multi_json (1.12.2)
37
+ multi_xml (0.6.0)
37
38
  multipart-post (2.0.0)
38
- nokogiri (1.6.7.2)
39
- mini_portile2 (~> 2.0.0.rc2)
40
- oauth2 (1.1.0)
41
- faraday (>= 0.8, < 0.10)
42
- jwt (~> 1.0, < 1.5.2)
39
+ nokogiri (1.8.1)
40
+ mini_portile2 (~> 2.3.0)
41
+ oauth2 (1.4.0)
42
+ faraday (>= 0.8, < 0.13)
43
+ jwt (~> 1.0)
43
44
  multi_json (~> 1.3)
44
45
  multi_xml (~> 0.5)
45
46
  rack (>= 1.2, < 3)
46
- rack (1.6.4)
47
- rake (11.1.2)
48
- rdoc (4.2.2)
49
- json (~> 1.4)
47
+ psych (2.2.4)
48
+ rack (2.0.3)
49
+ rake (12.3.0)
50
+ rdoc (5.1.0)
50
51
  rspec (3.4.0)
51
52
  rspec-core (~> 3.4.0)
52
53
  rspec-expectations (~> 3.4.0)
@@ -60,9 +61,9 @@ GEM
60
61
  diff-lcs (>= 1.2.0, < 2.0)
61
62
  rspec-support (~> 3.4.0)
62
63
  rspec-support (3.4.1)
63
- semver (1.0.1)
64
+ semver2 (3.4.2)
64
65
  sys-proctable (1.0.0)
65
- thread_safe (0.3.5)
66
+ thread_safe (0.3.6)
66
67
 
67
68
  PLATFORMS
68
69
  ruby
@@ -75,4 +76,4 @@ DEPENDENCIES
75
76
  sys-proctable
76
77
 
77
78
  BUNDLED WITH
78
- 1.12.0
79
+ 1.16.0
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.5
data/deplomat.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: deplomat 0.1.3 ruby lib
5
+ # stub: deplomat 0.1.5 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "deplomat"
9
- s.version = "0.1.3"
9
+ s.version = "0.1.5"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Roman Snitko"]
14
- s.date = "2017-04-12"
14
+ s.date = "2017-11-19"
15
15
  s.description = "Stack agnostic deployment system that uses bash and ssh commands"
16
16
  s.email = "roman.snitko@gmail.com"
17
17
  s.extra_rdoc_files = [
@@ -6,12 +6,6 @@ module Deplomat
6
6
  super
7
7
  end
8
8
 
9
- private
10
-
11
- def path_exist?(path)
12
- File.exist?(path)
13
- end
14
-
15
9
  end
16
10
 
17
11
  end
data/lib/deplomat/node.rb CHANGED
@@ -12,7 +12,7 @@ module Deplomat
12
12
  self.cd(path) if path
13
13
  end
14
14
 
15
- def execute(command, path=@current_path, message: [], stdout_source: :stdout, log_command: true)
15
+ def execute(command, path=@current_path, message: [], stdout_source: :stdout, log_command: true, _raise_exceptions: @raise_exceptions)
16
16
 
17
17
  message = [message] if message.kind_of?(String)
18
18
  log(message[0] + "\n", color: 'white') unless message.empty? || message.nil?
@@ -35,7 +35,7 @@ module Deplomat
35
35
  log("--> " + command_to_log + "\n", color: "white") if log_command
36
36
  while line=stdout_source_object.gets do
37
37
  out << line
38
- log(" #{line}")
38
+ log(" #{line}") if log_command
39
39
  end
40
40
 
41
41
  error_out = ""
@@ -45,7 +45,7 @@ module Deplomat
45
45
  error_out += o
46
46
  end
47
47
  log(error_out + "\n", color: 'red')
48
- if @raise_exceptions
48
+ if _raise_exceptions
49
49
  self.close if self.respond_to?(:close)
50
50
  raise Deplomat::ExecutionError
51
51
  end
@@ -88,13 +88,22 @@ module Deplomat
88
88
  end
89
89
  alias :ln :create_symlink
90
90
 
91
+ def path_exist?(path)
92
+ execute("[ -e #{path} ]", @current_path, _raise_exceptions: true) && true
93
+ rescue Deplomat::ExecutionError # returned 1, file doesn't exist
94
+ false
95
+ end
96
+ alias :path_exists? :path_exist?
97
+ alias :file_exists? :path_exist?
98
+
91
99
  def cd(path)
100
+ raise Deplomat::NoSuchPathError, path if !path.nil? && !path_exist?(path)
101
+
92
102
  @current_path = if path =~ /\A[\/~]/ || path.nil?
93
103
  path
94
104
  else
95
105
  File.expand_path("#{@current_path}#{path}")
96
106
  end
97
- raise Deplomat::NoSuchPathError, @current_path if !@current_path.nil? && !path_exist?(@current_path)
98
107
 
99
108
  # Making sure we don't end up with double // at the end of the path
100
109
  @current_path = @current_path.chomp("/") + "/"
@@ -118,7 +127,7 @@ module Deplomat
118
127
 
119
128
  def clean(path: @current_path, except: [], leave: [0, :last])
120
129
  # Gets us all entries sorted by date, most recent ones first
121
- entries_by_date = execute("ls -t", path)[:out].split("\n")
130
+ entries_by_date = execute("ls -t", path, log_command: false)[:out].split("\n")
122
131
  # Don't do anything with entries listed in :except
123
132
  entries_by_date = entries_by_date - except
124
133
  if leave
@@ -30,12 +30,12 @@ module Deplomat
30
30
  end
31
31
 
32
32
  alias :local_execute :execute
33
- def execute(command, path=@current_path, message: [], env_vars: '', login_shell: false, stdout_source: :stdout, log_command: true)
33
+ def execute(command, path=@current_path, message: [], env_vars: '', login_shell: false, stdout_source: :stdout, log_command: true, _raise_exceptions: @raise_exceptions)
34
34
 
35
35
  log("(#{@host}) --> " + command + "\n", color: "white") if log_command
36
36
  command = "#{env_vars} cd #{path} && #{command}" if path
37
37
  command = "bash -l -c \"#{command}\"" if login_shell
38
- super("#{@ssh_command} '#{command}'", nil, message: message, stdout_source: stdout_source, log_command: false)
38
+ super("#{@ssh_command} '#{command}'", nil, message: message, stdout_source: stdout_source, log_command: false, _raise_exceptions: _raise_exceptions)
39
39
  end
40
40
 
41
41
  def upload(what, where, except: nil)
@@ -52,13 +52,5 @@ module Deplomat
52
52
  end
53
53
  end
54
54
 
55
- private
56
-
57
- def path_exist?(path)
58
- old_raise_exceptions = @raise_exceptions
59
- @raise_exceptions = false
60
- !(execute("ls #{path}", nil, log_command: false){ @raise_exceptions = old_raise_exceptions}[:status] > 0)
61
- end
62
-
63
55
  end
64
56
  end
data/spec/node_spec.rb CHANGED
@@ -2,12 +2,20 @@ require 'spec_helper'
2
2
 
3
3
  describe Deplomat::Node do
4
4
 
5
- describe "logging" do
5
+ before(:each) do
6
+ @fixtures_dir = Dir.pwd + "/spec/fixtures"
7
+ @node = Deplomat::Node.new(logfile: "#{@fixtures_dir}/deplomat.log", log_to: [:file, :stdout])
8
+ end
6
9
 
7
- before(:each) do
8
- @fixtures_dir = Dir.pwd + "/spec/fixtures"
9
- @node = Deplomat::Node.new(logfile: "#{@fixtures_dir}/deplomat.log", log_to: [:file, :stdout])
10
- end
10
+ it "checks if file exists" do
11
+ expect(@node.file_exists?("#{@fixtures_dir}/existing_file.txt")).to be_falsey
12
+ expect(@node.file_exists?("/non-existent-path")).to be_falsey
13
+ FileUtils.touch("#{@fixtures_dir}/existing_file.txt")
14
+ expect(@node.file_exists?("#{@fixtures_dir}/existing_file.txt")).to be_truthy
15
+ FileUtils.rm("#{@fixtures_dir}/existing_file.txt")
16
+ end
17
+
18
+ describe "logging" do
11
19
 
12
20
  after(:each) do
13
21
  @node.log_to = []
@@ -28,7 +36,7 @@ describe Deplomat::Node do
28
36
 
29
37
  it "puts additional messages into the terminal when required" do
30
38
  expect($stdout).to receive(:print).once.with("hello\n".white)
31
- expect($stdout).to receive(:print).once.with("--> ls /home/roman/Dropbox/Work/my_libs/deplomat/spec/fixtures/dir1\n".white)
39
+ expect($stdout).to receive(:print).once.with("--> ls #{@fixtures_dir}/dir1\n".white)
32
40
  expect($stdout).to receive(:print).once.with(" file1\n".light_black)
33
41
  expect($stdout).to receive(:print).once.with(" file2\n".light_black)
34
42
  expect($stdout).to receive(:print).once.with(" subdir1\n".light_black)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deplomat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Snitko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-12 00:00:00.000000000 Z
11
+ date: 2017-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sys-proctable