inprovise 0.2.12 → 0.2.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MmU0MTAwMDZmYzQzNTQxYzA2ZGU5MTNmNzA4ZDJkNDg2ZTU0ZTRjOQ==
4
+ NDM3NDQyMTI2YjQ3MTdmY2QzNzBiM2U4ZDY3ZGIyYmI0MDNkYTUyNg==
5
5
  data.tar.gz: !binary |-
6
- MzAzNWE4NTY0ZmMwNDgzZDRkMTY3MTJkNDBhOTM2N2FmOGY0YzIzYQ==
6
+ NTViNDMwM2JmNDI4YWE4MmU3YmQ0OTlhYjQ0YWI2MGQ5YjFmZDVhMQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDMwYzRiZGU2YzE2ZTZiZGYwYjRkMjJkMzExMGE0MDdkMTI1NTllMjQxNzY0
10
- MTRhYjBjZmYyNDk0ODAzZDAzNDIwNWU3YThjYWFmYWYzY2EzZDQyZjliNWY3
11
- ZWVhYzgxZDEyZWEzMWU5YTgzZjkxOGU2YTc4MThiOTdiNDk0MzI=
9
+ ZGRlY2FhYTA5ZmE1NWIwNzI2NzMyMDdhZjE1NWJlZmZmM2NkZGYyNzhmYWRi
10
+ YzExMTYwZmE2NTcwOGRlYjk1YWU5NGIzZTYxZWEwMTgxMmQyZTI0MDQxMDhm
11
+ Y2U4MDExNDZkYjZkNzYzZDRjMzIwZDMxODc3OTlmZTlmZThlZjg=
12
12
  data.tar.gz: !binary |-
13
- NWM0ZmUxMzZlYzllYTM3NjY3MjNhNWY5YjZjMTdlNWM5M2Y4YjFmZGY2NGI3
14
- MTAyODMxMjVlMTA3NDdjZDFiYmE3MjJkMGQ0ZWFmZjc2YzIwM2JiM2RjZDI1
15
- NjI1YWFjMDNkNmFiMDg4MjM4ZDM5OWNlY2M1MzE5Y2FlNWVlMzg=
13
+ OTc5ZTUwNmRhN2UxYzIyZWFmOGM0NTEyNmMxYjQxNWVmNzE3OTE4YmQ2NDk0
14
+ Y2YyNzgyYjIzMDg0MjE2M2Q5MzdlYzVmMTAwZTIwZjYxZGNiNjQwOTNjODJk
15
+ MWM3OGM3N2FmODQ0ZTdjMjYzMjQ3NWJlZjc3MTc3N2NmMjVkYjM=
@@ -168,7 +168,7 @@ class Inprovise::Controller
168
168
  @targets << tgt
169
169
  [
170
170
  if command == :trigger
171
- Inprovise::TriggerRunner.new(tgt, cmdtgt)
171
+ Inprovise::TriggerRunner.new(tgt, cmdtgt, Inprovise.skip_dependencies)
172
172
  else
173
173
  Inprovise::ScriptRunner.new(tgt, Inprovise::ScriptIndex.default.get(cmdtgt), Inprovise.skip_dependencies)
174
174
  end,
@@ -217,15 +217,15 @@ class Inprovise::ExecutionContext
217
217
 
218
218
  def resolve_action_ref(action_ref)
219
219
  action_name, scr_name = *action_ref.split(':', 2).reverse
220
- scr = @script
221
- scr = @index.get(scr_name) if scr_name
222
- action = scr ? scr.actions[action_name] : nil
223
- raise Inprovise::MissingActionError.new(action_ref) unless action
224
- [scr, action]
220
+ scr = scr_name ? @index.get(scr_name) : nil
221
+ [scr, action_name]
225
222
  end
226
223
 
227
- def trigger(scr, action, *args)
228
- curtask = @node.log.set_task(action_ref)
224
+ def trigger(scr, action_name, *args)
225
+ scr ||= @script
226
+ action = scr ? scr.actions[action_name] : nil
227
+ raise Inprovise::MissingActionError.new("#{scr ? scr.name+':' : ''}#{action_name}") unless action
228
+ curtask = @node.log.set_task("#{scr.name}:#{action_name}")
229
229
  curscript = @script
230
230
  @script = scr
231
231
  begin
@@ -4,10 +4,11 @@
4
4
  # License:: Distributes under the same license as Ruby
5
5
 
6
6
  class Inprovise::TriggerRunner
7
- def initialize(node, action_ref_with_args)
7
+ def initialize(node, action_ref_with_args, skip_dependencies=false)
8
8
  @node = node
9
9
  @action_ref, @args = *parse_action_ref(action_ref_with_args)
10
10
  @log = Inprovise::Logger.new(@node, @action_ref)
11
+ @skip_dependencies = skip_dependencies
11
12
  @index = Inprovise::ScriptIndex.default
12
13
  end
13
14
 
@@ -19,7 +20,7 @@ class Inprovise::TriggerRunner
19
20
  Inprovise.log.local("Triggering #{@action_ref} for #{@node.to_s}")
20
21
  context = Inprovise::ExecutionContext.new(@node, @log, @index, config)
21
22
  scr, action = context.resolve_action_ref(@action_ref)
22
- setup_configuration(scr, context)
23
+ setup_configuration(scr, context) if scr
23
24
  context.trigger(scr, action, *@args)
24
25
  end
25
26
 
@@ -27,18 +28,28 @@ class Inprovise::TriggerRunner
27
28
  Inprovise.log.local("Demonstrating trigger #{@action_ref} for #{@node.to_s}")
28
29
  context = Inprovise::MockExecutionContext.new(@node, @log, @index, config)
29
30
  scr, action = context.resolve_action_ref(@action_ref)
30
- setup_configuration(scr, context)
31
+ setup_configuration(scr, context) if scr
31
32
  context.trigger(scr, action, *@args)
32
33
  end
33
34
 
34
35
  private
35
36
 
37
+ def scripts(script)
38
+ return [script] if @skip_dependencies
39
+ resolver = Inprovise::Resolver.new(script, @index)
40
+ resolver.resolve
41
+ resolver.scripts
42
+ end
43
+
36
44
  def setup_configuration(script, context)
37
- script.update_configuration(context)
38
- context.log.set_task(script)
39
- context.log.command(:configure)
40
- context.script = script
41
- script.command(:configure).each {|cmd| context.exec_config(cmd) }
45
+ script_list = scripts(script)
46
+ script_list.each { |scr| scr.update_configuration(context) }
47
+ script_list.each do |scr|
48
+ context.log.set_task(scr)
49
+ context.log.command(:configure)
50
+ context.script = scr
51
+ scr.command(:configure).each {|cmd| context.exec_config(cmd) }
52
+ end
42
53
  end
43
54
 
44
55
  def parse_action_ref(action_ref_with_args)
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Inprovise
7
7
 
8
- VERSION = '0.2.12'
8
+ VERSION = '0.2.13'
9
9
 
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inprovise
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.12
4
+ version: 0.2.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Corino