coral_plan 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d08101618ff0dc615dad752c9064ebe0a5ed4d35
4
+ data.tar.gz: 1c9420a4184fd87ebba109aa4584908c2c0f78d0
5
+ SHA512:
6
+ metadata.gz: a3e847cd1be7e2e1cd9119eb730c6ea06128f91a01fa70319bdb32349bcd1a7212d678bbcbfd721c99cbaf49b90eb21ccd844118142c3066b739ffe7f0062d5b
7
+ data.tar.gz: eb764d9eab832ed0d91f76d2611cc12b2698165af64bdae8a61d6cca6d01539abba2f5f94ac33cc36c95aab28f10ff09bbc6a31fc5541c8d42dc341c58732158
data/coral_plan.gemspec CHANGED
@@ -5,17 +5,14 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "coral_plan"
8
- s.version = "0.1.3"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Adrian Webb"]
12
- s.date = "2013-03-14"
13
- s.description = "= coral_plan\n\nThis library provides the ability to create, load, execute, and save \nexecution plans.\n\nThe Coral Plan library contains a system that defines execution plans of \nCLI commands. The goal is to make it easy to create, edit, load, execute,\nand save these plans in a machine readable format (ie; JSON). The system \nis composed of Events, Commands, Actions, and of course Plans. There are a\nfew simple rules:\n \n1. All plans begin with a Command but may have more Commands defined\n that act in sequence unless there are errors with previous commands.\n \n2. Commands can trigger Events of various types, where Events are reading\n and checking (ie; Regular expressions) Command output line by line.\n \n3. Events have different criteria for measuring success and will have \n different fields. For example, a Regexp event contains a 'pattern'\n field.\n \n4. Actions listen for Events and run Commands, with the ability to override\n default Command parameters. Actions may also generate Events on either\n successful execution or failure which can trigger other Actions.\n \nNote: This library is still very early in development!\n\n== Contributing to coral_plan\n \n* Check out the latest {major}.{minor} branch to make sure the feature hasn't \n been implemented or the bug hasn't been fixed yet.\n* Check out the issue tracker to make sure someone already hasn't requested \n it and/or contributed it.\n* Fork the project.\n* Start a feature/bugfix branch.\n* Commit and push until you are happy with your contribution.\n* Make sure to add tests for it. This is important so I don't break it in a \n future version unintentionally.\n* Please try not to mess with the Rakefile, version, or history. If you want \n to have your own version, or is otherwise necessary, that is fine, but \n please isolate to its own commit so I can cherry-pick around it.\n\n== Copyright\n\nLicensed under GPLv3. See LICENSE.txt for further details.\n\nCopyright (c) 2013 Adrian Webb <adrian.webb@coraltech.net>\nCoral Technology Group LLC"
14
- s.email = "adrian.webb@coraltech.net"
15
- s.extra_rdoc_files = [
16
- "LICENSE.txt",
17
- "README.rdoc"
18
- ]
12
+ s.date = "2015-02-15"
13
+ s.description = "This gem has been depreciated in favor of corl (https://github.com/coralnexus/corl). Do not use. No further development."
14
+ s.email = "adrian.webb@coraltechgroup.com"
15
+ s.extra_rdoc_files = []
19
16
  s.files = [
20
17
  ".document",
21
18
  "Gemfile",
@@ -25,48 +22,26 @@ Gem::Specification.new do |s|
25
22
  "Rakefile",
26
23
  "VERSION",
27
24
  "coral_plan.gemspec",
28
- "lib/coral_plan.rb",
29
- "lib/coral_plan/action.rb",
30
- "lib/coral_plan/base.rb",
31
- "lib/coral_plan/command.rb",
32
- "lib/coral_plan/event.rb",
33
- "spec/coral_test_kernel.rb",
34
- "spec/spec_helper.rb"
35
25
  ]
36
- s.homepage = "http://github.com/coraltech/ruby-coral_plan"
26
+ s.homepage = ""
37
27
  s.licenses = ["GPLv3"]
38
28
  s.rdoc_options = ["--title", "Coral Execution Plan library", "--main", "README.rdoc", "--line-numbers"]
39
29
  s.require_paths = ["lib"]
40
30
  s.required_ruby_version = Gem::Requirement.new(">= 1.8.1")
