script_executor 1.7.5 → 1.7.6
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/CHANGES +4 -0
- data/Gemfile.lock +4 -4
- data/lib/script_executor/base_provision.rb +7 -7
- data/lib/script_executor/version.rb +1 -1
- data/spec/base_provision_spec.rb +16 -8
- data/spec/support/script0.sh +21 -0
- data/spec/thor_spec.rb +30 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 145e0125d8e949943a1bf237c1ad46f7606a427d
|
4
|
+
data.tar.gz: 8f43a9cfed71aa16cfe46a5bb3d7cc1ff69126f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abe1d415c3e7d0f5f4ee6b6944194dee479d9549ff8c0c74f4d343eba05751731175e90faede22d5b4034e6f4e49dd9784c8162a92a0e79f50e05b26f0467cf5
|
7
|
+
data.tar.gz: 7b532fbc46970cba8763a740aacfc4ced2a0d56c970157be0b71412e11b84218061479da9f634fd4c9a0105e02b4a707428b3e8bbcc8061f9b644d248f4973b6
|
data/CHANGES
CHANGED
data/Gemfile.lock
CHANGED
@@ -4,13 +4,13 @@ GEM
|
|
4
4
|
awesome_print (1.6.1)
|
5
5
|
blankslate (3.1.3)
|
6
6
|
diff-lcs (1.2.5)
|
7
|
-
file_utils (1.
|
7
|
+
file_utils (1.1.2)
|
8
8
|
gemcutter (0.7.1)
|
9
9
|
gemspec_deps_gen (1.1.2)
|
10
10
|
bundler
|
11
11
|
file_utils
|
12
|
-
highline (1.
|
13
|
-
json_pure (1.8.
|
12
|
+
highline (1.7.8)
|
13
|
+
json_pure (1.8.3)
|
14
14
|
net-ssh (2.9.2)
|
15
15
|
parslet (1.7.1)
|
16
16
|
blankslate (>= 2.0, <= 4.0)
|
@@ -27,7 +27,7 @@ GEM
|
|
27
27
|
diff-lcs (>= 1.2.0, < 2.0)
|
28
28
|
rspec-support (~> 3.3.0)
|
29
29
|
rspec-support (3.3.0)
|
30
|
-
text-interpolator (1.1.
|
30
|
+
text-interpolator (1.1.7)
|
31
31
|
thor (0.19.1)
|
32
32
|
|
33
33
|
PLATFORMS
|
@@ -27,9 +27,9 @@ class BaseProvision
|
|
27
27
|
create_script_methods
|
28
28
|
end
|
29
29
|
|
30
|
-
def run script_name,
|
30
|
+
def run script_name, type=:string, env={}
|
31
31
|
execute(server_info) do
|
32
|
-
evaluate_script_body(script_list[script_name.to_sym][:code],
|
32
|
+
evaluate_script_body(script_list[script_name.to_sym][:code], env, type)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -49,13 +49,13 @@ class BaseProvision
|
|
49
49
|
|
50
50
|
def create_script_methods
|
51
51
|
script_list.keys.each do |name|
|
52
|
-
singleton_class.send(:define_method, name.to_sym) do
|
53
|
-
self.run name.to_s, env
|
52
|
+
singleton_class.send(:define_method, name.to_sym) do |type, params|
|
53
|
+
self.run name.to_s, type, params.empty? ? env : env.merge(params: params.join(' '))
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
def create_thor_methods parent_class
|
58
|
+
def create_thor_methods parent_class, type=:string
|
59
59
|
if parent_class.ancestors.collect(&:to_s).include?('Thor')
|
60
60
|
provision = self
|
61
61
|
|
@@ -66,8 +66,8 @@ class BaseProvision
|
|
66
66
|
|
67
67
|
parent_class.send(:desc, name, title) if parent_class.respond_to?(:desc)
|
68
68
|
|
69
|
-
parent_class.send(:define_method, name.to_sym) do
|
70
|
-
provision.send "#{name}".to_sym
|
69
|
+
parent_class.send(:define_method, name.to_sym) do |*params|
|
70
|
+
provision.send "#{name}".to_sym, type, params
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
data/spec/base_provision_spec.rb
CHANGED
@@ -1,23 +1,31 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
require 'thor'
|
4
3
|
require 'script_executor/base_provision'
|
5
4
|
|
6
|
-
class ThorClass < Thor; end
|
7
|
-
|
8
5
|
describe BaseProvision do
|
9
|
-
subject { BaseProvision.new 'spec/support/base.conf.json', ['spec/support/
|
6
|
+
subject { BaseProvision.new 'spec/support/base.conf.json', ['spec/support/script0.sh'] }
|
10
7
|
|
11
8
|
describe "#initialize" do
|
12
9
|
it "parses content from file" do
|
13
|
-
expect(subject.script_list.size).to equal(
|
10
|
+
expect(subject.script_list.size).to equal(3)
|
14
11
|
end
|
15
12
|
end
|
16
13
|
|
17
14
|
describe "#run" do
|
18
|
-
it "
|
19
|
-
|
20
|
-
|
15
|
+
it "executes command with :erb type" do
|
16
|
+
params = OpenStruct.new({name: 'some name', "project": {"home": 'root'}})
|
17
|
+
|
18
|
+
b = params.instance_eval { binding }
|
19
|
+
|
20
|
+
result = subject.run 'test1', :erb, b
|
21
|
+
|
22
|
+
ap result
|
23
|
+
end
|
24
|
+
|
25
|
+
it "executes command with :string type" do
|
26
|
+
params = {name: 'other name'}
|
27
|
+
|
28
|
+
result = subject.run 'test2', :string, subject.env.merge(params)
|
21
29
|
|
22
30
|
ap result
|
23
31
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
|
4
|
+
# [test1]
|
5
|
+
# Some description
|
6
|
+
|
7
|
+
echo "<%= name %>"
|
8
|
+
|
9
|
+
|
10
|
+
#######################################
|
11
|
+
# [test2]
|
12
|
+
|
13
|
+
echo "#{ name }"
|
14
|
+
|
15
|
+
|
16
|
+
#######################################
|
17
|
+
# [test3]
|
18
|
+
|
19
|
+
echo "#{ name }"
|
20
|
+
|
21
|
+
echo "#{params}"
|
data/spec/thor_spec.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require 'script_executor/base_provision'
|
5
|
+
|
6
|
+
class ThorSpec < Thor
|
7
|
+
class << self
|
8
|
+
attr_reader :provision
|
9
|
+
end
|
10
|
+
|
11
|
+
@provision = BaseProvision.new 'spec/support/base.conf.json', ['spec/support/script0.sh']
|
12
|
+
|
13
|
+
@provision.create_thor_methods(self)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe ThorSpec do
|
17
|
+
describe "#invoke" do
|
18
|
+
it "executes thor without parameters" do
|
19
|
+
ThorSpec.provision.env[:name] = 'name'
|
20
|
+
|
21
|
+
subject.invoke :test2
|
22
|
+
end
|
23
|
+
|
24
|
+
it "executes thor with parameters" do
|
25
|
+
ThorSpec.provision.env[:name] = 'name'
|
26
|
+
|
27
|
+
subject.invoke :test3, ['a', 'b','c']
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: script_executor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Shvets
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|
@@ -172,11 +172,13 @@ files:
|
|
172
172
|
- spec/scripts_parser_spec.rb
|
173
173
|
- spec/spec_helper.rb
|
174
174
|
- spec/support/base.conf.json
|
175
|
+
- spec/support/script0.sh
|
175
176
|
- spec/support/script1.sh
|
176
177
|
- spec/support/script2.sh
|
177
178
|
- spec/support/script3.sh
|
178
179
|
- spec/support/script4.sh
|
179
180
|
- spec/support/script5.sh
|
181
|
+
- spec/thor_spec.rb
|
180
182
|
homepage: http://github.com/shvets/script_executor
|
181
183
|
licenses:
|
182
184
|
- MIT
|
@@ -208,8 +210,10 @@ test_files:
|
|
208
210
|
- spec/scripts_parser_spec.rb
|
209
211
|
- spec/spec_helper.rb
|
210
212
|
- spec/support/base.conf.json
|
213
|
+
- spec/support/script0.sh
|
211
214
|
- spec/support/script1.sh
|
212
215
|
- spec/support/script2.sh
|
213
216
|
- spec/support/script3.sh
|
214
217
|
- spec/support/script4.sh
|
215
218
|
- spec/support/script5.sh
|
219
|
+
- spec/thor_spec.rb
|