linecook 0.6.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History +139 -0
- data/HowTo/Control Virtual Machines +106 -0
- data/HowTo/Generate Scripts +263 -0
- data/HowTo/Run Scripts +87 -0
- data/HowTo/Setup Virtual Machines +76 -0
- data/License.txt +1 -1
- data/README +78 -59
- data/bin/linecook +12 -5
- data/bin/linecook_run +45 -0
- data/bin/linecook_scp +50 -0
- data/lib/linecook.rb +1 -3
- data/lib/linecook/attributes.rb +49 -12
- data/lib/linecook/commands.rb +9 -4
- data/lib/linecook/commands/build.rb +69 -0
- data/lib/linecook/commands/command.rb +13 -3
- data/lib/linecook/commands/command_error.rb +6 -0
- data/lib/linecook/commands/env.rb +74 -8
- data/lib/linecook/commands/helper.rb +271 -24
- data/lib/linecook/commands/init.rb +10 -6
- data/lib/linecook/commands/package.rb +36 -18
- data/lib/linecook/commands/run.rb +66 -0
- data/lib/linecook/commands/snapshot.rb +114 -0
- data/lib/linecook/commands/ssh.rb +39 -0
- data/lib/linecook/commands/start.rb +34 -0
- data/lib/linecook/commands/state.rb +32 -0
- data/lib/linecook/commands/stop.rb +22 -0
- data/lib/linecook/commands/vbox_command.rb +130 -0
- data/lib/linecook/cookbook.rb +112 -55
- data/lib/linecook/package.rb +293 -109
- data/lib/linecook/proxy.rb +19 -0
- data/lib/linecook/recipe.rb +321 -62
- data/lib/linecook/template.rb +7 -101
- data/lib/linecook/test.rb +196 -141
- data/lib/linecook/test/command_parser.rb +75 -0
- data/lib/linecook/test/file_test.rb +153 -35
- data/lib/linecook/test/shell_test.rb +176 -0
- data/lib/linecook/utils.rb +25 -7
- data/lib/linecook/version.rb +4 -4
- data/templates/Rakefile +44 -47
- data/templates/_gitignore +1 -1
- data/templates/attributes/project_name.rb +4 -4
- data/templates/config/ssh +15 -0
- data/templates/files/help.txt +1 -0
- data/templates/helpers/project_name/assert_content_equal.erb +15 -0
- data/templates/helpers/project_name/create_dir.erb +9 -0
- data/templates/helpers/project_name/create_file.erb +8 -0
- data/templates/helpers/project_name/install_file.erb +8 -0
- data/templates/packages/abox.yml +4 -0
- data/templates/recipes/abox.rb +22 -0
- data/templates/recipes/abox_test.rb +14 -0
- data/templates/templates/todo.txt.erb +3 -0
- data/templates/test/project_name_test.rb +19 -0
- data/templates/test/test_helper.rb +14 -0
- metadata +43 -41
- data/cookbook +0 -0
- data/lib/linecook/commands/helpers.rb +0 -28
- data/lib/linecook/commands/vbox.rb +0 -85
- data/lib/linecook/helper.rb +0 -117
- data/lib/linecook/shell.rb +0 -11
- data/lib/linecook/shell/posix.rb +0 -145
- data/lib/linecook/shell/test.rb +0 -254
- data/lib/linecook/shell/unix.rb +0 -117
- data/lib/linecook/shell/utils.rb +0 -138
- data/templates/README +0 -90
- data/templates/files/file.txt +0 -1
- data/templates/helpers/project_name/echo.erb +0 -5
- data/templates/recipes/project_name.rb +0 -20
- data/templates/scripts/project_name.yml +0 -7
- data/templates/templates/template.txt.erb +0 -3
- data/templates/vbox/setup/virtual_box +0 -86
- data/templates/vbox/ssh/id_rsa +0 -27
- data/templates/vbox/ssh/id_rsa.pub +0 -1
data/lib/linecook/shell.rb
DELETED
data/lib/linecook/shell/posix.rb
DELETED
@@ -1,145 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
|
3
|
-
# Generated by Linecook, do not edit.
|
4
|
-
module Linecook
|
5
|
-
module Shell
|
6
|
-
module Posix
|
7
|
-
# :stopdoc:
|
8
|
-
COMMENT_LINE = __LINE__ + 2
|
9
|
-
COMMENT = "self." + ERB.new(<<'END_OF_TEMPLATE', nil, '<>').src
|
10
|
-
# <%= str %>
|
11
|
-
END_OF_TEMPLATE
|
12
|
-
# :startdoc:
|
13
|
-
|
14
|
-
# Writes a comment
|
15
|
-
def comment(str)
|
16
|
-
eval(COMMENT, binding, __FILE__, COMMENT_LINE)
|
17
|
-
nil
|
18
|
-
end
|
19
|
-
|
20
|
-
def _comment(*args, &block) # :nodoc:
|
21
|
-
capture { comment(*args, &block) }
|
22
|
-
end
|
23
|
-
|
24
|
-
# :stopdoc:
|
25
|
-
HEREDOC_LINE = __LINE__ + 2
|
26
|
-
HEREDOC = "self." + ERB.new(<<'END_OF_TEMPLATE', nil, '<>').src
|
27
|
-
<<<%= options[:indent] ? '-' : ' '%><%= options[:quote] ? "\"#{delimiter}\"" : delimiter %>
|
28
|
-
<% yield %>
|
29
|
-
<%= delimiter %>
|
30
|
-
|
31
|
-
END_OF_TEMPLATE
|
32
|
-
# :startdoc:
|
33
|
-
|
34
|
-
# Makes a heredoc statement surrounding the contents of the block. Options:
|
35
|
-
|
36
|
-
#
|
37
|
-
|
38
|
-
# delimiter the delimiter used, by default HEREDOC_n where n increments
|
39
|
-
|
40
|
-
# indent add '-' before the delimiter
|
41
|
-
|
42
|
-
# quote quotes the delimiter
|
43
|
-
|
44
|
-
def heredoc(options={})
|
45
|
-
delimiter = options[:delimiter] || begin
|
46
|
-
@heredoc_count ||= -1
|
47
|
-
"HEREDOC_#{@heredoc_count += 1}"
|
48
|
-
end
|
49
|
-
eval(HEREDOC, binding, __FILE__, HEREDOC_LINE)
|
50
|
-
nil
|
51
|
-
end
|
52
|
-
|
53
|
-
def _heredoc(*args, &block) # :nodoc:
|
54
|
-
capture { heredoc(*args, &block) }
|
55
|
-
end
|
56
|
-
|
57
|
-
# :stopdoc:
|
58
|
-
NOT_IF_LINE = __LINE__ + 2
|
59
|
-
NOT_IF = "self." + ERB.new(<<'END_OF_TEMPLATE', nil, '<>').src
|
60
|
-
only_if("! #{cmd}", &block)
|
61
|
-
END_OF_TEMPLATE
|
62
|
-
# :startdoc:
|
63
|
-
|
64
|
-
def not_if(cmd, &block)
|
65
|
-
eval(NOT_IF, binding, __FILE__, NOT_IF_LINE)
|
66
|
-
nil
|
67
|
-
end
|
68
|
-
|
69
|
-
def _not_if(*args, &block) # :nodoc:
|
70
|
-
capture { not_if(*args, &block) }
|
71
|
-
end
|
72
|
-
|
73
|
-
# :stopdoc:
|
74
|
-
ONLY_IF_LINE = __LINE__ + 2
|
75
|
-
ONLY_IF = "self." + ERB.new(<<'END_OF_TEMPLATE', nil, '<>').src
|
76
|
-
if <%= cmd %>
|
77
|
-
then
|
78
|
-
<% indent { yield } %>
|
79
|
-
fi
|
80
|
-
|
81
|
-
END_OF_TEMPLATE
|
82
|
-
# :startdoc:
|
83
|
-
|
84
|
-
def only_if(cmd)
|
85
|
-
eval(ONLY_IF, binding, __FILE__, ONLY_IF_LINE)
|
86
|
-
nil
|
87
|
-
end
|
88
|
-
|
89
|
-
def _only_if(*args, &block) # :nodoc:
|
90
|
-
capture { only_if(*args, &block) }
|
91
|
-
end
|
92
|
-
|
93
|
-
# :stopdoc:
|
94
|
-
SET_LINE = __LINE__ + 2
|
95
|
-
SET = "self." + ERB.new(<<'END_OF_TEMPLATE', nil, '<>').src
|
96
|
-
<% if block_given? %>
|
97
|
-
<% reset_file = "LINECOOK_RESET_OPTIONS_#{next_count}" %>
|
98
|
-
<%= reset_file %>=`mktemp /tmp/line_cook_reset_fileXXXXXX`
|
99
|
-
set -o | sed 's/\(.*\) on/set -o \1/' | sed 's/\(.*\) off/set +o \1/' > $<%= reset_file %>
|
100
|
-
<% end %><% options.keys.sort_by {|opt| opt.to_s }.each do |opt| %>
|
101
|
-
set <%= options[opt] ? '-' : '+' %>o <%= opt %>
|
102
|
-
<% end %>
|
103
|
-
<% if block_given? %>
|
104
|
-
|
105
|
-
<% indent { yield } %>
|
106
|
-
|
107
|
-
source $<%= reset_file %>
|
108
|
-
<% end %>
|
109
|
-
|
110
|
-
END_OF_TEMPLATE
|
111
|
-
# :startdoc:
|
112
|
-
|
113
|
-
# Sets bash options for the duration of a block. If no block is given,
|
114
|
-
|
115
|
-
# set simply sets the options as specified.
|
116
|
-
def set(options)
|
117
|
-
eval(SET, binding, __FILE__, SET_LINE)
|
118
|
-
nil
|
119
|
-
end
|
120
|
-
|
121
|
-
def _set(*args, &block) # :nodoc:
|
122
|
-
capture { set(*args, &block) }
|
123
|
-
end
|
124
|
-
|
125
|
-
# :stopdoc:
|
126
|
-
UNSET_LINE = __LINE__ + 2
|
127
|
-
UNSET = "self." + ERB.new(<<'END_OF_TEMPLATE', nil, '<>').src
|
128
|
-
<% keys.each do |key| %>
|
129
|
-
unset <%= key %>
|
130
|
-
<% end %>
|
131
|
-
END_OF_TEMPLATE
|
132
|
-
# :startdoc:
|
133
|
-
|
134
|
-
# Unsets a list of variables.
|
135
|
-
def unset(*keys)
|
136
|
-
eval(UNSET, binding, __FILE__, UNSET_LINE)
|
137
|
-
nil
|
138
|
-
end
|
139
|
-
|
140
|
-
def _unset(*args, &block) # :nodoc:
|
141
|
-
capture { unset(*args, &block) }
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
data/lib/linecook/shell/test.rb
DELETED
@@ -1,254 +0,0 @@
|
|
1
|
-
require 'linecook/test'
|
2
|
-
|
3
|
-
module Linecook
|
4
|
-
module Shell
|
5
|
-
# A module for testing shell scripts.
|
6
|
-
#
|
7
|
-
# class ShellTestSample < Test::Unit::TestCase
|
8
|
-
# include Linecook::Test::Shell
|
9
|
-
#
|
10
|
-
# # these are the default sh_test options used
|
11
|
-
# # in tests like test_sh_command_alias
|
12
|
-
# self.sh_test_options = {
|
13
|
-
# :cmd_pattern => '% inspect_argv',
|
14
|
-
# :cmd => 'ruby -e "puts ARGV.inspect"'
|
15
|
-
# }
|
16
|
-
#
|
17
|
-
# def test_echo
|
18
|
-
# assert_equal "goodnight moon", sh("echo goodnight moon").strip
|
19
|
-
# end
|
20
|
-
#
|
21
|
-
# def test_echo_using_sh_test
|
22
|
-
# sh_test %q{
|
23
|
-
# echo goodnight moon
|
24
|
-
# goodnight moon
|
25
|
-
# }
|
26
|
-
# end
|
27
|
-
#
|
28
|
-
# def test_sh_command_alias
|
29
|
-
# sh_test("% inspect_env") do |output|
|
30
|
-
# assert output !~ /NEW_ENV_VAR/
|
31
|
-
# end
|
32
|
-
#
|
33
|
-
# sh_test("NEW_ENV_VAR=blue % inspect_env") do |output|
|
34
|
-
# assert output =~ /NEW_ENV_VAR=blue/
|
35
|
-
# end
|
36
|
-
# end
|
37
|
-
# end
|
38
|
-
#
|
39
|
-
module Test
|
40
|
-
include Linecook::Test
|
41
|
-
|
42
|
-
def setup
|
43
|
-
super
|
44
|
-
@notify_method_name = true
|
45
|
-
end
|
46
|
-
|
47
|
-
# Sets the specified ENV variables and returns the *current* env.
|
48
|
-
# If replace is true, current ENV variables are replaced; otherwise
|
49
|
-
# the new env variables are simply added to the existing set.
|
50
|
-
def set_env(env={}, replace=false)
|
51
|
-
current_env = {}
|
52
|
-
ENV.each_pair do |key, value|
|
53
|
-
current_env[key] = value
|
54
|
-
end
|
55
|
-
|
56
|
-
ENV.clear if replace
|
57
|
-
|
58
|
-
env.each_pair do |key, value|
|
59
|
-
if value.nil?
|
60
|
-
ENV.delete(key)
|
61
|
-
else
|
62
|
-
ENV[key] = value
|
63
|
-
end
|
64
|
-
end if env
|
65
|
-
|
66
|
-
current_env
|
67
|
-
end
|
68
|
-
|
69
|
-
# Sets the specified ENV variables for the duration of the block.
|
70
|
-
# If replace is true, current ENV variables are replaced; otherwise
|
71
|
-
# the new env variables are simply added to the existing set.
|
72
|
-
#
|
73
|
-
# Returns the block return.
|
74
|
-
def with_env(env={}, replace=false)
|
75
|
-
current_env = nil
|
76
|
-
begin
|
77
|
-
current_env = set_env(env, replace)
|
78
|
-
yield
|
79
|
-
ensure
|
80
|
-
if current_env
|
81
|
-
set_env(current_env, true)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
# Returns true if the ENV variable 'VERBOSE' is true.
|
87
|
-
def verbose?
|
88
|
-
verbose = ENV['VERBOSE']
|
89
|
-
verbose && verbose =~ /^true$/i ? true : false
|
90
|
-
end
|
91
|
-
|
92
|
-
# Returns true if the ENV variable 'QUIET' is true or nil. If 'VERBOSE'
|
93
|
-
# and 'QUIET' are both set, verbose wins.
|
94
|
-
def quiet?
|
95
|
-
return false if verbose?
|
96
|
-
|
97
|
-
quiet = ENV['QUIET']
|
98
|
-
quiet.nil? || quiet =~ /^true$/i ? true : false
|
99
|
-
end
|
100
|
-
|
101
|
-
# Executes the command using IO.popen and returns the stdout content.
|
102
|
-
#
|
103
|
-
# ==== Note
|
104
|
-
# On Windows this method requires the {win32-popen3}[http://rubyforge.org/projects/win32utils]
|
105
|
-
# utility. If it is not available, it will have to be installed:
|
106
|
-
#
|
107
|
-
# % gem install win32-open3
|
108
|
-
#
|
109
|
-
def sh(cmd, options={})
|
110
|
-
if @notify_method_name && !quiet?
|
111
|
-
@notify_method_name = false
|
112
|
-
puts
|
113
|
-
puts method_name
|
114
|
-
end
|
115
|
-
|
116
|
-
original_cmd = cmd
|
117
|
-
if cmd_pattern = options[:cmd_pattern]
|
118
|
-
cmd = cmd.sub(cmd_pattern, options[:cmd].to_s)
|
119
|
-
end
|
120
|
-
|
121
|
-
start = Time.now
|
122
|
-
result = with_env(options[:env], options[:replace_env]) do
|
123
|
-
IO.popen(cmd) do |io|
|
124
|
-
yield(io) if block_given?
|
125
|
-
io.read
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
finish = Time.now
|
130
|
-
elapsed = "%.3f" % [finish-start]
|
131
|
-
puts " (#{elapsed}s) #{verbose? ? cmd : original_cmd}" unless quiet?
|
132
|
-
result
|
133
|
-
end
|
134
|
-
|
135
|
-
# Peforms a shell test. Shell tests execute the command and yield the
|
136
|
-
# $stdout result to the block for validation. The command is executed
|
137
|
-
# through sh, ie using IO.popen.
|
138
|
-
#
|
139
|
-
# Options provided to sh_test are merged with the sh_test_options set
|
140
|
-
# for the class.
|
141
|
-
#
|
142
|
-
# ==== Command Aliases
|
143
|
-
#
|
144
|
-
# The options allow specification of a command pattern that gets
|
145
|
-
# replaced with a command alias. Only the first instance of the command
|
146
|
-
# pattern is replaced. In addition, shell tests allow the expected result
|
147
|
-
# to be specified inline with the command. Used together, these allow
|
148
|
-
# multiple tests of a complex command to be specified easily:
|
149
|
-
#
|
150
|
-
# opts = {
|
151
|
-
# :cmd_pattern => '% argv_inspect',
|
152
|
-
# :cmd => 'ruby -e "puts ARGV.inspect"'
|
153
|
-
# }
|
154
|
-
#
|
155
|
-
# sh_test %Q{
|
156
|
-
# % argv_inspect goodnight moon
|
157
|
-
# ["goodnight", "moon"]
|
158
|
-
# }, opts
|
159
|
-
#
|
160
|
-
# sh_test %Q{
|
161
|
-
# % argv_inspect hello world
|
162
|
-
# ["hello", "world"]
|
163
|
-
# }, opts
|
164
|
-
#
|
165
|
-
# ==== Indents
|
166
|
-
#
|
167
|
-
# To improve the readability of tests, sh_test will lstrip each line in the
|
168
|
-
# expected output to the same degree as the command line. So for instance
|
169
|
-
# these all pass:
|
170
|
-
#
|
171
|
-
# sh_test %Q{
|
172
|
-
# % argv_inspect hello world
|
173
|
-
# ["hello", "world"]
|
174
|
-
# }, opts
|
175
|
-
#
|
176
|
-
# sh_test %Q{
|
177
|
-
# % argv_inspect hello world
|
178
|
-
# ["hello", "world"]
|
179
|
-
# }, opts
|
180
|
-
#
|
181
|
-
# sh_test %Q{
|
182
|
-
# % argv_inspect hello world
|
183
|
-
# ["hello", "world"]
|
184
|
-
# }, opts
|
185
|
-
#
|
186
|
-
# Turn off indent stripping by specifying :indent => false.
|
187
|
-
#
|
188
|
-
# ==== ENV variables
|
189
|
-
#
|
190
|
-
# Options may specify a hash of env variables that will be set in the
|
191
|
-
# subprocess.
|
192
|
-
#
|
193
|
-
# sh_test %Q{
|
194
|
-
# ruby -e "puts ENV['SAMPLE']"
|
195
|
-
# value
|
196
|
-
# }, :env => {'SAMPLE' => 'value'}
|
197
|
-
#
|
198
|
-
# Note it is better to specify env variables in this way rather than
|
199
|
-
# through the command trick 'VAR=value cmd ...', as that syntax does
|
200
|
-
# not work on Windows. As a point of interest, see
|
201
|
-
# http://gist.github.com/107363 for a demonstration of ENV
|
202
|
-
# variables being inherited by subprocesses.
|
203
|
-
#
|
204
|
-
def sh_test(cmd, options={})
|
205
|
-
options = sh_test_options.merge(options)
|
206
|
-
|
207
|
-
# strip indentiation if possible
|
208
|
-
if cmd =~ /\A(?:\s*?\n)?( *)(.*?\n)(.*)\z/m
|
209
|
-
indent, cmd, expected = $1, $2, $3
|
210
|
-
cmd.strip!
|
211
|
-
|
212
|
-
if indent.length > 0 && options[:indents]
|
213
|
-
expected.gsub!(/^ {0,#{indent.length}}/, '')
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
result = sh(cmd, options)
|
218
|
-
|
219
|
-
assert_equal(expected, result, cmd) if expected
|
220
|
-
yield(result) if block_given?
|
221
|
-
result
|
222
|
-
end
|
223
|
-
|
224
|
-
# Similar to sh_test, but matches the output against each of the
|
225
|
-
# regexps. A hash of sh options can be provided as the last argument;
|
226
|
-
# it will be merged with the default sh_test_options.
|
227
|
-
#
|
228
|
-
# The output is yielded to the block, if given, for further validation.
|
229
|
-
# Returns the sh output.
|
230
|
-
def sh_match(cmd, *regexps)
|
231
|
-
options = regexps.last.kind_of?(Hash) ? regexps.pop : {}
|
232
|
-
options = sh_test_options.merge(options)
|
233
|
-
result = sh(cmd, options)
|
234
|
-
|
235
|
-
regexps.each do |regexp|
|
236
|
-
assert_match regexp, result, cmd
|
237
|
-
end
|
238
|
-
yield(result) if block_given?
|
239
|
-
result
|
240
|
-
end
|
241
|
-
|
242
|
-
# Returns a hash of default sh_test options.
|
243
|
-
def sh_test_options
|
244
|
-
{
|
245
|
-
:cmd_pattern => '% ',
|
246
|
-
:cmd => '2>&1 ',
|
247
|
-
:indents => true,
|
248
|
-
:env => {},
|
249
|
-
:replace_env => false
|
250
|
-
}
|
251
|
-
end
|
252
|
-
end
|
253
|
-
end
|
254
|
-
end
|
data/lib/linecook/shell/unix.rb
DELETED
@@ -1,117 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
|
3
|
-
# Generated by Linecook, do not edit.
|
4
|
-
module Linecook
|
5
|
-
module Shell
|
6
|
-
module Unix
|
7
|
-
require 'linecook/shell/posix'
|
8
|
-
include Posix
|
9
|
-
# :stopdoc:
|
10
|
-
CAT_LINE = __LINE__ + 2
|
11
|
-
CAT = "self." + ERB.new(<<'END_OF_TEMPLATE', nil, '<>').src
|
12
|
-
cat<% sources.each do |source| %> "<%= source %>"<% end %>
|
13
|
-
END_OF_TEMPLATE
|
14
|
-
# :startdoc:
|
15
|
-
|
16
|
-
def cat(*sources)
|
17
|
-
eval(CAT, binding, __FILE__, CAT_LINE)
|
18
|
-
nil
|
19
|
-
end
|
20
|
-
|
21
|
-
def _cat(*args, &block) # :nodoc:
|
22
|
-
capture { cat(*args, &block) }
|
23
|
-
end
|
24
|
-
|
25
|
-
# :stopdoc:
|
26
|
-
CHMOD_LINE = __LINE__ + 2
|
27
|
-
CHMOD = "self." + ERB.new(<<'END_OF_TEMPLATE', nil, '<>').src
|
28
|
-
<% if mode %>
|
29
|
-
chmod <%= mode %> "<%= target %>"
|
30
|
-
<% check_status %>
|
31
|
-
<% end %>
|
32
|
-
END_OF_TEMPLATE
|
33
|
-
# :startdoc:
|
34
|
-
|
35
|
-
def chmod(target, mode=nil)
|
36
|
-
eval(CHMOD, binding, __FILE__, CHMOD_LINE)
|
37
|
-
nil
|
38
|
-
end
|
39
|
-
|
40
|
-
def _chmod(*args, &block) # :nodoc:
|
41
|
-
capture { chmod(*args, &block) }
|
42
|
-
end
|
43
|
-
|
44
|
-
# :stopdoc:
|
45
|
-
CHOWN_LINE = __LINE__ + 2
|
46
|
-
CHOWN = "self." + ERB.new(<<'END_OF_TEMPLATE', nil, '<>').src
|
47
|
-
<% if user || group %>
|
48
|
-
chown <%= user %>:<%= group %> "<%= target %>"
|
49
|
-
<% check_status %>
|
50
|
-
<% end %>
|
51
|
-
END_OF_TEMPLATE
|
52
|
-
# :startdoc:
|
53
|
-
|
54
|
-
def chown(target, user=nil, group=nil)
|
55
|
-
eval(CHOWN, binding, __FILE__, CHOWN_LINE)
|
56
|
-
nil
|
57
|
-
end
|
58
|
-
|
59
|
-
def _chown(*args, &block) # :nodoc:
|
60
|
-
capture { chown(*args, &block) }
|
61
|
-
end
|
62
|
-
|
63
|
-
# :stopdoc:
|
64
|
-
ECHO_LINE = __LINE__ + 2
|
65
|
-
ECHO = "self." + ERB.new(<<'END_OF_TEMPLATE', nil, '<>').src
|
66
|
-
echo '<%= args.join(" ") %>'
|
67
|
-
END_OF_TEMPLATE
|
68
|
-
# :startdoc:
|
69
|
-
|
70
|
-
# Echos input
|
71
|
-
def echo(*args)
|
72
|
-
eval(ECHO, binding, __FILE__, ECHO_LINE)
|
73
|
-
nil
|
74
|
-
end
|
75
|
-
|
76
|
-
def _echo(*args, &block) # :nodoc:
|
77
|
-
capture { echo(*args, &block) }
|
78
|
-
end
|
79
|
-
|
80
|
-
# :stopdoc:
|
81
|
-
LN_S_LINE = __LINE__ + 2
|
82
|
-
LN_S = "self." + ERB.new(<<'END_OF_TEMPLATE', nil, '<>').src
|
83
|
-
ln -sf "<%= source %>" "<%= target %>"
|
84
|
-
<% check_status %>
|
85
|
-
|
86
|
-
END_OF_TEMPLATE
|
87
|
-
# :startdoc:
|
88
|
-
|
89
|
-
def ln_s(source, target)
|
90
|
-
eval(LN_S, binding, __FILE__, LN_S_LINE)
|
91
|
-
nil
|
92
|
-
end
|
93
|
-
|
94
|
-
def _ln_s(*args, &block) # :nodoc:
|
95
|
-
capture { ln_s(*args, &block) }
|
96
|
-
end
|
97
|
-
|
98
|
-
# :stopdoc:
|
99
|
-
RM_LINE = __LINE__ + 2
|
100
|
-
RM = "self." + ERB.new(<<'END_OF_TEMPLATE', nil, '<>').src
|
101
|
-
<% only_if %Q{ls -l "#{path}"} do %>
|
102
|
-
rm <% if opts %><%= opts %> <% end %>"<%= path %>"
|
103
|
-
<% end %>
|
104
|
-
END_OF_TEMPLATE
|
105
|
-
# :startdoc:
|
106
|
-
|
107
|
-
def rm(path, opts=nil)
|
108
|
-
eval(RM, binding, __FILE__, RM_LINE)
|
109
|
-
nil
|
110
|
-
end
|
111
|
-
|
112
|
-
def _rm(*args, &block) # :nodoc:
|
113
|
-
capture { rm(*args, &block) }
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|