41
31
  s.rubyforge_project = "coral_plan"
42
32
  s.rubygems_version = "1.8.15"
43
- s.summary = "Provides the ability to create, load, execute, and save execution plans"
33
+ s.summary = "This gem has been depreciated in favor of corl (https://github.com/coralnexus/corl). Do not use. No further development."
44
34
 
45
35
  if s.respond_to? :specification_version then
46
36
  s.specification_version = 3
47
37
 
48
38
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
- s.add_runtime_dependency(%q<coral_core>, ["~> 0.1"])
50
- s.add_development_dependency(%q<bundler>, ["~> 1.2"])
51
- s.add_development_dependency(%q<jeweler>, ["~> 1.8"])
52
- s.add_development_dependency(%q<rspec>, ["~> 2.10"])
53
- s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
54
- s.add_development_dependency(%q<yard>, ["~> 0.8"])
39
+
55
40
  else
56
- s.add_dependency(%q<coral_core>, ["~> 0.1"])
57
- s.add_dependency(%q<bundler>, ["~> 1.2"])
58
- s.add_dependency(%q<jeweler>, ["~> 1.8"])
59
- s.add_dependency(%q<rspec>, ["~> 2.10"])
60
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
61
- s.add_dependency(%q<yard>, ["~> 0.8"])
41
+
62
42
  end
63
43
  else
64
- s.add_dependency(%q<coral_core>, ["~> 0.1"])
65
- s.add_dependency(%q<bundler>, ["~> 1.2"])
66
- s.add_dependency(%q<jeweler>, ["~> 1.8"])
67
- s.add_dependency(%q<rspec>, ["~> 2.10"])
68
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
69
- s.add_dependency(%q<yard>, ["~> 0.8"])
44
+
70
45
  end
71
46
  end
72
47
 
