script_executor 1.7.5 → 1.7.6

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
  SHA1:
3
- metadata.gz: 14d76bcbd7dec002c5f8a212e401e85fc179d48d
4
- data.tar.gz: fdd367cd483f92c06fca53ceed9071971ade9eb6
3
+ metadata.gz: 145e0125d8e949943a1bf237c1ad46f7606a427d
4
+ data.tar.gz: 8f43a9cfed71aa16cfe46a5bb3d7cc1ff69126f2
5
5
  SHA512:
6
- metadata.gz: 7cd378c64712dcfda80578495da636439cf31845c98350f0c574daa9ffb15ce4d772875996634c7cf284fd60a1eea1259f34973ddfda1de2adbe6023f5ad4f67
7
- data.tar.gz: 15301ca977bf1cc446da11ebc71caa22ae5eb7ca1b601add1f28459e2366a18af72cd149b614f6d539b15193b02e716d8e5148167ca453f5a40d64707f4e2fdd
6
+ metadata.gz: abe1d415c3e7d0f5f4ee6b6944194dee479d9549ff8c0c74f4d343eba05751731175e90faede22d5b4034e6f4e49dd9784c8162a92a0e79f50e05b26f0467cf5
7
+ data.tar.gz: 7b532fbc46970cba8763a740aacfc4ced2a0d56c970157be0b71412e11b84218061479da9f634fd4c9a0105e02b4a707428b3e8bbcc8061f9b644d248f4973b6
data/CHANGES CHANGED
@@ -113,3 +113,7 @@
113
113
  == Version 1.7.5
114
114
 
115
115
  * Add one more format for name section.
116
+
117
+ == Version 1.7.6
118
+
119
+ * Bug fixes.
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.0.7)
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.6.15)
13
- json_pure (1.8.1)
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.6)
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, params={}, type=:string
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], params, type)
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
@@ -1,3 +1,3 @@
1
1
  class ScriptExecutor
2
- VERSION = "1.7.5"
2
+ VERSION = "1.7.6"
3
3
  end
@@ -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/script1.sh'] }
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(9)
10
+ expect(subject.script_list.size).to equal(3)
14
11
  end
15
12
  end
16
13
 
17
14
  describe "#run" do
18
- it "parses content from file" do
19
- name = 'name'
20
- result = subject.run 'test1', binding, :erb
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.5
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-10-31 00:00:00.000000000 Z
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