coral_core 0.2.19 → 0.2.21

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coral_core
3
3
  version: !ruby/object:Gem::Version
4
- hash: 49
4
+ hash: 61
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 19
10
- version: 0.2.19
9
+ - 21
10
+ version: 0.2.21
11
11
  platform: ruby
12
12
  authors:
13
13
  - Adrian Webb
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-05-14 00:00:00 Z
18
+ date: 2013-05-17 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: log4r
@@ -196,42 +196,8 @@ extra_rdoc_files:
196
196
  - LICENSE.txt
197
197
  - README.rdoc
198
198
  files:
199
- - .document
200
- - .gitmodules
201
- - Gemfile
202
- - Gemfile.lock
203
199
  - LICENSE.txt
204
200
  - README.rdoc
205
- - Rakefile
206
- - VERSION
207
- - coral_core.gemspec
208
- - lib/coral_core.rb
209
- - lib/coral_core/command.rb
210
- - lib/coral_core/config.rb
211
- - lib/coral_core/core.rb
212
- - lib/coral_core/event.rb
213
- - lib/coral_core/event/regexp_event.rb
214
- - lib/coral_core/interface.rb
215
- - lib/coral_core/memory.rb
216
- - lib/coral_core/repository.rb
217
- - lib/coral_core/resource.rb
218
- - lib/coral_core/template.rb
219
- - lib/coral_core/template/environment.rb
220
- - lib/coral_core/template/json.rb
221
- - lib/coral_core/template/wrapper.rb
222
- - lib/coral_core/template/yaml.rb
223
- - lib/coral_core/util/data.rb
224
- - lib/coral_core/util/disk.rb
225
- - lib/coral_core/util/git.rb
226
- - lib/coral_core/util/git/base.rb
227
- - lib/coral_core/util/git/lib.rb
228
- - lib/coral_core/util/git/remote.rb
229
- - lib/coral_core/util/shell.rb
230
- - lib/hiera_backend.rb
231
- - spec/coral_core/interface_spec.rb
232
- - spec/coral_mock_input.rb
233
- - spec/coral_test_kernel.rb
234
- - spec/spec_helper.rb
235
201
  homepage: http://github.com/coraltech/ruby-coral_core
236
202
  licenses:
237
203
  - GPLv3