metadata CHANGED
@@ -1,171 +1,23 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: coral_plan
3
- version: !ruby/object:Gem::Version
4
- hash: 29
5
- prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 3
10
- version: 0.1.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Adrian Webb
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2013-03-14 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: coral_core
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
26
- - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 9
29
- segments:
30
- - 0
31
- - 1
32
- version: "0.1"
33
- type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: bundler
37
- prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ~>
42
- - !ruby/object:Gem::Version
43
- hash: 11
44
- segments:
45
- - 1
46
- - 2
47
- version: "1.2"
48
- type: :development
49
- version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
51
- name: jeweler
52
- prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
54
- none: false
55
- requirements:
56
- - - ~>
57
- - !ruby/object:Gem::Version
58
- hash: 31
59
- segments:
60
- - 1
61
- - 8
62
- version: "1.8"
63
- type: :development
64
- version_requirements: *id003
65
- - !ruby/object:Gem::Dependency
66
- name: rspec
67
- prerelease: false
68
- requirement: &id004 !ruby/object:Gem::Requirement
69
- none: false
70
- requirements:
71
- - - ~>
72
- - !ruby/object:Gem::Version
73
- hash: 23
74
- segments:
75
- - 2
76
- - 10
77
- version: "2.10"
78
- type: :development
79
- version_requirements: *id004
80
- - !ruby/object:Gem::Dependency
81
- name: rdoc
82
- prerelease: false
83
- requirement: &id005 !ruby/object:Gem::Requirement
84
- none: false
85
- requirements:
86
- - - ~>
87
- - !ruby/object:Gem::Version
88
- hash: 31
89
- segments:
90
- - 3
91
- - 12
92
- version: "3.12"
93
- type: :development
94
- version_requirements: *id005
95
- - !ruby/object:Gem::Dependency
96
- name: yard
97
- prerelease: false
98
- requirement: &id006 !ruby/object:Gem::Requirement
99
- none: false
100
- requirements:
101
- - - ~>
102
- - !ruby/object:Gem::Version
103
- hash: 27
104
- segments:
105
- - 0
106
- - 8
107
- version: "0.8"
108
- type: :development
109
- version_requirements: *id006
110
- description: |-
111
- = coral_plan
112
-
113
- This library provides the ability to create, load, execute, and save
114
- execution plans.
115
-
116
- The Coral Plan library contains a system that defines execution plans of
117
- CLI commands. The goal is to make it easy to create, edit, load, execute,
118
- and save these plans in a machine readable format (ie; JSON). The system
119
- is composed of Events, Commands, Actions, and of course Plans. There are a
120
- few simple rules:
121
-
122
- 1. All plans begin with a Command but may have more Commands defined
123
- that act in sequence unless there are errors with previous commands.
124
-
125
- 2. Commands can trigger Events of various types, where Events are reading
126
- and checking (ie; Regular expressions) Command output line by line.
127
-
128
- 3. Events have different criteria for measuring success and will have
129
- different fields. For example, a Regexp event contains a 'pattern'
130
- field.
131
-
132
- 4. Actions listen for Events and run Commands, with the ability to override
133
- default Command parameters. Actions may also generate Events on either
134
- successful execution or failure which can trigger other Actions.
135
-
136
- Note: This library is still very early in development!
137
-
138
- == Contributing to coral_plan
139
-
140
- * Check out the latest {major}.{minor} branch to make sure the feature hasn't
141
- been implemented or the bug hasn't been fixed yet.
142
- * Check out the issue tracker to make sure someone already hasn't requested
143
- it and/or contributed it.
144
- * Fork the project.
145
- * Start a feature/bugfix branch.
146
- * Commit and push until you are happy with your contribution.
147
- * Make sure to add tests for it. This is important so I don't break it in a
148
- future version unintentionally.
149
- * Please try not to mess with the Rakefile, version, or history. If you want
150
- to have your own version, or is otherwise necessary, that is fine, but
151
- please isolate to its own commit so I can cherry-pick around it.
152
-
153
- == Copyright
154
-
155
- Licensed under GPLv3. See LICENSE.txt for further details.
156
-
157
- Copyright (c) 2013 Adrian Webb <adrian.webb@coraltech.net>
158
- Coral Technology Group LLC
159
- email: adrian.webb@coraltech.net
11
+ date: 2015-02-15 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: This gem has been depreciated in favor of corl (https://github.com/coralnexus/corl). Do
14
+ not use. No further development.
15
+ email: adrian.webb@coraltechgroup.com
160
16
  executables: []
161
-
162
17
  extensions: []
163
-
164
- extra_rdoc_files:
165
- - LICENSE.txt
166
- - README.rdoc
167
- files:
168
- - .document
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".document"
169
21
  - Gemfile
170
22
  - Gemfile.lock
171
23
  - LICENSE.txt
@@ -173,52 +25,34 @@ files:
173
25
  - Rakefile
174
26
  - VERSION
175
27
  - coral_plan.gemspec
176
- - lib/coral_plan.rb
177
- - lib/coral_plan/action.rb
178
- - lib/coral_plan/base.rb
179
- - lib/coral_plan/command.rb
180
- - lib/coral_plan/event.rb
181
- - spec/coral_test_kernel.rb
182
- - spec/spec_helper.rb
183
- homepage: http://github.com/coraltech/ruby-coral_plan
184
- licenses:
28
+ homepage: ''
29
+ licenses:
185
30
  - GPLv3
31
+ metadata: {}
186
32
  post_install_message:
187
- rdoc_options:
188
- - --title
33
+ rdoc_options:
34
+ - "--title"
189
35
  - Coral Execution Plan library
190
- - --main
36
+ - "--main"
191
37
  - README.rdoc
192
- - --line-numbers
193
- require_paths:
38
+ - "--line-numbers"
39
+ require_paths:
194
40
  - lib
195
- required_ruby_version: !ruby/object:Gem::Requirement
196
- none: false
197
- requirements:
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
198
43
  - - ">="
199
- - !ruby/object:Gem::Version
200
- hash: 53
201
- segments:
202
- - 1
203
- - 8
204
- - 1
44
+ - !ruby/object:Gem::Version
205
45
  version: 1.8.1
206
- required_rubygems_version: !ruby/object:Gem::Requirement
207
- none: false
208
- requirements:
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
209
48
  - - ">="
210
- - !ruby/object:Gem::Version
211
- hash: 3
212
- segments:
213
- - 0
214
- version: "0"
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
215
51
  requirements: []
216
-
217
52
  rubyforge_project: coral_plan
218
- rubygems_version: 1.8.15
53
+ rubygems_version: 2.4.5
219
54
  signing_key:
220
55
  specification_version: 3
221
- summary: Provides the ability to create, load, execute, and save execution plans
56
+ summary: This gem has been depreciated in favor of corl (https://github.com/coralnexus/corl). Do
57
+ not use. No further development.
222
58
  test_files: []
223
-
224
- has_rdoc:
data/lib/coral_plan.rb DELETED
@@ -1,75 +0,0 @@
1
-
2
- home = File.dirname(__FILE__)
3
-
4
- $:.unshift(home) unless
5
- $:.include?(home) || $:.include?(File.expand_path(home))
6
-
7
- #-------------------------------------------------------------------------------
8
-
9
- require 'rubygems'
10
- require 'coral_core'
11
-
12
- #---
13
-
14
- # Include data model
15
- [ :event, :command, :action, :base ].each do |name|
16
- require File.join('coral_plan', name.to_s + '.rb')
17
- end
18
-
19
- #*******************************************************************************
20
- # Coral Execution Plan Library
21
- #
22
- # This provides the ability to create repeatable execution plans that can be
23
- # loaded from and stored into files, among other things...
24
- #
25
- # Author:: Adrian Webb (mailto:adrian.webb@coraltech.net)
26
- # License:: GPLv3
27
- module Coral
28
-
29
- #-----------------------------------------------------------------------------
30
- # Constructor / Destructor
31
-
32
- def self.create_plan(name, options = {})
33
- return Coral::Plan.create(name, options)
34
- end
35
-
36
- #---
37
-
38
- def self.delete_plan(name)
39
- return Coral::Plan.delete(name)
40
- end
41
-
42
- #-----------------------------------------------------------------------------
43
- # Accessors / Modifiers
44
-
45
- def self.plan(name)
46
- return Coral::Plan[name]
47
- end
48
-
49
- #*******************************************************************************
50
-
51
- module Plan
52
-
53
- VERSION = File.read(File.join(File.dirname(__FILE__), '..', 'VERSION'))
54
-
55
- #-----------------------------------------------------------------------------
56
- # Constructor / Destructor
57
-
58
- def self.create(name, options = {})
59
- return Coral::Plan::Base.create(name, options)
60
- end
61
-
62
- #---
63
-
64
- def self.delete(name)
65
- return Coral::Plan::Base.delete(name)
66
- end
67
-
68
- #-----------------------------------------------------------------------------
69
- # Accessors / Modifiers
70
-
71
- def self.[](name)
72
- return Coral::Plan::Base[name]
73
- end
74
- end
75
- end
@@ -1,167 +0,0 @@
1
-
2
- module Coral
3
- module Plan
4
- class Action < Core
5
-
6
- #-----------------------------------------------------------------------------
7
- # Constructor / Destructor
8
-
9
- def initialize(options = {})
10
- super(options)
11
- @plan = ( options.has_key?(:plan) ? options[:plan] : nil )
12
- @name = ( options.has_key?(:name) ? string(options[:name]) : '' )
13
- end
14
-
15
- #-----------------------------------------------------------------------------
16
- # Property accessors / modifiers
17
-
18
- attr_accessor :name
19
-
20
- #---
21
-
22
- def events
23
- events = {}
24
- @plan.action(@name, 'events', [], :array).each do |name|
25
- events[name] = @plan.events[name]
26
- end
27
- return events
28
- end
29
-
30
- #---
31
-
32
- def events=events
33
- @plan.set_action(@name, "events", events)
34
- end
35
-
36
- #---
37
-
38
- def commands
39
- commands = []
40
- @plan.action(@name, 'commands', [], :array).each do |name|
41
- commands << @plan.commands[name]
42
- end
43
- return commands
44
- end
45
-
46
- #---
47
-
48
- def commands=commands
49
- @plan.set_action(@name, "commands", commands)
50
- end
51
-
52
- #---
53
-
54
- def args
55
- return search('args', :array)
56
- end
57
-
58
- #---
59
-
60
- def args=args
61
- @plan.set_action(@name, "args", args)
62
- end
63
-
64
- #---
65
-
66
- def flags
67
- return search('flags', :array)
68
- end
69
-
70
- #---
71
-
72
- def flags=flags
73
- @plan.set_action(@name, "flags", flags)
74
- end
75
-
76
- #---
77
-
78
- def data
79
- return search('data', :hash)
80
- end
81
-
82
- #---
83
-
84
- def data=data
85
- @plan.set_action(@name, "data", data)
86
- end
87
-
88
- #---
89
-
90
- def next
91
- commands = []
92
- @plan.action(@name, 'next', [], :array).each do |name|
93
- commands << @plan.commands[name]
94
- end
95
- return commands
96
- end
97
-
98
- #---
99
-
100
- def next=commands
101
- @plan.set_action(@name, "next", commands)
102
- end
103
-
104
- #---
105
-
106
- def trigger_success
107
- return @plan.action('trigger_success', :array)
108
- end
109
-
110
- #---
111
-
112
- def trigger_success=event_names
113
- @plan.set_action(@name, "trigger_success", array(event_names))
114
- end
115
-
116
- #---
117
-
118
- def trigger_failure
119
- return @plan.action('trigger_failure', :array)
120
- end
121
-
122
- #---
123
-
124
- def trigger_failure=event_names
125
- @plan.set_action(@name, "trigger_failure", array(event_names))
126
- end
127
-
128
- #-----------------------------------------------------------------------------
129
- # Import / Export
130
-
131
- def export
132
- return symbol_map(@plan.action(@name))
133
- end
134
-
135
- #-----------------------------------------------------------------------------
136
- # Utilities
137
-
138
- def search(key, format = :array)
139
- action_info = @plan.action(@name)
140
- action_value = map(action_info[key])
141
-
142
- merged_value = {}
143
-
144
- commands.each do |command|
145
- command_info = command.export
146
- command_value = ( command_info[key] ? { command.name => filter(command_info[key], format) } : {} )
147
-
148
- merged_value[name] = Coral::Util::Data.merge([ action_value, command_value ], true)
149
- end
150
- return merged_value
151
- end
152
-
153
- #---
154
-
155
- def map(data)
156
- if data && ! data.is_a?(Hash)
157
- data_map = {}
158
- commands.each do |command|
159
- data_map[command.name] = array(data)
160
- end
161
- data = data_map
162
- end
163
- return data
164
- end
165
- end
166
- end
167
- end
@@ -1,281 +0,0 @@
1
-
2
- module Coral
3
- module Plan
4
-
5
- #*******************************************************************************
6
- # Errors
7
-
8
- class ExecuteError < StandardError
9
- end
10
-
11
- #*******************************************************************************
12
- # Base Plan definition
13
-
14
- class Base < Memory
15
-
16
- #-----------------------------------------------------------------------------
17
- # Properties
18
-
19
- @@instances = {}
20
-
21
- #-----------------------------------------------------------------------------
22
- # Constructor / Destructor
23
-
24
- def self.create(name, options = {})
25
- options[:name] = name unless options.has_key?(:name)
26
- @@instances[name] = new(options)
27
- return @@instances[name]
28
- end
29
-
30
- #---
31
-
32
- def self.delete(name)
33
- if @@instances.has_key?(name) && @@instances[name]
34
- @@instances.delete(name)
35
- end
36
- end
37
-
38
- #-----------------------------------------------------------------------------
39
-
40
- def self.[](name)
41
- if ! @@instances.has_key?(name) || ! @@instances[name]
42
- @@instances[name] = new({ :name => name })
43
- end
44
- return @@instances[name]
45
- end
46
-
47
- #-----------------------------------------------------------------------------
48
-
49
- def initialize(options = {})
50
- autoload = ( options.has_key?(:autoload) ? options[:autoload] : true )
51
-
52
- options[:autoload] = false
53
- super(options)
54
- @autoload = autoload
55
-
56
- self.home = ( options.has_key?(:home) && options[:home].is_a?(Coral::Repository) ? options[:home] : self )
57
-
58
- @start_commands = []
59
- @commands = {}
60
- @events = {}
61
- @actions = {}
62
-
63
- set_absolute_config_file
64
- load if @autoload
65
- end
66
-
67
- #-----------------------------------------------------------------------------
68
- # Property accessors / modifiers
69
-
70
- attr_reader :home
71
-
72
- #---
73
-
74
- def home=home
75
- if home && home.is_a?(Coral::Repository)
76
- @home = home
77
- set_repository(@home.directory, @submodule)
78
- end
79
- end
80
-
81
- #---
82
-
83
- def submodule=submodule
84
- set_repository(@home.directory, submodule)
85
- end
86
-
87
- #-----------------------------------------------------------------------------
88
-
89
- def start(reset = false)
90
- if reset || @start_commands.empty?
91
- @start_commands = []
92
- get('start', [], :array).each do |name|
93
- @start_commands << @commands[name]
94
- end
95
- end
96
- return @start_commands
97
- end
98
-
99
- #-----------------------------------------------------------------------------
100
-
101
- def commands(reset = false)
102
- if reset || @commands.empty?
103
- @commands = {}
104
- get('commands', {}, :hash).each do |name, command_info|
105
- command_info = Coral::Util::Data.merge([ {
106
- :plan => self,
107
- :name => name,
108
- }, symbol_map(command_info) ])
109
-
110
- @commands[name] = Coral::Plan::Command.new(command_info)
111
- end
112
- end
113
- return @commands
114
- end
115
-
116
- #---
117
-
118
- def set_commands(commands = {})
119
- return set('commands', events)
120
- end
121
-
122
- #---
123
-
124
- def command(name, key = nil, default = {}, format = false)
125
- return get_group('commands', name, key, default, format)
126
- end
127
-
128
- #---
129
-
130
- def set_command(name, key = nil, value = {})
131
- return set_group('commands', name, key, value)
132
- end
133
-
134
- #---
135
-
136
- def delete_command(name, key = nil)
137
- return delete_group('commands', name, key)
138
- end
139
-
140
- #-----------------------------------------------------------------------------
141
-
142
- def events(reset = false)
143
- if reset || @events.empty?
144
- @events = {}
145
- get('events', {}, :hash).each do |name, event_info|
146
- event_info = Coral::Util::Data.merge([ {
147
- :plan => self,
148
- :name => name,
149
- }, symbol_map(event_info) ])
150
-
151
- @events[name] = Coral::Plan::Event.instance(event_info)
152
- end
153
- end
154
- return @events
155
- end
156
-
157
- #---
158
-
159
- def set_events(events = {})
160
- return set('events', events)
161
- end
162
-
163
- #---
164
-
165
- def event(name, key = nil, default = {}, format = false)
166
- return get_group('events', name, key, default, format)
167
- end
168
-
169
- #---
170
-
171
- def set_event(name, key = nil, value = {})
172
- return set_group('events', name, key, value)
173
- end
174
-
175
- #---
176
-
177
- def delete_event(name, key = nil)
178
- return delete_group('events', name, key)
179
- end
180
-
181
- #-----------------------------------------------------------------------------
182
-
183
- def actions(reset = false)
184
- if reset || @actions.empty?
185
- @actions = {}
186
- get('actions', {}, :hash).each do |name, action_info|
187
- action_info = Coral::Util::Data.merge([ {
188
- :plan => self,
189
- :name => name,
190
- }, symbol_map(action_info) ])
191
-
192
- @actions[name] = Coral::Plan::Action.new(action_info)
193
- end
194
- end
195
- return @actions
196
- end
197
-
198
- #---
199
-
200
- def set_actions(actions = {})
201
- return set('actions', actions)
202
- end
203
-
204
- #---
205
-
206
- def action(name, key = nil, default = {}, format = false)
207
- return get_group('actions', name, key, default, format)
208
- end
209
-
210
- #---
211
-
212
- def set_action(name, key = nil, value = {})
213
- return set_group('actions', name, key, value)
214
- end
215
-
216
- #---
217
-
218
- def delete_action(name, key = nil)
219
- return delete_group('actions', name, key)
220
- end
221
-
222
- #-----------------------------------------------------------------------------
223
- # Configuration loading / saving
224
-
225
- def load
226
- super()
227
- commands(true)
228
- events(true)
229
- actions(true)
230
- return self
231
- end
232
-
233
- #-----------------------------------------------------------------------------
234
- # Execution
235
-
236
- def run(options)
237
- success = true
238
- start.each do |command|
239
- success = recursive_exec(command, options)
240
- break unless success
241
- end
242
- return success
243
- end
244
-
245
- #---
246
-
247
- def recursive_exec(command, options = {}, parent_action = nil)
248
- success = false
249
-
250
- options[:info_prefix] = 'info' unless options.has_key?(:info_prefix)
251
- options[:error_prefix] = 'error' unless options.has_key?(:error_prefix)
252
-
253
- begin
254
- triggered_events = command.exec(options, parent_action)
255
- rescue
256
- raise Coral::Plan::ExecuteError.new(command.name)
257
- end
258
-
259
- if triggered_events
260
- success = true
261
-
262
- unless triggered_events.empty?
263
- triggered_events.each do |event_name, event|
264
- actions.each do |action_name, action|
265
- if action.events.has_key?(event_name)
266
- action.commands.each do |subcommand|
267
- success = recursive_exec(subcommand, options, action)
268
- break unless success
269
- end
270
- end
271
- break unless success
272
- end
273
- break unless success
274
- end
275
- end
276
- end
277
- return success
278
- end
279
- end
280
- end
281
- end
@@ -1,188 +0,0 @@
1
-
2
- module Coral
3
- module Plan
4
- class Command < Command
5
-
6
- #-----------------------------------------------------------------------------
7
- # Constructor / Destructor
8
-
9
- def initialize(options = {})
10
- super(options)
11
- @plan = ( options.has_key?(:plan) ? options[:plan] : nil )
12
- end
13
-
14
- #-----------------------------------------------------------------------------
15
- # Property accessors / modifiers
16
-
17
- def command=command
18
- super(command)
19
- @plan.set_command(@name, "command", command) if @plan
20
- end
21
-
22
- #---
23
-
24
- def vagrant=command
25
- super(command)
26
- @plan.set_command(@name, "vagrant", command) if @plan
27
- end
28
-
29
- #---
30
-
31
- def cloud=command
32
- super(command)
33
- @plan.set_command(@name, "cloud", command) if @plan
34
- end
35
-
36
- #---
37
-
38
- def args=args
39
- super(args)
40
- @plan.set_command(@name, "args", @properties[:args]) if @plan
41
- end
42
-
43
- #---
44
-
45
- def flags=flags
46
- super(flags)
47
- @plan.set_command(@name, "flags", @properties[:flags]) if @plan
48
- end
49
-
50
- #---
51
-
52
- def data=data
53
- super(data)
54
- @plan.set_command(@name, "data", @properties[:data]) if @plan
55
- end
56
-
57
- #---
58
-
59
- def subcommand=subcommand
60
- super(subcommand)
61
- @plan.set_command(@name, "subcommand", @properties[:subcommand]) if @plan
62
- end
63
-
64
- #---
65
-
66
- def events
67
- events = {}
68
- if @plan
69
- event_types = @plan.command(@name, 'events', [], :array)
70
- @plan.events.each do |name, event|
71
- if event_types.include?(event.type)
72
- events[name] = @plan.events[name]
73
- end
74
- end
75
- end
76
- return events
77
- end
78
-
79
- #---
80
-
81
- def events=events
82
- @plan.set_command(@name, "events", events) if @plan
83
- end
84
-
85
- #-----------------------------------------------------------------------------
86
- # Command functions
87
-
88
- def build(components = {}, overrides = nil, override_key = false)
89
- if overrides && ! overrides.empty?
90
- overrides = translate_events(overrides)
91
- end
92
- return super(translate_events(components), overrides, override_key)
93
- end
94
-
95
- #---
96
-
97
- def exec!(options = {}, action = nil)
98
- triggered_events = {}
99
- action_info = action
100
-
101
- if action && ! action.is_a?(Hash)
102
- action_info = action.export
103
- end
104
-
105
- success = super(options, action_info) do |line|
106
- result = true
107
- prefix = false
108
-
109
- if @plan
110
- @plan.events.each do |name, event|
111
- if events.has_key?(name) && event.check(line)
112
- prefix = 'EVENT'
113
- triggered_events[name] = event
114
- end
115
- end
116
- end
117
-
118
- if block_given?
119
- result = yield(line)
120
-
121
- if result && result.is_a?(Hash)
122
- result = result[:success]
123
- end
124
- end
125
- prefix ? { :success => result, :prefix => prefix } : result
126
- end
127
-
128
- if @plan && action
129
- if success
130
- action.trigger_success.each do |name|
131
- triggered_events[name] = @plan.events[name]
132
- end
133
- else
134
- action.trigger_failure.each do |name|
135
- triggered_events[name] = @plan.events[name]
136
- end
137
- end
138
- end
139
-
140
- return ( success ? triggered_events : nil )
141
- end
142
-
143
- #-----------------------------------------------------------------------------
144
- # Utilities
145
-
146
- def translate_events(data, options = [ :exit ])
147
- if @plan && data && data.is_a?(Hash) && data.has_key?(:data)
148
- data[:data].each do |key, value|
149
- # Action with command specific overrides
150
- if value.is_a?(Hash)
151
- value.each do |sub_key, sub_value|
152
- if options.include?(sub_key) && @plan.command(key, 'coral', false)
153
- events = []
154
- array(sub_value.split(',')).each do |event_name|
155
- if @plan.events.has_key?(event_name)
156
- events << @plan.events[event_name].export
157
- else
158
- events << event_name
159
- end
160
- end
161
- data[:data][key][sub_key] = events.join(',')
162
- end
163
- end
164
- # Command or Action with overrides for all commands
165
- elsif options.include?(key)
166
- if data.has_key?(:commands)
167
- array(data[:commands]).each do |command_name|
168
- return data unless @plan.command(command_name, 'coral', false)
169
- end
170
- end
171
-
172
- events = []
173
- array(value.split(',')).each do |event_name|
174
- if @plan.events.has_key?(event_name)
175
- events << @plan.events[event_name].export
176
- else
177
- events << event_name
178
- end
179
- end
180
- data[:data][key] = events.join(',')
181
- end
182
- end
183
- end
184
- return data
185
- end
186
- end
187
- end
188
- end
@@ -1,69 +0,0 @@
1
-
2
- module Coral
3
- module Plan
4
- class Event < Event
5
-
6
- #-----------------------------------------------------------------------------
7
- # Constructor / Destructor
8
-
9
- def self.instance(options = {}, build_hash = false, keep_array = false)
10
- return instance!(options, build_hash, keep_array) do |type, info|
11
- type == :plan ? info[:object] : create(type, info)
12
- end
13
- end
14
-
15
- #---
16
-
17
- def initialize(options = {})
18
- super(options)
19
- @plan = ( options.has_key?(:plan) ? options[:plan] : nil )
20
- end
21
-
22
- #-----------------------------------------------------------------------------
23
- # Property accessors / modifiers
24
-
25
- def set_properties(data)
26
- super(data)
27
- @plan.set_event(@name, nil, @properties) if @plan
28
- return self
29
- end
30
-
31
- #---
32
-
33
- def set_property(name, value)
34
- super(data)
35
- @plan.set_event(@name, name, @properties[name]) if @plan
36
- return self
37
- end
38
-
39
- #-----------------------------------------------------------------------------
40
- # Utilities
41
-
42
- def self.build_info(data = {})
43
- return build_info!(data) do |element|
44
- event = {}
45
-
46
- case element
47
- when String
48
- if @plan && @plan.events.has_key?(element)
49
- event[:type] = :plan
50
- event[:object] = @plan.events[element]
51
- else
52
- event = split_event_string(element)
53
- end
54
- when Hash
55
- event = element
56
- end
57
-
58
- if @plan
59
- event[:delegate] = self.new({
60
- :name => element[:name],
61
- :plan => @plan,
62
- })
63
- end
64
- event
65
- end
66
- end
67
- end
68
- end
69
- end
@@ -1,22 +0,0 @@
1
-
2
- module Kernel
3
-
4
- #-----------------------------------------------------------------------------
5
- # Utilities
6
-
7
- def capture
8
- out = StringIO.new
9
- $stdout = out
10
-
11
- error = StringIO.new
12
- $stderr = error
13
-
14
- # Go do stuff!
15
- yield
16
- return out, error
17
-
18
- ensure
19
- $stdout = STDOUT
20
- $stderr = STDERR
21
- end
22
- end
data/spec/spec_helper.rb DELETED
@@ -1,14 +0,0 @@
1
-
2
- require 'rspec'
3
- require 'stringio'
4
- require 'coral_plan'
5
-
6
- require 'coral_test_kernel'
7
-
8
- #-------------------------------------------------------------------------------
9
-
10
- RSpec.configure do |config|
11
- config.mock_framework = :rspec
12
- config.color_enabled = true
13
- config.formatter = 'documentation'
14
- end