coral_core 0.2.26 → 0.2.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +7 -2
- data/Gemfile.lock +84 -15
- data/VERSION +1 -1
- data/coral_core.gemspec +51 -16
- data/lib/{coral_core/command.rb → coral/command/shell.rb} +12 -116
- data/lib/coral/machine/fog.rb +215 -0
- data/lib/coral/network/default.rb +26 -0
- data/lib/coral/node/rackspace.rb +23 -0
- data/lib/coral_core.rb +249 -134
- data/lib/coral_core/config.rb +233 -275
- data/lib/coral_core/config/collection.rb +57 -0
- data/lib/coral_core/config/options.rb +70 -0
- data/lib/coral_core/config/project.rb +225 -0
- data/lib/coral_core/core.rb +19 -173
- data/lib/coral_core/event/puppet_event.rb +98 -0
- data/lib/coral_core/mixin/config_collection.rb +52 -0
- data/lib/coral_core/mixin/config_ops.rb +51 -0
- data/lib/coral_core/mixin/config_options.rb +38 -0
- data/lib/coral_core/mixin/lookup.rb +211 -0
- data/lib/coral_core/mixin/macro/object_interface.rb +292 -0
- data/lib/coral_core/mixin/macro/plugin_interface.rb +277 -0
- data/lib/coral_core/mixin/settings.rb +46 -0
- data/lib/coral_core/mixin/sub_config.rb +208 -0
- data/lib/coral_core/mod/hash.rb +29 -0
- data/lib/{hiera_backend.rb → coral_core/mod/hiera_backend.rb} +0 -0
- data/lib/coral_core/plugin.rb +261 -0
- data/lib/coral_core/plugin/command.rb +95 -0
- data/lib/coral_core/plugin/machine.rb +152 -0
- data/lib/coral_core/plugin/network.rb +24 -0
- data/lib/coral_core/plugin/node.rb +184 -0
- data/lib/coral_core/plugin_base.rb +147 -0
- data/lib/coral_core/repository.rb +471 -82
- data/lib/coral_core/util/cli.rb +293 -0
- data/lib/coral_core/util/data.rb +178 -8
- data/lib/coral_core/util/disk.rb +13 -0
- data/lib/coral_core/util/git.rb +35 -10
- data/lib/coral_core/{interface.rb → util/interface.rb} +31 -21
- data/lib/coral_core/util/process.rb +43 -0
- data/locales/en.yml +8 -0
- data/spec/coral_core/interface_spec.rb +45 -45
- metadata +109 -34
- data/.gitmodules +0 -12
- data/lib/coral_core/memory.rb +0 -226
- data/lib/coral_core/util/git/base.rb +0 -65
- data/lib/coral_core/util/git/lib.rb +0 -89
- data/lib/coral_core/util/git/remote.rb +0 -12
data/lib/coral_core/util/disk.rb
CHANGED
|
@@ -14,6 +14,18 @@ class Disk
|
|
|
14
14
|
#-----------------------------------------------------------------------------
|
|
15
15
|
# Utilities
|
|
16
16
|
|
|
17
|
+
def self.exists?(file)
|
|
18
|
+
return File.exists?(File.expand_path(file))
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
#---
|
|
22
|
+
|
|
23
|
+
def self.filename(file_name)
|
|
24
|
+
return ( file_name.is_a?(Array) ? file_name.join(File::SEPARATOR) : file_name.to_s )
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
#---
|
|
28
|
+
|
|
17
29
|
def self.open(file_name, options = {}, reset = false)
|
|
18
30
|
mode = options[:mode].to_s
|
|
19
31
|
|
|
@@ -44,6 +56,7 @@ class Disk
|
|
|
44
56
|
file = open(file_name, options)
|
|
45
57
|
|
|
46
58
|
if file
|
|
59
|
+
file.pos = 0 if options[:mode] == 'r'
|
|
47
60
|
return file.read
|
|
48
61
|
end
|
|
49
62
|
return nil
|
data/lib/coral_core/util/git.rb
CHANGED
|
@@ -1,15 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
module Git
|
|
5
|
-
|
|
1
|
+
module Coral
|
|
2
|
+
class Git < ::Grit::Repo
|
|
3
|
+
|
|
6
4
|
#-----------------------------------------------------------------------------
|
|
7
|
-
#
|
|
5
|
+
# Constructor / Destructor
|
|
6
|
+
|
|
7
|
+
def initialize(path, options = {})
|
|
8
|
+
epath = File.expand_path(path)
|
|
9
|
+
git_dir = File.join(epath, '.git')
|
|
10
|
+
|
|
11
|
+
@bare = (options[:is_bare] ? true : false)
|
|
12
|
+
|
|
13
|
+
if File.exist?(git_dir)
|
|
14
|
+
self.working_dir = epath
|
|
15
|
+
|
|
16
|
+
if File.directory?(git_dir)
|
|
17
|
+
self.path = git_dir
|
|
18
|
+
else
|
|
19
|
+
git_dir = Util::Disk.read(git_dir)
|
|
20
|
+
unless git_dir.nil?
|
|
21
|
+
git_dir = git_dir.gsub(/^gitdir\:\s*/, '').strip
|
|
22
|
+
self.path = git_dir if File.directory?(git_dir)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
elsif File.directory?(epath) && (options[:is_bare] || (epath =~ /\.git$/ && File.exist?(File.join(epath, 'HEAD'))))
|
|
27
|
+
self.path = epath
|
|
28
|
+
@bare = true
|
|
29
|
+
end
|
|
8
30
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
options[:auth] = ( options[:auth] ? options[:auth] : true )
|
|
31
|
+
self.git = ::Grit::Git.new(self.path)
|
|
32
|
+
self.git.work_tree = epath
|
|
12
33
|
|
|
13
|
-
|
|
34
|
+
unless File.directory?(epath) && self.git.exist?
|
|
35
|
+
FileUtils.mkdir_p(epath) unless File.directory?(epath)
|
|
36
|
+
self.git.init({ :bare => @bare })
|
|
37
|
+
end
|
|
14
38
|
end
|
|
39
|
+
end
|
|
15
40
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
1
|
require 'log4r'
|
|
3
2
|
|
|
4
3
|
module Coral
|
|
4
|
+
module Util
|
|
5
5
|
class Interface
|
|
6
6
|
|
|
7
7
|
#-----------------------------------------------------------------------------
|
|
@@ -12,15 +12,15 @@ class Interface
|
|
|
12
12
|
#---
|
|
13
13
|
|
|
14
14
|
COLORS = {
|
|
15
|
-
:clear
|
|
16
|
-
:red
|
|
17
|
-
:green
|
|
15
|
+
:clear => "\e[0m",
|
|
16
|
+
:red => "\e[31m",
|
|
17
|
+
:green => "\e[32m",
|
|
18
18
|
:yellow => "\e[33m"
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
COLOR_MAP = {
|
|
22
|
-
:warn
|
|
23
|
-
:error
|
|
22
|
+
:warn => COLORS[:yellow],
|
|
23
|
+
:error => COLORS[:red],
|
|
24
24
|
:success => COLORS[:green]
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -39,24 +39,30 @@ class Interface
|
|
|
39
39
|
if config[:logger].is_a?(String)
|
|
40
40
|
@logger = Log4r::Logger.new(config[:logger])
|
|
41
41
|
else
|
|
42
|
-
@logger = config[:logger]
|
|
42
|
+
@logger = config[:logger]
|
|
43
43
|
end
|
|
44
44
|
else
|
|
45
45
|
@logger = Log4r::Logger.new(class_name)
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
@resource
|
|
49
|
-
@color
|
|
48
|
+
@resource = config.get(:resource, '')
|
|
49
|
+
@color = config.get(:color, true)
|
|
50
50
|
|
|
51
|
-
@printer
|
|
51
|
+
@printer = config.get(:printer, :puts)
|
|
52
52
|
|
|
53
|
-
@input
|
|
54
|
-
@output
|
|
55
|
-
@error
|
|
53
|
+
@input = config.get(:input, $stdin)
|
|
54
|
+
@output = config.get(:output, $stdout)
|
|
55
|
+
@error = config.get(:error, $stderr)
|
|
56
56
|
|
|
57
|
-
@delegate
|
|
57
|
+
@delegate = config.get(:ui_delegate, nil)
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
+
#---
|
|
61
|
+
|
|
62
|
+
def inspect
|
|
63
|
+
"#<#{self.class}: #{@resource}>"
|
|
64
|
+
end
|
|
65
|
+
|
|
60
66
|
#-----------------------------------------------------------------------------
|
|
61
67
|
# Accessors / Modifiers
|
|
62
68
|
|
|
@@ -75,9 +81,9 @@ class Interface
|
|
|
75
81
|
return @delegate.say(type, message, options) if check_delegate('say')
|
|
76
82
|
|
|
77
83
|
defaults = { :new_line => true, :prefix => true }
|
|
78
|
-
options
|
|
79
|
-
printer
|
|
80
|
-
channel
|
|
84
|
+
options = defaults.merge(options)
|
|
85
|
+
printer = options[:new_line] ? :puts : :print
|
|
86
|
+
channel = type == :error || options[:channel] == :error ? @error : @output
|
|
81
87
|
|
|
82
88
|
safe_puts(format_message(type, message, options),
|
|
83
89
|
:channel => channel, :printer => printer)
|
|
@@ -89,7 +95,7 @@ class Interface
|
|
|
89
95
|
return @delegate.ask(message, options) if check_delegate('ask')
|
|
90
96
|
|
|
91
97
|
options[:new_line] = false if ! options.has_key?(:new_line)
|
|
92
|
-
options[:prefix]
|
|
98
|
+
options[:prefix] = false if ! options.has_key?(:prefix)
|
|
93
99
|
|
|
94
100
|
say(:info, message, options)
|
|
95
101
|
return @input.gets.chomp
|
|
@@ -138,13 +144,13 @@ class Interface
|
|
|
138
144
|
return @delegate.format_message(type, message, options) if check_delegate('format_message')
|
|
139
145
|
|
|
140
146
|
if @resource && ! @resource.empty? && options[:prefix]
|
|
141
|
-
prefix = "[#{@resource}]"
|
|
147
|
+
prefix = "[#{@resource}]"
|
|
142
148
|
end
|
|
143
149
|
message = "#{prefix} #{message}".strip
|
|
144
150
|
|
|
145
151
|
if @color
|
|
146
152
|
if options.has_key?(:color)
|
|
147
|
-
color
|
|
153
|
+
color = COLORS[options[:color]]
|
|
148
154
|
message = "#{color}#{message}#{COLORS[:clear]}"
|
|
149
155
|
else
|
|
150
156
|
message = "#{COLOR_MAP[type]}#{message}#{COLORS[:clear]}" if COLOR_MAP[type]
|
|
@@ -158,8 +164,11 @@ class Interface
|
|
|
158
164
|
def safe_puts(message = nil, options = {})
|
|
159
165
|
return @delegate.safe_puts(message, options) if check_delegate('safe_puts')
|
|
160
166
|
|
|
167
|
+
#dbg(message, 'message')
|
|
168
|
+
#dbg(options, 'options')
|
|
169
|
+
|
|
161
170
|
message ||= ""
|
|
162
|
-
options
|
|
171
|
+
options = {
|
|
163
172
|
:channel => @output,
|
|
164
173
|
:printer => @printer,
|
|
165
174
|
}.merge(options)
|
|
@@ -177,4 +186,5 @@ class Interface
|
|
|
177
186
|
return ( @delegate && @delegate.respond_to?(method.to_s) )
|
|
178
187
|
end
|
|
179
188
|
end
|
|
189
|
+
end
|
|
180
190
|
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
|
|
2
|
+
module Coral
|
|
3
|
+
module Util
|
|
4
|
+
class Process
|
|
5
|
+
|
|
6
|
+
#-----------------------------------------------------------------------------
|
|
7
|
+
# Constructor / Destructor
|
|
8
|
+
|
|
9
|
+
def initialize(name, &code)
|
|
10
|
+
@name = name
|
|
11
|
+
@code = code
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
#-----------------------------------------------------------------------------
|
|
15
|
+
# Property accessors / modifiers
|
|
16
|
+
|
|
17
|
+
attr_reader :name
|
|
18
|
+
|
|
19
|
+
#---
|
|
20
|
+
|
|
21
|
+
def provider_options
|
|
22
|
+
return {
|
|
23
|
+
:parallel => true
|
|
24
|
+
}
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
#-----------------------------------------------------------------------------
|
|
28
|
+
# Actions
|
|
29
|
+
|
|
30
|
+
def action(action_name, options = {})
|
|
31
|
+
if action_name == :run
|
|
32
|
+
run(options)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
#---
|
|
37
|
+
|
|
38
|
+
def run(options = {})
|
|
39
|
+
@code.call(options)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
data/locales/en.yml
ADDED
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
|
3
3
|
|
|
4
4
|
module Coral
|
|
5
5
|
|
|
6
|
-
describe Interface do
|
|
6
|
+
describe Util::Interface do
|
|
7
7
|
|
|
8
8
|
#---------------------------------------------------------------------------
|
|
9
9
|
# UI functionality
|
|
@@ -17,11 +17,11 @@ module Coral
|
|
|
17
17
|
output = double('output')
|
|
18
18
|
output.should_receive(:puts).with('message')
|
|
19
19
|
|
|
20
|
-
ui = Interface.new({
|
|
20
|
+
ui = Util::Interface.new({
|
|
21
21
|
:output => output,
|
|
22
22
|
:printer => :puts,
|
|
23
23
|
})
|
|
24
|
-
Interface.new({ :ui_delegate => ui }).say(:info, 'message')
|
|
24
|
+
Util::Interface.new({ :ui_delegate => ui }).say(:info, 'message')
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
#-------------------------------------------------------------------------
|
|
@@ -31,12 +31,12 @@ module Coral
|
|
|
31
31
|
output1 = double('output1')
|
|
32
32
|
output1.should_receive(:puts).with('message')
|
|
33
33
|
|
|
34
|
-
Interface.new({ :output => output1 }).say(:info, 'message')
|
|
34
|
+
Util::Interface.new({ :output => output1 }).say(:info, 'message')
|
|
35
35
|
|
|
36
36
|
output2 = double('output2')
|
|
37
37
|
output2.should_receive(:puts).with('[component] message')
|
|
38
38
|
|
|
39
|
-
Interface.new({
|
|
39
|
+
Util::Interface.new({
|
|
40
40
|
:resource => 'component',
|
|
41
41
|
:output => output2,
|
|
42
42
|
}).say(:info, 'message')
|
|
@@ -48,13 +48,13 @@ module Coral
|
|
|
48
48
|
output1 = double('output1')
|
|
49
49
|
output1.should_receive(:puts).with('message')
|
|
50
50
|
|
|
51
|
-
test = Interface.new({ :output => output1 })
|
|
51
|
+
test = Util::Interface.new({ :output => output1 })
|
|
52
52
|
test.say(:info, 'message', { :new_line => true })
|
|
53
53
|
|
|
54
54
|
output2 = double('output2')
|
|
55
55
|
output2.should_receive(:print).with('message')
|
|
56
56
|
|
|
57
|
-
test = Interface.new({ :output => output2 })
|
|
57
|
+
test = Util::Interface.new({ :output => output2 })
|
|
58
58
|
test.say(:info, 'message', { :new_line => false })
|
|
59
59
|
end
|
|
60
60
|
|
|
@@ -65,7 +65,7 @@ module Coral
|
|
|
65
65
|
output = double('output')
|
|
66
66
|
output.should_receive(:puts).with('message')
|
|
67
67
|
|
|
68
|
-
Interface.new({
|
|
68
|
+
Util::Interface.new({
|
|
69
69
|
:output => output,
|
|
70
70
|
:printer => :puts,
|
|
71
71
|
:color => false,
|
|
@@ -75,7 +75,7 @@ module Coral
|
|
|
75
75
|
error = double('error')
|
|
76
76
|
error.should_receive(:puts).with('message')
|
|
77
77
|
|
|
78
|
-
Interface.new({
|
|
78
|
+
Util::Interface.new({
|
|
79
79
|
:error => error,
|
|
80
80
|
:printer => :puts,
|
|
81
81
|
:color => false,
|
|
@@ -89,7 +89,7 @@ module Coral
|
|
|
89
89
|
output = double('output')
|
|
90
90
|
output.should_receive(:puts).with('message')
|
|
91
91
|
|
|
92
|
-
Interface.new({
|
|
92
|
+
Util::Interface.new({
|
|
93
93
|
:output => output,
|
|
94
94
|
:printer => :puts,
|
|
95
95
|
}).say(:info, 'message', { :channel => type })
|
|
@@ -98,7 +98,7 @@ module Coral
|
|
|
98
98
|
error = double('error')
|
|
99
99
|
error.should_receive(:puts).with('message')
|
|
100
100
|
|
|
101
|
-
Interface.new({
|
|
101
|
+
Util::Interface.new({
|
|
102
102
|
:error => error,
|
|
103
103
|
:printer => :puts,
|
|
104
104
|
:color => false,
|
|
@@ -132,11 +132,11 @@ module Coral
|
|
|
132
132
|
output = double('output')
|
|
133
133
|
output.should_receive(:puts).with('message')
|
|
134
134
|
|
|
135
|
-
ui = Interface.new({
|
|
135
|
+
ui = Util::Interface.new({
|
|
136
136
|
:output => output,
|
|
137
137
|
:printer => :puts,
|
|
138
138
|
})
|
|
139
|
-
Interface.new({ :ui_delegate => ui }).info('message')
|
|
139
|
+
Util::Interface.new({ :ui_delegate => ui }).info('message')
|
|
140
140
|
end
|
|
141
141
|
|
|
142
142
|
#-------------------------------------------------------------------------
|
|
@@ -146,7 +146,7 @@ module Coral
|
|
|
146
146
|
output = double('output')
|
|
147
147
|
output.should_receive(:puts).with('message')
|
|
148
148
|
|
|
149
|
-
Interface.new({
|
|
149
|
+
Util::Interface.new({
|
|
150
150
|
:output => output,
|
|
151
151
|
:printer => :puts,
|
|
152
152
|
}).info('message')
|
|
@@ -164,12 +164,12 @@ module Coral
|
|
|
164
164
|
output = double('output')
|
|
165
165
|
output.should_receive(:puts).with('message')
|
|
166
166
|
|
|
167
|
-
ui = Interface.new({
|
|
167
|
+
ui = Util::Interface.new({
|
|
168
168
|
:output => output,
|
|
169
169
|
:printer => :puts,
|
|
170
170
|
:color => false,
|
|
171
171
|
})
|
|
172
|
-
Interface.new({ :ui_delegate => ui }).warn('message')
|
|
172
|
+
Util::Interface.new({ :ui_delegate => ui }).warn('message')
|
|
173
173
|
end
|
|
174
174
|
|
|
175
175
|
#-------------------------------------------------------------------------
|
|
@@ -179,7 +179,7 @@ module Coral
|
|
|
179
179
|
output = double('output')
|
|
180
180
|
output.should_receive(:puts).with('message')
|
|
181
181
|
|
|
182
|
-
Interface.new({
|
|
182
|
+
Util::Interface.new({
|
|
183
183
|
:output => output,
|
|
184
184
|
:printer => :puts,
|
|
185
185
|
:color => false,
|
|
@@ -192,7 +192,7 @@ module Coral
|
|
|
192
192
|
output = double('output')
|
|
193
193
|
output.should_receive(:print).with(/^\e\[33mmessage\e\[0m$/)
|
|
194
194
|
|
|
195
|
-
Interface.new({
|
|
195
|
+
Util::Interface.new({
|
|
196
196
|
:output => output,
|
|
197
197
|
:color => true,
|
|
198
198
|
}).warn('message', { :new_line => false })
|
|
@@ -210,12 +210,12 @@ module Coral
|
|
|
210
210
|
error = double('error')
|
|
211
211
|
error.should_receive(:puts).with('message')
|
|
212
212
|
|
|
213
|
-
ui = Interface.new({
|
|
213
|
+
ui = Util::Interface.new({
|
|
214
214
|
:error => error,
|
|
215
215
|
:printer => :puts,
|
|
216
216
|
:color => false,
|
|
217
217
|
})
|
|
218
|
-
Interface.new({ :ui_delegate => ui }).error('message')
|
|
218
|
+
Util::Interface.new({ :ui_delegate => ui }).error('message')
|
|
219
219
|
end
|
|
220
220
|
|
|
221
221
|
#-------------------------------------------------------------------------
|
|
@@ -225,7 +225,7 @@ module Coral
|
|
|
225
225
|
error = double('error')
|
|
226
226
|
error.should_receive(:puts).with('message')
|
|
227
227
|
|
|
228
|
-
Interface.new({
|
|
228
|
+
Util::Interface.new({
|
|
229
229
|
:error => error,
|
|
230
230
|
:printer => :puts,
|
|
231
231
|
:color => false,
|
|
@@ -238,7 +238,7 @@ module Coral
|
|
|
238
238
|
error = double('error')
|
|
239
239
|
error.should_receive(:print).with(/^\e\[31mmessage\e\[0m$/)
|
|
240
240
|
|
|
241
|
-
Interface.new({
|
|
241
|
+
Util::Interface.new({
|
|
242
242
|
:error => error,
|
|
243
243
|
:color => true,
|
|
244
244
|
}).error('message', { :new_line => false })
|
|
@@ -256,12 +256,12 @@ module Coral
|
|
|
256
256
|
output = double('output')
|
|
257
257
|
output.should_receive(:puts).with('message')
|
|
258
258
|
|
|
259
|
-
ui = Interface.new({
|
|
259
|
+
ui = Util::Interface.new({
|
|
260
260
|
:output => output,
|
|
261
261
|
:printer => :puts,
|
|
262
262
|
:color => false,
|
|
263
263
|
})
|
|
264
|
-
Interface.new({ :ui_delegate => ui }).success('message')
|
|
264
|
+
Util::Interface.new({ :ui_delegate => ui }).success('message')
|
|
265
265
|
end
|
|
266
266
|
|
|
267
267
|
#-------------------------------------------------------------------------
|
|
@@ -271,7 +271,7 @@ module Coral
|
|
|
271
271
|
output = double('output')
|
|
272
272
|
output.should_receive(:puts).with('message')
|
|
273
273
|
|
|
274
|
-
Interface.new({
|
|
274
|
+
Util::Interface.new({
|
|
275
275
|
:output => output,
|
|
276
276
|
:printer => :puts,
|
|
277
277
|
:color => false,
|
|
@@ -284,7 +284,7 @@ module Coral
|
|
|
284
284
|
output = double('output')
|
|
285
285
|
output.should_receive(:print).with(/^\e\[32mmessage\e\[0m$/)
|
|
286
286
|
|
|
287
|
-
Interface.new({
|
|
287
|
+
Util::Interface.new({
|
|
288
288
|
:output => output,
|
|
289
289
|
:color => true,
|
|
290
290
|
}).success('message', { :new_line => false })
|
|
@@ -300,8 +300,8 @@ module Coral
|
|
|
300
300
|
# Delegation
|
|
301
301
|
|
|
302
302
|
it "can delegate to another class that contains this method" do
|
|
303
|
-
message = Interface.new({
|
|
304
|
-
:ui_delegate => Interface.new('delegate')
|
|
303
|
+
message = Util::Interface.new({
|
|
304
|
+
:ui_delegate => Util::Interface.new('delegate')
|
|
305
305
|
}).format_message(:info, 'message', { :prefix => true })
|
|
306
306
|
|
|
307
307
|
message.should == '[delegate] message'
|
|
@@ -311,28 +311,28 @@ module Coral
|
|
|
311
311
|
# Prefix specifications
|
|
312
312
|
|
|
313
313
|
it "returns without a prefix because no resource" do
|
|
314
|
-
message = Interface.new.format_message(:info, 'message', { :prefix => true })
|
|
314
|
+
message = Util::Interface.new.format_message(:info, 'message', { :prefix => true })
|
|
315
315
|
message.should == 'message'
|
|
316
316
|
end
|
|
317
317
|
|
|
318
318
|
#---
|
|
319
319
|
|
|
320
320
|
it "returns without a prefix because prefix is false" do
|
|
321
|
-
message = Interface.new('component').format_message(:info, 'message', { :prefix => false })
|
|
321
|
+
message = Util::Interface.new('component').format_message(:info, 'message', { :prefix => false })
|
|
322
322
|
message.should == 'message'
|
|
323
323
|
end
|
|
324
324
|
|
|
325
325
|
#---
|
|
326
326
|
|
|
327
327
|
it "returns without a prefix because no prefix option given" do
|
|
328
|
-
message = Interface.new('component').format_message(:info, 'message')
|
|
328
|
+
message = Util::Interface.new('component').format_message(:info, 'message')
|
|
329
329
|
message.should == 'message'
|
|
330
330
|
end
|
|
331
331
|
|
|
332
332
|
#---
|
|
333
333
|
|
|
334
334
|
it "returns with a prefix if resource and prefix option given" do
|
|
335
|
-
message = Interface.new('component').format_message(:info, 'message', { :prefix => true })
|
|
335
|
+
message = Util::Interface.new('component').format_message(:info, 'message', { :prefix => true })
|
|
336
336
|
message.should == '[component] message'
|
|
337
337
|
end
|
|
338
338
|
|
|
@@ -340,7 +340,7 @@ module Coral
|
|
|
340
340
|
# Color specifications
|
|
341
341
|
|
|
342
342
|
it "formats a error message in red if color enabled" do
|
|
343
|
-
message = Interface.new({
|
|
343
|
+
message = Util::Interface.new({
|
|
344
344
|
:resource => 'component',
|
|
345
345
|
:color => true,
|
|
346
346
|
}).format_message(:error, 'message')
|
|
@@ -350,7 +350,7 @@ module Coral
|
|
|
350
350
|
#---
|
|
351
351
|
|
|
352
352
|
it "formats a warning message in yellow if color enabled" do
|
|
353
|
-
message = Interface.new({
|
|
353
|
+
message = Util::Interface.new({
|
|
354
354
|
:resource => 'component',
|
|
355
355
|
:color => true,
|
|
356
356
|
}).format_message(:warn, 'message')
|
|
@@ -360,7 +360,7 @@ module Coral
|
|
|
360
360
|
#---
|
|
361
361
|
|
|
362
362
|
it "formats a success message in green if color enabled" do
|
|
363
|
-
message = Interface.new({
|
|
363
|
+
message = Util::Interface.new({
|
|
364
364
|
:resource => 'component',
|
|
365
365
|
:color => true,
|
|
366
366
|
}).format_message(:success, 'message')
|
|
@@ -379,11 +379,11 @@ module Coral
|
|
|
379
379
|
output = double('output')
|
|
380
380
|
output.should_receive(:puts).with('message')
|
|
381
381
|
|
|
382
|
-
ui = Interface.new({
|
|
382
|
+
ui = Util::Interface.new({
|
|
383
383
|
:output => output,
|
|
384
384
|
:printer => :puts,
|
|
385
385
|
})
|
|
386
|
-
Interface.new({ :ui_delegate => ui }).safe_puts('message')
|
|
386
|
+
Util::Interface.new({ :ui_delegate => ui }).safe_puts('message')
|
|
387
387
|
end
|
|
388
388
|
|
|
389
389
|
#-------------------------------------------------------------------------
|
|
@@ -393,7 +393,7 @@ module Coral
|
|
|
393
393
|
output = double('output')
|
|
394
394
|
output.should_receive(:puts).with('')
|
|
395
395
|
|
|
396
|
-
Interface.new({
|
|
396
|
+
Util::Interface.new({
|
|
397
397
|
:output => output,
|
|
398
398
|
:printer => :puts,
|
|
399
399
|
}).safe_puts()
|
|
@@ -405,7 +405,7 @@ module Coral
|
|
|
405
405
|
output1 = double('output1')
|
|
406
406
|
output1.should_receive(:puts).with('message')
|
|
407
407
|
|
|
408
|
-
test = Interface.new({
|
|
408
|
+
test = Util::Interface.new({
|
|
409
409
|
:output => output1,
|
|
410
410
|
:printer => :puts,
|
|
411
411
|
})
|
|
@@ -424,7 +424,7 @@ module Coral
|
|
|
424
424
|
output = double('output')
|
|
425
425
|
output.should_receive(:puts).with('message')
|
|
426
426
|
|
|
427
|
-
Interface.new({
|
|
427
|
+
Util::Interface.new({
|
|
428
428
|
:output => output,
|
|
429
429
|
:printer => :puts,
|
|
430
430
|
}).safe_puts('message')
|
|
@@ -436,7 +436,7 @@ module Coral
|
|
|
436
436
|
output = double('output')
|
|
437
437
|
output.should_receive(:print).with('message')
|
|
438
438
|
|
|
439
|
-
Interface.new({
|
|
439
|
+
Util::Interface.new({
|
|
440
440
|
:output => output,
|
|
441
441
|
:printer => :print,
|
|
442
442
|
}).safe_puts('message')
|
|
@@ -452,7 +452,7 @@ module Coral
|
|
|
452
452
|
output2 = double('output2')
|
|
453
453
|
output2.should_receive(:puts).with('message')
|
|
454
454
|
|
|
455
|
-
Interface.new({
|
|
455
|
+
Util::Interface.new({
|
|
456
456
|
:output => output1,
|
|
457
457
|
:printer => :puts,
|
|
458
458
|
}).safe_puts('message', { :channel => output2 })
|
|
@@ -465,7 +465,7 @@ module Coral
|
|
|
465
465
|
output.should_not_receive(:puts).with('message')
|
|
466
466
|
output.should_receive(:print).with('message')
|
|
467
467
|
|
|
468
|
-
Interface.new({
|
|
468
|
+
Util::Interface.new({
|
|
469
469
|
:output => output,
|
|
470
470
|
:printer => :puts,
|
|
471
471
|
}).safe_puts('message', { :printer => :print })
|
|
@@ -477,10 +477,10 @@ module Coral
|
|
|
477
477
|
describe "#check_delegate" do
|
|
478
478
|
|
|
479
479
|
it "returns false if no delegate exists" do
|
|
480
|
-
Interface.new.check_delegate('safe_puts').should be_false
|
|
480
|
+
Util::Interface.new.check_delegate('safe_puts').should be_false
|
|
481
481
|
end
|
|
482
482
|
it "returns true if a delegate exists and it implements given method" do
|
|
483
|
-
test = Interface.new({ :ui_delegate => Interface.new })
|
|
483
|
+
test = Util::Interface.new({ :ui_delegate => Util::Interface.new })
|
|
484
484
|
test.check_delegate('safe_puts').should be_true
|
|
485
485
|
test.check_delegate('nonexistent').should be_false
|
|
486
486
|
end
|