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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4278281c960d9b21bdd6bdb79819a48f18a9df61
4
- data.tar.gz: dc7add247f9d9c232d4b91ee33fc3de11b431348
3
+ metadata.gz: 89f9937f07ebd9d634ecd280588b0adbd42f9622
4
+ data.tar.gz: 587804a24117a695395807203d1797bdd86ee0c7
5
5
  SHA512:
6
- metadata.gz: e25753b2a629e1fdfa1a669fb4d046e1d040bf133e1932b5f9f0caacd01095e0ee5b3d4641151293c61d6373f98b2b1a5101cab54ae9f08b77b3022bc53036fe
7
- data.tar.gz: 98a0937ae915d2d07ac341746d0ae3e7a98fde634fcd445456ee919d41e32c604ef1e163ffce2c45e92c82c7637a65d5569c6b2d0ee88a92721a84ae67a5287e
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
@@ -1,7 +1,7 @@
1
1
  module Evrone
2
2
  module CI
3
3
  module Common
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
6
6
  end
7
7
  end
@@ -5,7 +5,10 @@ module Evrone
5
5
 
6
6
  module Common
7
7
 
8
- autoload :ShellHelper, File.expand_path("../common/shell_helper", __FILE__)
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
@@ -6,7 +6,7 @@ module Evrone
6
6
 
7
7
  class GitSSH
8
8
 
9
- include Common::ShellHelper
9
+ include Common::Helper::Shell
10
10
 
11
11
  attr_reader :deploy_key
12
12
 
@@ -7,7 +7,7 @@ module Evrone
7
7
 
8
8
  class Git
9
9
 
10
- include Common::ShellHelper
10
+ include Common::Helper::Shell
11
11
 
12
12
  COMMIT_RE = /^(.*) -:- (.*) \((.*)\) -:- (.*)$/
13
13
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Evrone::CI::Common::ShellHelper do
3
+ describe Evrone::CI::Common::Helper::Shell do
4
4
 
5
5
  let(:klass) { Class.new.tap{|i| i.send :include, described_class } }
6
6
  let(:object) { klass.new }
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.1
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