coral_core 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitmodules +9 -0
- data/VERSION +1 -1
- data/coral_core.gemspec +2 -1
- data/lib/coral_core/interface.rb +1 -1
- data/lib/coral_core/util/data.rb +5 -3
- data/lib/coral_core.rb +110 -27
- metadata +4 -3
data/.gitmodules
ADDED
@@ -0,0 +1,9 @@
|
|
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
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.7
|
data/coral_core.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "coral_core"
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.7"
|
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"]
|
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
|
+
".gitmodules",
|
21
22
|
"Gemfile",
|
22
23
|
"Gemfile.lock",
|
23
24
|
"LICENSE.txt",
|
data/lib/coral_core/interface.rb
CHANGED
data/lib/coral_core/util/data.rb
CHANGED
@@ -50,9 +50,9 @@ class Data
|
|
50
50
|
def self.to_json(data)
|
51
51
|
output = ''
|
52
52
|
begin
|
53
|
-
require 'json'
|
54
53
|
output = data.to_json
|
55
|
-
|
54
|
+
|
55
|
+
rescue Exception
|
56
56
|
end
|
57
57
|
return output
|
58
58
|
end
|
@@ -64,7 +64,8 @@ class Data
|
|
64
64
|
begin
|
65
65
|
require 'yaml'
|
66
66
|
output = YAML.dump(data)
|
67
|
-
|
67
|
+
|
68
|
+
rescue Exception
|
68
69
|
end
|
69
70
|
return output
|
70
71
|
end
|
@@ -116,6 +117,7 @@ class Data
|
|
116
117
|
begin
|
117
118
|
require 'deep_merge'
|
118
119
|
value = force ? value.deep_merge!(item) : value.deep_merge(item)
|
120
|
+
|
119
121
|
rescue LoadError
|
120
122
|
if item.is_a?(Hash) # Non recursive top level by default.
|
121
123
|
value = value.merge(item)
|
data/lib/coral_core.rb
CHANGED
@@ -1,24 +1,111 @@
|
|
1
1
|
|
2
|
-
|
2
|
+
#*******************************************************************************
|
3
|
+
# Coral Core Library
|
4
|
+
#
|
5
|
+
# This provides core data elements and utilities used in the Coral gems.
|
6
|
+
#
|
7
|
+
# Author:: Adrian Webb (mailto:adrian.webb@coraltech.net)
|
8
|
+
# License:: GPLv3
|
3
9
|
|
4
|
-
|
5
|
-
|
10
|
+
#-------------------------------------------------------------------------------
|
11
|
+
# Global namespace
|
12
|
+
|
13
|
+
module Kernel
|
14
|
+
|
15
|
+
def dbg(data, label = '')
|
16
|
+
require 'pp'
|
17
|
+
|
18
|
+
puts '>>----------------------'
|
19
|
+
unless label.empty?
|
20
|
+
puts label
|
21
|
+
puts '---'
|
22
|
+
end
|
23
|
+
pp data
|
24
|
+
puts '<<'
|
25
|
+
end
|
6
26
|
|
27
|
+
#---
|
28
|
+
|
29
|
+
def locate(command)
|
30
|
+
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
31
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
32
|
+
exts.each do |ext|
|
33
|
+
exe = File.join(path, "#{command}#{ext}")
|
34
|
+
return exe if File.executable?(exe)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
return nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
7
41
|
#-------------------------------------------------------------------------------
|
42
|
+
# Properties and
|
43
|
+
|
44
|
+
home = File.dirname(__FILE__)
|
45
|
+
dependencies = File.join(home, 'dependency')
|
46
|
+
|
47
|
+
git_location = locate('git')
|
48
|
+
|
49
|
+
#-------------------------------------------------------------------------------
|
50
|
+
|
51
|
+
$:.unshift(home) unless
|
52
|
+
$:.include?(home) || $:.include?(File.expand_path(home))
|
53
|
+
|
54
|
+
#---
|
8
55
|
|
9
56
|
require 'rubygems'
|
10
57
|
require 'hiera_backend.rb'
|
11
58
|
|
12
59
|
#---
|
13
60
|
|
14
|
-
|
15
|
-
|
16
|
-
|
61
|
+
begin
|
62
|
+
require 'log4r'
|
63
|
+
|
64
|
+
rescue LoadError
|
65
|
+
log4r_lib = File.join(dependencies, 'log4r', 'lib')
|
66
|
+
|
67
|
+
$:.push(log4r_lib)
|
68
|
+
require File.join(log4r_lib, 'log4r.rb')
|
17
69
|
end
|
18
70
|
|
19
|
-
|
20
|
-
|
21
|
-
|
71
|
+
#---
|
72
|
+
|
73
|
+
begin
|
74
|
+
require 'json'
|
75
|
+
|
76
|
+
rescue LoadError
|
77
|
+
json_lib = File.join(dependencies, 'json', 'lib')
|
78
|
+
|
79
|
+
$:.push(json_lib)
|
80
|
+
require File.join(json_lib, 'json.rb')
|
81
|
+
end
|
82
|
+
|
83
|
+
#---
|
84
|
+
|
85
|
+
if git_location
|
86
|
+
begin
|
87
|
+
require 'git'
|
88
|
+
|
89
|
+
rescue LoadError
|
90
|
+
git_lib = File.join(dependencies, 'git', 'lib')
|
91
|
+
|
92
|
+
$:.push(git_lib)
|
93
|
+
require File.join(git_lib, 'git.rb')
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
#---
|
98
|
+
|
99
|
+
# Include pre core utilities (no internal dependencies)
|
100
|
+
require File.join('coral_core', 'util', 'data.rb')
|
101
|
+
|
102
|
+
if git_location
|
103
|
+
require File.join('coral_core', 'util', 'git.rb')
|
104
|
+
|
105
|
+
# Include Git overrides
|
106
|
+
Dir.glob(File.join(home, 'coral_core', 'util', 'git', '*.rb')).each do |file|
|
107
|
+
require file
|
108
|
+
end
|
22
109
|
end
|
23
110
|
|
24
111
|
# Include core
|
@@ -35,15 +122,26 @@ end
|
|
35
122
|
end
|
36
123
|
|
37
124
|
# Include data model
|
38
|
-
[ :event, :command
|
125
|
+
[ :event, :command ].each do |name|
|
39
126
|
require File.join('coral_core', name.to_s + ".rb")
|
40
127
|
end
|
41
128
|
|
129
|
+
if git_location
|
130
|
+
[ :repository, :memory ].each do |name|
|
131
|
+
require File.join('coral_core', name.to_s + ".rb")
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
42
135
|
# Include specialized events
|
43
136
|
Dir.glob(File.join(home, 'coral_core', 'event', '*.rb')).each do |file|
|
44
137
|
require file
|
45
138
|
end
|
46
139
|
|
140
|
+
# Include bundled templates
|
141
|
+
Dir.glob(File.join(home, 'coral_core', 'template', '*.rb')).each do |file|
|
142
|
+
require file
|
143
|
+
end
|
144
|
+
|
47
145
|
#*******************************************************************************
|
48
146
|
# Coral Core Library
|
49
147
|
#
|
@@ -59,6 +157,8 @@ module Coral
|
|
59
157
|
|
60
158
|
@@ui = Coral::Core.ui
|
61
159
|
|
160
|
+
#---
|
161
|
+
|
62
162
|
def self.ui
|
63
163
|
return @@ui
|
64
164
|
end
|
@@ -110,23 +210,6 @@ module Coral
|
|
110
210
|
ui.warning(Util::Data.to_yaml(error.backtrace))
|
111
211
|
raise
|
112
212
|
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
#-------------------------------------------------------------------------------
|
117
|
-
# Global namespace
|
118
|
-
|
119
|
-
module Kernel
|
120
|
-
def dbg(data, label = '')
|
121
|
-
require 'pp'
|
122
|
-
|
123
|
-
puts '>>----------------------'
|
124
|
-
unless label.empty?
|
125
|
-
puts label
|
126
|
-
puts '---'
|
127
|
-
end
|
128
|
-
pp data
|
129
|
-
puts '<<'
|
130
213
|
end
|
131
214
|
end
|
132
215
|
|
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:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 7
|
10
|
+
version: 0.2.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Adrian Webb
|
@@ -182,6 +182,7 @@ extra_rdoc_files:
|
|
182
182
|
- README.rdoc
|
183
183
|
files:
|
184
184
|
- .document
|
185
|
+
- .gitmodules
|
185
186
|
- Gemfile
|
186
187
|
- Gemfile.lock
|
187
188
|
- LICENSE.txt
|