coral_core 0.2.30 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +2 -8
- data/Gemfile.lock +15 -86
- data/Rakefile +1 -3
- data/VERSION +1 -1
- data/coral_core.gemspec +12 -102
- metadata +18 -239
- data/lib/coral/command/shell.rb +0 -140
- data/lib/coral/machine/fog.rb +0 -215
- data/lib/coral/network/default.rb +0 -26
- data/lib/coral/node/rackspace.rb +0 -23
- data/lib/coral_core/config/collection.rb +0 -57
- data/lib/coral_core/config/options.rb +0 -70
- data/lib/coral_core/config/project.rb +0 -225
- data/lib/coral_core/config.rb +0 -329
- data/lib/coral_core/core.rb +0 -58
- data/lib/coral_core/event/puppet_event.rb +0 -98
- data/lib/coral_core/event/regexp_event.rb +0 -55
- data/lib/coral_core/event.rb +0 -170
- data/lib/coral_core/mixin/config_collection.rb +0 -52
- data/lib/coral_core/mixin/config_ops.rb +0 -51
- data/lib/coral_core/mixin/config_options.rb +0 -38
- data/lib/coral_core/mixin/lookup.rb +0 -211
- data/lib/coral_core/mixin/macro/object_interface.rb +0 -292
- data/lib/coral_core/mixin/macro/plugin_interface.rb +0 -277
- data/lib/coral_core/mixin/settings.rb +0 -46
- data/lib/coral_core/mixin/sub_config.rb +0 -208
- data/lib/coral_core/mod/hash.rb +0 -29
- data/lib/coral_core/mod/hiera_backend.rb +0 -63
- data/lib/coral_core/plugin/command.rb +0 -95
- data/lib/coral_core/plugin/machine.rb +0 -152
- data/lib/coral_core/plugin/network.rb +0 -24
- data/lib/coral_core/plugin/node.rb +0 -184
- data/lib/coral_core/plugin.rb +0 -261
- data/lib/coral_core/plugin_base.rb +0 -147
- data/lib/coral_core/repository.rb +0 -553
- data/lib/coral_core/resource.rb +0 -243
- data/lib/coral_core/template/environment.rb +0 -72
- data/lib/coral_core/template/json.rb +0 -13
- data/lib/coral_core/template/wrapper.rb +0 -13
- data/lib/coral_core/template/yaml.rb +0 -13
- data/lib/coral_core/template.rb +0 -92
- data/lib/coral_core/util/cli.rb +0 -293
- data/lib/coral_core/util/data.rb +0 -389
- data/lib/coral_core/util/disk.rb +0 -105
- data/lib/coral_core/util/git.rb +0 -40
- data/lib/coral_core/util/interface.rb +0 -190
- data/lib/coral_core/util/process.rb +0 -43
- data/lib/coral_core/util/shell.rb +0 -183
- data/lib/coral_core.rb +0 -375
- data/locales/en.yml +0 -8
- data/spec/coral_core/interface_spec.rb +0 -489
- data/spec/coral_mock_input.rb +0 -29
- data/spec/coral_test_kernel.rb +0 -22
- data/spec/spec_helper.rb +0 -15
data/lib/coral_core/util/disk.rb
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
|
2
|
-
module Coral
|
3
|
-
module Util
|
4
|
-
class Disk
|
5
|
-
|
6
|
-
#-----------------------------------------------------------------------------
|
7
|
-
# Properties
|
8
|
-
|
9
|
-
@@files = {}
|
10
|
-
|
11
|
-
@@separator = false
|
12
|
-
@@description = ''
|
13
|
-
|
14
|
-
#-----------------------------------------------------------------------------
|
15
|
-
# Utilities
|
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
|
-
|
29
|
-
def self.open(file_name, options = {}, reset = false)
|
30
|
-
mode = options[:mode].to_s
|
31
|
-
|
32
|
-
@@separator = ( options[:separator] ? options[:separator] : false )
|
33
|
-
@@description = ( options[:description] ? options[:description] : '' )
|
34
|
-
|
35
|
-
if @@files.has_key?(file_name) && ! reset
|
36
|
-
reset = true if ! mode.empty? && mode != @@files[file_name][:mode]
|
37
|
-
end
|
38
|
-
|
39
|
-
if ! @@files.has_key?(file_name) || ! @@files[file_name][:file] || reset
|
40
|
-
@@files[file_name][:file].close if @@files[file_name] && @@files[file_name][:file]
|
41
|
-
unless mode.empty? || ( mode == 'r' && ! File.exists?(file_name) )
|
42
|
-
@@files[file_name] = {
|
43
|
-
:file => File.open(file_name, mode),
|
44
|
-
:mode => mode,
|
45
|
-
}
|
46
|
-
end
|
47
|
-
end
|
48
|
-
return nil unless @@files[file_name]
|
49
|
-
return @@files[file_name][:file]
|
50
|
-
end
|
51
|
-
|
52
|
-
#---
|
53
|
-
|
54
|
-
def self.read(file_name, options = {})
|
55
|
-
options[:mode] = ( options[:mode] ? options[:mode] : 'r' )
|
56
|
-
file = open(file_name, options)
|
57
|
-
|
58
|
-
if file
|
59
|
-
file.pos = 0 if options[:mode] == 'r'
|
60
|
-
return file.read
|
61
|
-
end
|
62
|
-
return nil
|
63
|
-
end
|
64
|
-
|
65
|
-
#---
|
66
|
-
|
67
|
-
def self.write(file_name, data, options = {})
|
68
|
-
options[:mode] = ( options[:mode] ? options[:mode] : 'w' )
|
69
|
-
file = open(file_name, options)
|
70
|
-
|
71
|
-
if file
|
72
|
-
return file.write(data)
|
73
|
-
end
|
74
|
-
return nil
|
75
|
-
end
|
76
|
-
|
77
|
-
#---
|
78
|
-
|
79
|
-
def self.log(data, options = {})
|
80
|
-
reset = ( options[:file_name] || options[:mode] )
|
81
|
-
file = open(( options[:file_name] ? options[:file_name] : 'log.txt' ), options, reset)
|
82
|
-
if file
|
83
|
-
file.write("--------------------------------------\n") if @@separator
|
84
|
-
file.write("#{@@description}\n") if @@description
|
85
|
-
file.write("#{data}\n")
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
#---
|
90
|
-
|
91
|
-
def self.close(file_names = [])
|
92
|
-
file_names = @@files.keys unless file_names && ! file_names.empty?
|
93
|
-
|
94
|
-
unless file_names.is_a?(Array)
|
95
|
-
file_names = [ file_names ]
|
96
|
-
end
|
97
|
-
|
98
|
-
file_names.each do |file_name|
|
99
|
-
@@files[file_name][:file].close if @@files[file_name] && @@files[file_name][:file]
|
100
|
-
@@files.delete(file_name)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
data/lib/coral_core/util/git.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
module Coral
|
2
|
-
class Git < ::Grit::Repo
|
3
|
-
|
4
|
-
#-----------------------------------------------------------------------------
|
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
|
30
|
-
|
31
|
-
self.git = ::Grit::Git.new(self.path)
|
32
|
-
self.git.work_tree = epath
|
33
|
-
|
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
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,190 +0,0 @@
|
|
1
|
-
require 'log4r'
|
2
|
-
|
3
|
-
module Coral
|
4
|
-
module Util
|
5
|
-
class Interface
|
6
|
-
|
7
|
-
#-----------------------------------------------------------------------------
|
8
|
-
# Properties
|
9
|
-
|
10
|
-
@@logger = Log4r::Logger.new("coral::interface")
|
11
|
-
|
12
|
-
#---
|
13
|
-
|
14
|
-
COLORS = {
|
15
|
-
:clear => "\e[0m",
|
16
|
-
:red => "\e[31m",
|
17
|
-
:green => "\e[32m",
|
18
|
-
:yellow => "\e[33m"
|
19
|
-
}
|
20
|
-
|
21
|
-
COLOR_MAP = {
|
22
|
-
:warn => COLORS[:yellow],
|
23
|
-
:error => COLORS[:red],
|
24
|
-
:success => COLORS[:green]
|
25
|
-
}
|
26
|
-
|
27
|
-
#-----------------------------------------------------------------------------
|
28
|
-
# Constructor
|
29
|
-
|
30
|
-
def initialize(options = {})
|
31
|
-
class_name = self.class.to_s.downcase
|
32
|
-
|
33
|
-
if options.is_a?(String)
|
34
|
-
options = { :resource => options, :logger => options }
|
35
|
-
end
|
36
|
-
config = Config.ensure(options)
|
37
|
-
|
38
|
-
if config.get(:logger, false)
|
39
|
-
if config[:logger].is_a?(String)
|
40
|
-
@logger = Log4r::Logger.new(config[:logger])
|
41
|
-
else
|
42
|
-
@logger = config[:logger]
|
43
|
-
end
|
44
|
-
else
|
45
|
-
@logger = Log4r::Logger.new(class_name)
|
46
|
-
end
|
47
|
-
|
48
|
-
@resource = config.get(:resource, '')
|
49
|
-
@color = config.get(:color, true)
|
50
|
-
|
51
|
-
@printer = config.get(:printer, :puts)
|
52
|
-
|
53
|
-
@input = config.get(:input, $stdin)
|
54
|
-
@output = config.get(:output, $stdout)
|
55
|
-
@error = config.get(:error, $stderr)
|
56
|
-
|
57
|
-
@delegate = config.get(:ui_delegate, nil)
|
58
|
-
end
|
59
|
-
|
60
|
-
#---
|
61
|
-
|
62
|
-
def inspect
|
63
|
-
"#<#{self.class}: #{@resource}>"
|
64
|
-
end
|
65
|
-
|
66
|
-
#-----------------------------------------------------------------------------
|
67
|
-
# Accessors / Modifiers
|
68
|
-
|
69
|
-
attr_accessor :logger, :resource, :color, :input, :output, :error, :delegate
|
70
|
-
|
71
|
-
#-----------------------------------------------------------------------------
|
72
|
-
|
73
|
-
def self.logger
|
74
|
-
return @@logger
|
75
|
-
end
|
76
|
-
|
77
|
-
#-----------------------------------------------------------------------------
|
78
|
-
# UI functionality
|
79
|
-
|
80
|
-
def say(type, message, options = {})
|
81
|
-
return @delegate.say(type, message, options) if check_delegate('say')
|
82
|
-
|
83
|
-
defaults = { :new_line => true, :prefix => true }
|
84
|
-
options = defaults.merge(options)
|
85
|
-
printer = options[:new_line] ? :puts : :print
|
86
|
-
channel = type == :error || options[:channel] == :error ? @error : @output
|
87
|
-
|
88
|
-
safe_puts(format_message(type, message, options),
|
89
|
-
:channel => channel, :printer => printer)
|
90
|
-
end
|
91
|
-
|
92
|
-
#---
|
93
|
-
|
94
|
-
def ask(message, options = {})
|
95
|
-
return @delegate.ask(message, options) if check_delegate('ask')
|
96
|
-
|
97
|
-
options[:new_line] = false if ! options.has_key?(:new_line)
|
98
|
-
options[:prefix] = false if ! options.has_key?(:prefix)
|
99
|
-
|
100
|
-
say(:info, message, options)
|
101
|
-
return @input.gets.chomp
|
102
|
-
end
|
103
|
-
|
104
|
-
#-----------------------------------------------------------------------------
|
105
|
-
|
106
|
-
def info(message, *args)
|
107
|
-
@logger.info("info: #{message}")
|
108
|
-
|
109
|
-
return @delegate.info(message, *args) if check_delegate('info')
|
110
|
-
say(:info, message, *args)
|
111
|
-
end
|
112
|
-
|
113
|
-
#---
|
114
|
-
|
115
|
-
def warn(message, *args)
|
116
|
-
@logger.info("warn: #{message}")
|
117
|
-
|
118
|
-
return @delegate.warn(message, *args) if check_delegate('warn')
|
119
|
-
say(:warn, message, *args)
|
120
|
-
end
|
121
|
-
|
122
|
-
#---
|
123
|
-
|
124
|
-
def error(message, *args)
|
125
|
-
@logger.info("error: #{message}")
|
126
|
-
|
127
|
-
return @delegate.error(message, *args) if check_delegate('error')
|
128
|
-
say(:error, message, *args)
|
129
|
-
end
|
130
|
-
|
131
|
-
#---
|
132
|
-
|
133
|
-
def success(message, *args)
|
134
|
-
@logger.info("success: #{message}")
|
135
|
-
|
136
|
-
return @delegate.success(message, *args) if check_delegate('success')
|
137
|
-
say(:success, message, *args)
|
138
|
-
end
|
139
|
-
|
140
|
-
#-----------------------------------------------------------------------------
|
141
|
-
# Utilities
|
142
|
-
|
143
|
-
def format_message(type, message, options = {})
|
144
|
-
return @delegate.format_message(type, message, options) if check_delegate('format_message')
|
145
|
-
|
146
|
-
if @resource && ! @resource.empty? && options[:prefix]
|
147
|
-
prefix = "[#{@resource}]"
|
148
|
-
end
|
149
|
-
message = "#{prefix} #{message}".strip
|
150
|
-
|
151
|
-
if @color
|
152
|
-
if options.has_key?(:color)
|
153
|
-
color = COLORS[options[:color]]
|
154
|
-
message = "#{color}#{message}#{COLORS[:clear]}"
|
155
|
-
else
|
156
|
-
message = "#{COLOR_MAP[type]}#{message}#{COLORS[:clear]}" if COLOR_MAP[type]
|
157
|
-
end
|
158
|
-
end
|
159
|
-
return message
|
160
|
-
end
|
161
|
-
|
162
|
-
#---
|
163
|
-
|
164
|
-
def safe_puts(message = nil, options = {})
|
165
|
-
return @delegate.safe_puts(message, options) if check_delegate('safe_puts')
|
166
|
-
|
167
|
-
#dbg(message, 'message')
|
168
|
-
#dbg(options, 'options')
|
169
|
-
|
170
|
-
message ||= ""
|
171
|
-
options = {
|
172
|
-
:channel => @output,
|
173
|
-
:printer => @printer,
|
174
|
-
}.merge(options)
|
175
|
-
|
176
|
-
begin
|
177
|
-
options[:channel].send(options[:printer], message)
|
178
|
-
rescue Errno::EPIPE
|
179
|
-
return
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
#-----------------------------------------------------------------------------
|
184
|
-
|
185
|
-
def check_delegate(method)
|
186
|
-
return ( @delegate && @delegate.respond_to?(method.to_s) )
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|
@@ -1,43 +0,0 @@
|
|
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
|
@@ -1,183 +0,0 @@
|
|
1
|
-
|
2
|
-
module Coral
|
3
|
-
module Util
|
4
|
-
class Shell < Core
|
5
|
-
|
6
|
-
#-----------------------------------------------------------------------------
|
7
|
-
# Utilities
|
8
|
-
|
9
|
-
def self.exec!(command, options = {})
|
10
|
-
config = Config.ensure(options)
|
11
|
-
|
12
|
-
min = config.get(:min, 1).to_i
|
13
|
-
tries = config.get(:tries, min).to_i
|
14
|
-
tries = ( min > tries ? min : tries )
|
15
|
-
|
16
|
-
info_prefix = config.get(:info_prefix, '')
|
17
|
-
info_suffix = config.get(:info_suffix, '')
|
18
|
-
error_prefix = config.get(:error_prefix, '')
|
19
|
-
error_suffix = config.get(:error_suffix, '')
|
20
|
-
|
21
|
-
ui = config.get(:ui, Coral.ui)
|
22
|
-
|
23
|
-
conditions = Coral::Event.instance(config.get(:exit, {}), true)
|
24
|
-
|
25
|
-
$stdout.sync = true
|
26
|
-
$stderr.sync = true
|
27
|
-
|
28
|
-
for i in tries.downto(1)
|
29
|
-
ui.info(">> running: #{command}")
|
30
|
-
|
31
|
-
begin
|
32
|
-
t1, output_new, output_orig, output_reader = pipe_exec_stream!($stdout, conditions, {
|
33
|
-
:prefix => info_prefix,
|
34
|
-
:suffix => info_suffix,
|
35
|
-
}, 'output') do |line|
|
36
|
-
block_given? ? yield(line) : true
|
37
|
-
end
|
38
|
-
|
39
|
-
t2, error_new, error_orig, error_reader = pipe_exec_stream!($stderr, conditions, {
|
40
|
-
:prefix => error_prefix,
|
41
|
-
:suffix => error_suffix,
|
42
|
-
}, 'error') do |line|
|
43
|
-
block_given? ? yield(line) : true
|
44
|
-
end
|
45
|
-
|
46
|
-
system_success = system(command)
|
47
|
-
|
48
|
-
ensure
|
49
|
-
output_success = close_exec_pipe(t1, $stdout, output_orig, output_new, 'output')
|
50
|
-
error_success = close_exec_pipe(t2, $stderr, error_orig, error_new, 'error')
|
51
|
-
end
|
52
|
-
ui.info('')
|
53
|
-
|
54
|
-
success = ( system_success && output_success && error_success )
|
55
|
-
|
56
|
-
min -= 1
|
57
|
-
break if success && min <= 0 && conditions.empty?
|
58
|
-
end
|
59
|
-
unless conditions.empty?
|
60
|
-
success = false
|
61
|
-
end
|
62
|
-
|
63
|
-
return success
|
64
|
-
end
|
65
|
-
|
66
|
-
#---
|
67
|
-
|
68
|
-
def self.exec(command, options = {})
|
69
|
-
return exec!(command, options)
|
70
|
-
end
|
71
|
-
|
72
|
-
#---
|
73
|
-
|
74
|
-
def self.pipe_exec_stream!(output, conditions, options, label)
|
75
|
-
original = output.dup
|
76
|
-
read, write = IO.pipe
|
77
|
-
|
78
|
-
match_prefix = ( options[:match_prefix] ? options[:match_prefix] : 'EXIT' )
|
79
|
-
|
80
|
-
thread = process_stream!(read, original, options, label) do |line|
|
81
|
-
check_conditions!(line, conditions, match_prefix) do
|
82
|
-
block_given? ? yield(line) : true
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
thread.abort_on_exception = false
|
87
|
-
|
88
|
-
output.reopen(write)
|
89
|
-
return thread, write, original, read
|
90
|
-
end
|
91
|
-
|
92
|
-
#---
|
93
|
-
|
94
|
-
def self.close_exec_pipe(thread, output, original, write, label)
|
95
|
-
output.reopen(original)
|
96
|
-
|
97
|
-
write.close
|
98
|
-
success = thread.value
|
99
|
-
|
100
|
-
original.close
|
101
|
-
return success
|
102
|
-
end
|
103
|
-
|
104
|
-
#---
|
105
|
-
|
106
|
-
def self.check_conditions!(line, conditions, match_prefix = '')
|
107
|
-
prefix = ''
|
108
|
-
|
109
|
-
unless ! conditions || conditions.empty?
|
110
|
-
conditions.each do |key, event|
|
111
|
-
if event.check(line)
|
112
|
-
prefix = match_prefix
|
113
|
-
conditions.delete(key)
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
result = true
|
119
|
-
if block_given?
|
120
|
-
result = yield
|
121
|
-
|
122
|
-
unless prefix.empty?
|
123
|
-
case result
|
124
|
-
when Hash
|
125
|
-
result[:prefix] = prefix
|
126
|
-
else
|
127
|
-
result = { :success => result, :prefix => prefix }
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
return result
|
132
|
-
end
|
133
|
-
|
134
|
-
#---
|
135
|
-
|
136
|
-
def self.process_stream!(input, output, options, label)
|
137
|
-
return Thread.new do
|
138
|
-
success = true
|
139
|
-
default_prefix = ( options[:prefix] ? options[:prefix] : '' )
|
140
|
-
default_suffix = ( options[:suffix] ? options[:suffix] : '' )
|
141
|
-
|
142
|
-
begin
|
143
|
-
while ( data = input.readpartial(1024) )
|
144
|
-
message = data.strip
|
145
|
-
newline = ( data[-1,1].match(/\n/) ? true : false )
|
146
|
-
|
147
|
-
unless message.empty?
|
148
|
-
lines = message.split(/\n/)
|
149
|
-
lines.each_with_index do |line, index|
|
150
|
-
prefix = default_prefix
|
151
|
-
suffix = default_suffix
|
152
|
-
|
153
|
-
unless line.empty?
|
154
|
-
if block_given?
|
155
|
-
result = yield(line)
|
156
|
-
|
157
|
-
if result && result.is_a?(Hash)
|
158
|
-
prefix = result[:prefix]
|
159
|
-
suffix = result[:suffix]
|
160
|
-
result = result[:success]
|
161
|
-
end
|
162
|
-
success = result if success
|
163
|
-
end
|
164
|
-
|
165
|
-
prefix = ( prefix && ! prefix.empty? ? "#{prefix}: " : '' )
|
166
|
-
suffix = ( suffix && ! suffix.empty? ? suffix : '' )
|
167
|
-
eol = ( index < lines.length - 1 || newline ? "\n" : ' ' )
|
168
|
-
|
169
|
-
output.write(prefix.lstrip + line + suffix.rstrip + eol)
|
170
|
-
end
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
174
|
-
rescue EOFError
|
175
|
-
end
|
176
|
-
|
177
|
-
input.close()
|
178
|
-
success
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|