evrone-ci-common 0.0.1 → 0.0.2
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/lib/evrone/ci/common/helper/shell.rb +85 -0
- data/lib/evrone/ci/common/version.rb +1 -1
- data/lib/evrone/ci/common.rb +4 -1
- data/lib/evrone/ci/csm/git/git_ssh.rb +1 -1
- data/lib/evrone/ci/csm/git.rb +1 -1
- data/spec/lib/common/{shell_helper_spec.rb → helper/shell_spec.rb} +1 -1
- metadata +4 -4
- data/lib/evrone/ci/common/shell_helper.rb +0 -83
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89f9937f07ebd9d634ecd280588b0adbd42f9622
|
4
|
+
data.tar.gz: 587804a24117a695395807203d1797bdd86ee0c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0b8b932d1617fd3f9c327804f0db5d061a738c70494467d022ad0c3fc1abd5f8601e7143a2baf6efd51c4a32512eda519ee342a6edcfedc804b690ec5622ef8
|
7
|
+
data.tar.gz: 2594eb70a663c38bca897a4fd5a9a6d1a57eeeb85367aff18b372da7c15a8981c327765e26772d4cabcce2e5de0d1f29f6b0d3895ddec6b4f854cacd88e8269e
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'tempfile'
|
4
|
+
require 'shellwords'
|
5
|
+
|
6
|
+
require 'evrone/common/spawn'
|
7
|
+
|
8
|
+
module Evrone
|
9
|
+
module CI
|
10
|
+
module Common
|
11
|
+
module Helper
|
12
|
+
|
13
|
+
module Shell
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
include Evrone::Common::Spawn
|
18
|
+
|
19
|
+
def path(name)
|
20
|
+
Pathname.new(name)
|
21
|
+
end
|
22
|
+
|
23
|
+
def mkdir(name)
|
24
|
+
FileUtils.mkdir_p name.to_s
|
25
|
+
end
|
26
|
+
|
27
|
+
def rm(name)
|
28
|
+
FileUtils.rm_rf name.to_s
|
29
|
+
end
|
30
|
+
|
31
|
+
def recreate(name)
|
32
|
+
rm name
|
33
|
+
mkdir name
|
34
|
+
end
|
35
|
+
|
36
|
+
def write_file(name, content, perm = 0644)
|
37
|
+
File.open(name, 'w', perm) do |io|
|
38
|
+
io.write content
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def write_tmp_file(name, content, perm = 0600)
|
43
|
+
tmp = ::Tempfile.new name
|
44
|
+
tmp.write content
|
45
|
+
tmp.rewind
|
46
|
+
tmp.flush
|
47
|
+
tmp.close
|
48
|
+
FileUtils.chmod perm, tmp.path
|
49
|
+
tmp
|
50
|
+
end
|
51
|
+
|
52
|
+
def read_file(name)
|
53
|
+
if File.readable?(name)
|
54
|
+
File.read name
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def expand_path(path)
|
59
|
+
File.expand_path path.to_s
|
60
|
+
end
|
61
|
+
|
62
|
+
def bash(*args, &block)
|
63
|
+
raise ArgumentError, 'block required' unless block_given?
|
64
|
+
|
65
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
66
|
+
command = args.first
|
67
|
+
|
68
|
+
cmd = "/usr/bin/env -i HOME=${HOME} bash"
|
69
|
+
|
70
|
+
if file = options.delete(:file)
|
71
|
+
cmd << " #{file}"
|
72
|
+
else
|
73
|
+
cmd << " -c " << Shellwords.escape(command)
|
74
|
+
end
|
75
|
+
|
76
|
+
runner = options.delete(:ssh) || self
|
77
|
+
runner.send(:spawn, cmd, options, &block)
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/lib/evrone/ci/common.rb
CHANGED
@@ -5,7 +5,10 @@ module Evrone
|
|
5
5
|
|
6
6
|
module Common
|
7
7
|
|
8
|
-
|
8
|
+
module Helper
|
9
|
+
autoload :Shell, File.expand_path("../common/helper/shell", __FILE__)
|
10
|
+
end
|
11
|
+
|
9
12
|
autoload :PerformMessageWrapper, File.expand_path("../common/perform_message_wrapper", __FILE__)
|
10
13
|
|
11
14
|
end
|
data/lib/evrone/ci/csm/git.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evrone-ci-common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Galinsky
|
@@ -110,13 +110,13 @@ files:
|
|
110
110
|
- Rakefile
|
111
111
|
- evrone-ci-common.gemspec
|
112
112
|
- lib/evrone/ci/common.rb
|
113
|
+
- lib/evrone/ci/common/helper/shell.rb
|
113
114
|
- lib/evrone/ci/common/perform_message_wrapper.rb
|
114
|
-
- lib/evrone/ci/common/shell_helper.rb
|
115
115
|
- lib/evrone/ci/common/version.rb
|
116
116
|
- lib/evrone/ci/csm/git.rb
|
117
117
|
- lib/evrone/ci/csm/git/git_ssh.rb
|
118
|
+
- spec/lib/common/helper/shell_spec.rb
|
118
119
|
- spec/lib/common/perform_message_wrapper_spec.rb
|
119
|
-
- spec/lib/common/shell_helper_spec.rb
|
120
120
|
- spec/lib/csm/git_spec.rb
|
121
121
|
- spec/spec_helper.rb
|
122
122
|
homepage: ''
|
@@ -144,7 +144,7 @@ signing_key:
|
|
144
144
|
specification_version: 4
|
145
145
|
summary: Common code for ci
|
146
146
|
test_files:
|
147
|
+
- spec/lib/common/helper/shell_spec.rb
|
147
148
|
- spec/lib/common/perform_message_wrapper_spec.rb
|
148
|
-
- spec/lib/common/shell_helper_spec.rb
|
149
149
|
- spec/lib/csm/git_spec.rb
|
150
150
|
- spec/spec_helper.rb
|
@@ -1,83 +0,0 @@
|
|
1
|
-
require 'pathname'
|
2
|
-
require 'fileutils'
|
3
|
-
require 'tempfile'
|
4
|
-
require 'shellwords'
|
5
|
-
|
6
|
-
require 'evrone/common/spawn'
|
7
|
-
|
8
|
-
module Evrone
|
9
|
-
module CI
|
10
|
-
module Common
|
11
|
-
|
12
|
-
module ShellHelper
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
include Evrone::Common::Spawn
|
17
|
-
|
18
|
-
def path(name)
|
19
|
-
Pathname.new(name)
|
20
|
-
end
|
21
|
-
|
22
|
-
def mkdir(name)
|
23
|
-
FileUtils.mkdir_p name.to_s
|
24
|
-
end
|
25
|
-
|
26
|
-
def rm(name)
|
27
|
-
FileUtils.rm_rf name.to_s
|
28
|
-
end
|
29
|
-
|
30
|
-
def recreate(name)
|
31
|
-
rm name
|
32
|
-
mkdir name
|
33
|
-
end
|
34
|
-
|
35
|
-
def write_file(name, content, perm = 0644)
|
36
|
-
File.open(name, 'w', perm) do |io|
|
37
|
-
io.write content
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def write_tmp_file(name, content, perm = 0600)
|
42
|
-
tmp = ::Tempfile.new name
|
43
|
-
tmp.write content
|
44
|
-
tmp.rewind
|
45
|
-
tmp.flush
|
46
|
-
tmp.close
|
47
|
-
FileUtils.chmod perm, tmp.path
|
48
|
-
tmp
|
49
|
-
end
|
50
|
-
|
51
|
-
def read_file(name)
|
52
|
-
if File.readable?(name)
|
53
|
-
File.read name
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def expand_path(path)
|
58
|
-
File.expand_path path.to_s
|
59
|
-
end
|
60
|
-
|
61
|
-
def bash(*args, &block)
|
62
|
-
raise ArgumentError, 'block required' unless block_given?
|
63
|
-
|
64
|
-
options = args.last.is_a?(Hash) ? args.pop : {}
|
65
|
-
command = args.first
|
66
|
-
|
67
|
-
cmd = "/usr/bin/env -i HOME=${HOME} bash"
|
68
|
-
|
69
|
-
if file = options.delete(:file)
|
70
|
-
cmd << " #{file}"
|
71
|
-
else
|
72
|
-
cmd << " -c " << Shellwords.escape(command)
|
73
|
-
end
|
74
|
-
|
75
|
-
runner = options.delete(:ssh) || self
|
76
|
-
runner.send(:spawn, cmd, options, &block)
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|