data/.document DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- LICENSE.txt
data/.gitmodules DELETED
@@ -1,12 +0,0 @@
1
- [submodule "lib/dependency/git"]
2
- path = lib/dependency/git
3
- url = git://github.com/schacon/ruby-git.git
4
- [submodule "lib/dependency/json"]
5
- path = lib/dependency/json
6
- url = git://github.com/flori/json.git
7
- [submodule "lib/dependency/log4r"]
8
- path = lib/dependency/log4r
9
- url = git://github.com/colbygk/log4r.git
10
- [submodule "lib/dependency/deep_merge"]
11
- path = lib/dependency/deep_merge
12
- url = git://github.com/danielsdeleo/deep_merge.git
data/Gemfile DELETED
@@ -1,14 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- gem "log4r", "~> 1.1"
4
- gem "deep_merge", "~> 1.0"
5
- gem "json", ">= 1.4"
6
- gem "git", "= 1.2.5"
7
-
8
- group :development do
9
- gem "bundler", "~> 1.2"
10
- gem "jeweler", "~> 1.8"
11
- gem "rspec", "~> 2.10"
12
- gem "rdoc", "~> 3.12"
13
- gem "yard", "~> 0.8"
14
- end
data/Gemfile.lock DELETED
@@ -1,39 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- deep_merge (1.0.0)
5
- diff-lcs (1.2.4)
6
- git (1.2.5)
7
- jeweler (1.8.4)
8
- bundler (~> 1.0)
9
- git (>= 1.2.5)
10
- rake
11
- rdoc
12
- json (1.8.0)
13
- log4r (1.1.10)
14
- rake (10.0.4)
15
- rdoc (3.12.2)
16
- json (~> 1.4)
17
- rspec (2.13.0)
18
- rspec-core (~> 2.13.0)
19
- rspec-expectations (~> 2.13.0)
20
- rspec-mocks (~> 2.13.0)
21
- rspec-core (2.13.1)
22
- rspec-expectations (2.13.0)
23
- diff-lcs (>= 1.1.3, < 2.0)
24
- rspec-mocks (2.13.1)
25
- yard (0.8.6.1)
26
-
27
- PLATFORMS
28
- ruby
29
-
30
- DEPENDENCIES
31
- bundler (~> 1.2)
32
- deep_merge (~> 1.0)
33
- git (= 1.2.5)
34
- jeweler (~> 1.8)
35
- json (>= 1.4)
36
- log4r (~> 1.1)
37
- rdoc (~> 3.12)
38
- rspec (~> 2.10)
39
- yard (~> 0.8)
data/Rakefile DELETED
@@ -1,77 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'rubygems'
4
- require 'rake'
5
- require 'bundler'
6
- require 'jeweler'
7
- require 'rspec/core/rake_task'
8
- require 'rdoc/task'
9
- require 'yard'
10
-
11
- require './lib/coral_core.rb'
12
-
13
- #-------------------------------------------------------------------------------
14
- # Dependencies
15
-
16
- begin
17
- Bundler.setup(:default, :development)
18
- rescue Bundler::BundlerError => e
19
- $stderr.puts e.message
20
- $stderr.puts "Run `bundle install` to install missing gems"
21
- exit e.status_code
22
- end
23
-
24
- #-------------------------------------------------------------------------------
25
- # Gem specification
26
-
27
- Jeweler::Tasks.new do |gem|
28
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
29
- gem.name = "coral_core"
30
- gem.homepage = "http://github.com/coraltech/ruby-coral_core"
31
- gem.rubyforge_project = 'coral_core'
32
- gem.license = "GPLv3"
33
- gem.email = "adrian.webb@coraltech.net"
34
- gem.authors = ["Adrian Webb"]
35
- gem.summary = %Q{Provides core data elements and utilities used in other Coral gems}
36
- gem.description = File.read('README.rdoc')
37
- gem.required_ruby_version = '>= 1.8.1'
38
- gem.has_rdoc = true
39
- gem.rdoc_options << '--title' << 'Coral Core library' <<
40
- '--main' << 'README.rdoc' <<
41
- '--line-numbers'
42
-
43
- # Dependencies defined in Gemfile
44
- end
45
-
46
- Jeweler::RubygemsDotOrgTasks.new
47
-
48
- #-------------------------------------------------------------------------------
49
- # Testing
50
-
51
- RSpec::Core::RakeTask.new(:spec, :tag) do |spec, task_args|
52
- options = []
53
- options << "--tag #{task_args[:tag]}" if task_args.is_a?(Array) && ! task_args[:tag].to_s.empty?
54
- spec.rspec_opts = options.join(' ')
55
- end
56
-
57
- task :default => :spec
58
-
59
- #-------------------------------------------------------------------------------
60
- # Documentation
61
-
62
- version = Coral::VERSION
63
- doc_title = "coral_core #{version}"
64
-
65
- Rake::RDocTask.new do |rdoc|
66
- rdoc.rdoc_dir = 'rdoc'
67
- rdoc.title = doc_title
68
- rdoc.rdoc_files.include('README*')
69
- rdoc.rdoc_files.include('lib/**/*.rb')
70
- end
71
-
72
- #---
73
-
74
- YARD::Rake::YardocTask.new do |ydoc|
75
- ydoc.files = [ 'README*', 'lib/**/*.rb' ]
76
- ydoc.options = [ "--output-dir yardoc", "--title '#{doc_title}'" ]
77
- end
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.2.19
data/coral_core.gemspec DELETED
@@ -1,102 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = "coral_core"
8
- s.version = "0.2.19"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Adrian Webb"]
12
- s.date = "2013-05-14"
13
- s.description = "= coral_core\n\nThis library provides core data elements and utilities used in other Coral gems.\n\nThe Coral core library contains functionality that is utilized by other\nCoral gems by providing basic utilities like Git, Shell, Disk, and Data\nmanipulation libraries, a UI system, and a core data model that supports\nEvents, Commands, Repositories, and Memory (version controlled JSON \nobjects). This library is only used as a starting point for other systems.\n\nNote: This library is still very early in development!\n\n== Contributing to coral_core\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
- ]
19
- s.files = [
20
- ".document",
21
- ".gitmodules",
22
- "Gemfile",
23
- "Gemfile.lock",
24
- "LICENSE.txt",
25
- "README.rdoc",
26
- "Rakefile",
27
- "VERSION",
28
- "coral_core.gemspec",
29
- "lib/coral_core.rb",
30
- "lib/coral_core/command.rb",
31
- "lib/coral_core/config.rb",
32
- "lib/coral_core/core.rb",
33
- "lib/coral_core/event.rb",
34
- "lib/coral_core/event/regexp_event.rb",
35
- "lib/coral_core/interface.rb",
36
- "lib/coral_core/memory.rb",
37
- "lib/coral_core/repository.rb",
38
- "lib/coral_core/resource.rb",
39
- "lib/coral_core/template.rb",
40
- "lib/coral_core/template/environment.rb",
41
- "lib/coral_core/template/json.rb",
42
- "lib/coral_core/template/wrapper.rb",
43
- "lib/coral_core/template/yaml.rb",
44
- "lib/coral_core/util/data.rb",
45
- "lib/coral_core/util/disk.rb",
46
- "lib/coral_core/util/git.rb",
47
- "lib/coral_core/util/git/base.rb",
48
- "lib/coral_core/util/git/lib.rb",
49
- "lib/coral_core/util/git/remote.rb",
50
- "lib/coral_core/util/shell.rb",
51
- "lib/hiera_backend.rb",
52
- "spec/coral_core/interface_spec.rb",
53
- "spec/coral_mock_input.rb",
54
- "spec/coral_test_kernel.rb",
55
- "spec/spec_helper.rb"
56
- ]
57
- s.homepage = "http://github.com/coraltech/ruby-coral_core"
58
- s.licenses = ["GPLv3"]
59
- s.rdoc_options = ["--title", "Coral Core library", "--main", "README.rdoc", "--line-numbers"]
60
- s.require_paths = ["lib"]
61
- s.required_ruby_version = Gem::Requirement.new(">= 1.8.1")
62
- s.rubyforge_project = "coral_core"
63
- s.rubygems_version = "1.8.15"
64
- s.summary = "Provides core data elements and utilities used in other Coral gems"
65
-
66
- if s.respond_to? :specification_version then
67
- s.specification_version = 3
68
-
69
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
70
- s.add_runtime_dependency(%q<log4r>, ["~> 1.1"])
71
- s.add_runtime_dependency(%q<deep_merge>, ["~> 1.0"])
72
- s.add_runtime_dependency(%q<json>, [">= 1.4"])
73
- s.add_runtime_dependency(%q<git>, ["= 1.2.5"])
74
- s.add_development_dependency(%q<bundler>, ["~> 1.2"])
75
- s.add_development_dependency(%q<jeweler>, ["~> 1.8"])
76
- s.add_development_dependency(%q<rspec>, ["~> 2.10"])
77
- s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
78
- s.add_development_dependency(%q<yard>, ["~> 0.8"])
79
- else
80
- s.add_dependency(%q<log4r>, ["~> 1.1"])
81
- s.add_dependency(%q<deep_merge>, ["~> 1.0"])
82
- s.add_dependency(%q<json>, [">= 1.4"])
83
- s.add_dependency(%q<git>, ["= 1.2.5"])
84
- s.add_dependency(%q<bundler>, ["~> 1.2"])
85
- s.add_dependency(%q<jeweler>, ["~> 1.8"])
86
- s.add_dependency(%q<rspec>, ["~> 2.10"])
87
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
88
- s.add_dependency(%q<yard>, ["~> 0.8"])
89
- end
90
- else
91
- s.add_dependency(%q<log4r>, ["~> 1.1"])
92
- s.add_dependency(%q<deep_merge>, ["~> 1.0"])
93
- s.add_dependency(%q<json>, [">= 1.4"])
94
- s.add_dependency(%q<git>, ["= 1.2.5"])
95
- s.add_dependency(%q<bundler>, ["~> 1.2"])
96
- s.add_dependency(%q<jeweler>, ["~> 1.8"])
97
- s.add_dependency(%q<rspec>, ["~> 2.10"])
98
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
99
- s.add_dependency(%q<yard>, ["~> 0.8"])
100
- end
101
- end
102
-
@@ -1,244 +0,0 @@
1
-
2
- module Coral
3
- class Command < Core
4
-
5
- #-----------------------------------------------------------------------------
6
- # Properties
7
-
8
- attr_accessor :name
9
- attr_reader :subcommand
10
-
11
- #-----------------------------------------------------------------------------
12
- # Constructor / Destructor
13
-
14
- def initialize(options = {})
15
-
16
- if options.is_a?(String) || options.is_a?(Symbol)
17
- options = string(options)
18
- options = { :name => options, :command => options }
19
- end
20
-
21
- config = Config.ensure(options)
22
-
23
- super(config)
24
-
25
- @properties = {}
26
-
27
- self.subcommand = config.get(:subcommand, nil)
28
-
29
- @name = config.get(:name, '')
30
-
31
- @properties = config.options
32
- @properties[:command] = executable(config)
33
- end
34
-
35
- #-----------------------------------------------------------------------------
36
- # Property accessors / modifiers
37
-
38
- def command_base
39
- return @properties[:command]
40
- end
41
-
42
- #---
43
-
44
- def command=command
45
- @properties[:command] = executable({ :command => command })
46
- end
47
-
48
- #---
49
-
50
- def vagrant=command
51
- @properties[:command] = executable({ :vagrant => command })
52
- end
53
-
54
- #---
55
-
56
- def coral=command
57
- @properties[:command] = executable({ :coral => command })
58
- end
59
-
60
- #---
61
-
62
- def args
63
- return array(@properties[:args])
64
- end
65
-
66
- #---
67
-
68
- def args=args
69
- @properties[:args] = array(args)
70
- end
71
-
72
- #---
73
-
74
- def flags
75
- return array(@properties[:flags])
76
- end
77
-
78
- #---
79
-
80
- def flags=flags
81
- @properties[:flags] = array(flags)
82
- end
83
-
84
- #---
85
-
86
- def data
87
- return hash(@properties[:data])
88
- end
89
-
90
- #---
91
-
92
- def data=data
93
- @properties[:data] = hash(data)
94
- end
95
-
96
- #---
97
-
98
- def subcommand=subcommand
99
- unless Util::Data.empty?(subcommand)
100
- @properties[:subcommand] = hash(subcommand)
101
- @subcommand = self.class.new(@properties[:subcommand])
102
- end
103
- end
104
-
105
- #-----------------------------------------------------------------------------
106
- # Import / Export
107
-
108
- def export
109
- return symbol_map(@properties)
110
- end
111
-
112
- #-----------------------------------------------------------------------------
113
- # Command functions
114
-
115
- def build(components = {}, overrides = nil, override_key = false)
116
-
117
- command = string(components[:command])
118
- flags = array( components.has_key?(:flags) ? components[:flags] : [] )
119
- data = string_map(hash( components.has_key?(:data) ? components[:data] : {} ))
120
- args = array( components.has_key?(:args) ? components[:args] : [] )
121
- subcommand = hash( components.has_key?(:subcommand) ? components[:subcommand] : {} )
122
-
123
- override_key = command unless override_key
124
- override_key = override_key.to_sym
125
-
126
- command_string = command.dup
127
- subcommand_string = ''
128
-
129
- escape_characters = /[\'\"]+/
130
- escape_replacement = '\"'
131
-
132
- dash_pattern = /^([\-]+)/
133
- assignment_pattern = /\=$/
134
-
135
- # Flags
136
- if overrides && overrides.has_key?(:flags)
137
- if overrides[:flags].is_a?(Hash)
138
- if overrides[:flags].has_key?(override_key)
139
- flags = array(overrides[:flags][override_key])
140
- end
141
- else
142
- flags = array(overrides[:flags])
143
- end
144
- end
145
- flags.each do |flag|
146
- flag = string(flag)
147
- if ! flag.empty?
148
- if flag.match(dash_pattern)
149
- dashes = $1
150
- else
151
- dashes = ( flag.size == 1 ? '-' : '--' )
152
- end
153
- command_string << " #{dashes}#{flag}"
154
- end
155
- end
156
-
157
- # Data
158
- if overrides && overrides.has_key?(:data)
159
- if overrides[:data].has_key?(override_key)
160
- data = hash(overrides[:data][override_key])
161
- else
162
- override = true
163
- overrides[:data].each do |key, value|
164
- if ! value.is_a?(String)
165
- override = false
166
- end
167
- end
168
- data = hash(overrides[:data]) if override
169
- end
170
- end
171
- data.each do |key, value|
172
- key = string(key)
173
- value = string(value).strip.sub(escape_characters, escape_replacement)
174
-
175
- if key.match(dash_pattern)
176
- dashes = $1
177
- else
178
- dashes = ( key.size == 1 ? '-' : '--' )
179
- end
180
- space = ( key.match(assignment_pattern) ? '' : ' ' )
181
-
182
- command_string << " #{dashes}#{key}#{space}'#{value}'"
183
- end
184
-
185
- # Arguments
186
- if overrides && overrides.has_key?(:args)
187
- if overrides[:args].is_a?(Hash)
188
- if overrides[:args].has_key?(override_key)
189
- args = array(overrides[:args][override_key])
190
- end
191
- else
192
- args = array(overrides[:args])
193
- end
194
- end
195
- args.each do |arg|
196
- arg = string(arg).sub(escape_characters, escape_replacement)
197
- command_string << " '#{arg}'"
198
- end
199
-
200
- # Subcommand
201
- subcommand_overrides = ( overrides ? overrides[:subcommand] : nil )
202
- if subcommand && subcommand.is_a?(Hash) && ! subcommand.empty?
203
- subcommand_string = build(subcommand, subcommand_overrides)
204
- end
205
-
206
- return (command_string + ' ' + subcommand_string).strip
207
- end
208
-
209
- #-----------------------------------------------------------------------------
210
-
211
- def exec!(options = {}, overrides = nil)
212
- config = Config.ensure(options)
213
-
214
- config[:ui] = @ui
215
- success = Coral::Util::Shell.exec!(build(export, overrides), config) do |line|
216
- block_given? ? yield(line) : true
217
- end
218
- return success
219
- end
220
-
221
- #---
222
-
223
- def exec(options = {}, overrides = nil)
224
- return exec!(options, overrides)
225
- end
226
-
227
- #-----------------------------------------------------------------------------
228
- # Utilities
229
-
230
- def executable(options)
231
- config = Config.ensure(options)
232
-
233
- if config.get(:coral, false)
234
- return 'vagrant coral ' + config[:coral]
235
-
236
- elsif config.get(:vagrant, false)
237
- return 'vagrant ' + config[:vagrant]
238
-
239
- elsif config.get(:command, false)
240
- return config[:command]
241
- end
242
- end
243
- end
244
- end