ratch 1.1.0 → 2.0.0
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.
- checksums.yaml +7 -0
- data/HISTORY.rdoc +87 -0
- data/LICENSE.txt +204 -0
- data/README.rdoc +133 -0
- data/bin/ludo +32 -0
- data/bin/ratch +1 -8
- data/lib/ratch/batch.rb +541 -0
- data/lib/ratch/core_ext/facets.rb +16 -1
- data/lib/ratch/core_ext/filetest.rb +29 -0
- data/lib/ratch/core_ext/{string.rb → to_actual_filename.rb} +0 -23
- data/lib/ratch/core_ext/to_console.rb +30 -12
- data/lib/ratch/core_ext/{object.rb → to_yamlfrag.rb} +1 -0
- data/lib/ratch/core_ext/unfold_paragraphs.rb +27 -0
- data/lib/ratch/core_ext.rb +1 -4
- data/lib/ratch/file_list.rb +402 -0
- data/lib/ratch/script/help.rb +84 -0
- data/lib/ratch/script.rb +99 -5
- data/lib/ratch/shell.rb +621 -0
- data/lib/ratch/utils/cli.rb +49 -0
- data/lib/ratch/utils/config.rb +52 -0
- data/lib/ratch/{emailer.rb → utils/email.rb} +58 -98
- data/lib/ratch/utils/rdoc.rb +45 -0
- data/lib/ratch/utils/tar.rb +132 -0
- data/lib/ratch/utils/xdg.rb +38 -0
- data/lib/ratch/utils/zlib.rb +55 -0
- data/lib/ratch/version.rb +3 -0
- data/lib/ratch.rb +12 -0
- metadata +160 -126
- data/COPYING +0 -22
- data/HISTORY +0 -6
- data/MANIFEST +0 -53
- data/NEWS +0 -12
- data/README +0 -87
- data/VERSION +0 -1
- data/demo/tryme-task.ratch +0 -12
- data/demo/tryme1.ratch +0 -6
- data/doc/log/basic_stats/index.html +0 -39
- data/doc/log/notes.xml +0 -18
- data/doc/log/stats.log +0 -14
- data/doc/log/syntax.log +0 -0
- data/doc/log/testunit.log +0 -156
- data/lib/ratch/commandline.rb +0 -16
- data/lib/ratch/core_ext/pathname.rb +0 -38
- data/lib/ratch/dsl.rb +0 -420
- data/lib/ratch/index.rb +0 -4
- data/lib/ratch/io.rb +0 -116
- data/lib/ratch/plugin.rb +0 -65
- data/lib/ratch/service.rb +0 -33
- data/lib/ratch/task.rb +0 -249
- data/lib/ratch/task2.rb +0 -298
- data/man/ratch.1 +0 -28
- data/meta/abstract +0 -4
- data/meta/author +0 -1
- data/meta/contact +0 -1
- data/meta/homepage +0 -1
- data/meta/name +0 -1
- data/meta/requires +0 -4
- data/meta/summary +0 -1
- data/test/README +0 -1
- data/test/test_helper.rb +0 -4
- data/test/test_task.rb +0 -46
|
@@ -1,11 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
require 'facets/net/smtp_tls'
|
|
3
|
-
rescue LoadError
|
|
4
|
-
require 'net/smtp'
|
|
5
|
-
end
|
|
1
|
+
module Ratch
|
|
6
2
|
|
|
3
|
+
# The Mail utility module provides an easy to use +email+ method.
|
|
4
|
+
module EmailUtils
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
# Email function to easily send out an email.
|
|
7
|
+
#
|
|
8
|
+
# Settings:
|
|
9
|
+
#
|
|
10
|
+
# subject Subject of email message.
|
|
11
|
+
# from Message FROM address [email].
|
|
12
|
+
# to Email address to send announcemnt.
|
|
13
|
+
# server Email server to route message.
|
|
14
|
+
# port Email server's port.
|
|
15
|
+
# domain Email server's domain name.
|
|
16
|
+
# account Email account name if needed.
|
|
17
|
+
# password Password for login..
|
|
18
|
+
# login Login type: plain, cram_md5 or login [plain].
|
|
19
|
+
# secure Uses TLS security, true or false? [false]
|
|
20
|
+
# message Mesage to send -or-
|
|
21
|
+
# file File that contains message.
|
|
22
|
+
#
|
|
23
|
+
def email(options)
|
|
24
|
+
options[:file] = localize(options[:file]) if options[:file]
|
|
25
|
+
emailer = Emailer.new(options.rekey)
|
|
26
|
+
success = emailer.email
|
|
27
|
+
if Exception === success
|
|
28
|
+
puts "Email failed: #{success.message}."
|
|
29
|
+
else
|
|
30
|
+
puts "Email sent successfully to #{success.join(';')}."
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
9
35
|
|
|
10
36
|
# Emailer class makes it easy send out an email.
|
|
11
37
|
#
|
|
@@ -46,8 +72,7 @@ module Ratch
|
|
|
46
72
|
end
|
|
47
73
|
|
|
48
74
|
def new_with_environment(options={})
|
|
49
|
-
environment_options.merge(options.rekey)
|
|
50
|
-
new(options)
|
|
75
|
+
new(environment_options.merge(options.rekey))
|
|
51
76
|
end
|
|
52
77
|
end
|
|
53
78
|
|
|
@@ -67,6 +92,8 @@ module Ratch
|
|
|
67
92
|
|
|
68
93
|
#
|
|
69
94
|
def initialize(options={})
|
|
95
|
+
require_smtp
|
|
96
|
+
|
|
70
97
|
options = options.rekey
|
|
71
98
|
|
|
72
99
|
if not options[:server]
|
|
@@ -105,7 +132,7 @@ module Ratch
|
|
|
105
132
|
#
|
|
106
133
|
|
|
107
134
|
def email(options={})
|
|
108
|
-
options.rekey
|
|
135
|
+
options = options.rekey
|
|
109
136
|
|
|
110
137
|
message = options[:message] || self.message
|
|
111
138
|
subject = options[:subject] || self.subject
|
|
@@ -119,32 +146,33 @@ module Ratch
|
|
|
119
146
|
raise ArgumentError, "missing email field -- mailto" unless mailto
|
|
120
147
|
raise ArgumentError, "missing email field -- subject" unless subject
|
|
121
148
|
|
|
122
|
-
passwd
|
|
149
|
+
passwd = self.passwd
|
|
123
150
|
|
|
124
151
|
mailto = [mailto].flatten.compact
|
|
125
152
|
|
|
126
|
-
msg =
|
|
153
|
+
msg = String.new
|
|
127
154
|
msg << "From: #{from}\n"
|
|
128
|
-
msg << "To: #{mailto.join('
|
|
155
|
+
msg << "To: #{mailto.join(', ')}\n"
|
|
129
156
|
msg << "Subject: #{subject}\n"
|
|
130
|
-
msg << ""
|
|
131
|
-
msg << message
|
|
157
|
+
msg << "\n"
|
|
158
|
+
msg << message.to_s
|
|
132
159
|
|
|
133
160
|
#p server, port, domain, account, passwd, login, secure if verbose?
|
|
134
161
|
|
|
135
162
|
begin
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
smtp.send_message(msg, from, mailto)
|
|
140
|
-
end
|
|
163
|
+
smtp = Net::SMTP.new(server, port)
|
|
164
|
+
if secure
|
|
165
|
+
port == 465 ? smtp.enable_tls : smtp.enable_starttls
|
|
141
166
|
else
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
167
|
+
smtp.disable_starttls
|
|
168
|
+
end
|
|
169
|
+
if passwd.to_s.empty?
|
|
170
|
+
smtp.start(domain){ |s| s.send_message(msg, from, mailto) }
|
|
171
|
+
else
|
|
172
|
+
smtp.start(domain, account, passwd, login){ |s| s.send_message(msg, from, mailto) }
|
|
145
173
|
end
|
|
146
174
|
return mailto
|
|
147
|
-
rescue
|
|
175
|
+
rescue StandardError => e
|
|
148
176
|
return e
|
|
149
177
|
end
|
|
150
178
|
end
|
|
@@ -171,81 +199,13 @@ module Ratch
|
|
|
171
199
|
return inp
|
|
172
200
|
end
|
|
173
201
|
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
=begin
|
|
181
|
-
# Email function to easily send out an email.
|
|
182
|
-
#
|
|
183
|
-
# Settings:
|
|
184
202
|
#
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
# port Email server's port.
|
|
190
|
-
# domain Email server's domain name.
|
|
191
|
-
# account Email account name if needed.
|
|
192
|
-
# password Password for login..
|
|
193
|
-
# login Login type: plain, cram_md5 or login [plain].
|
|
194
|
-
# secure Uses TLS security, true or false? [false]
|
|
195
|
-
# message Mesage to send -or-
|
|
196
|
-
# file File that contains message.
|
|
197
|
-
#
|
|
198
|
-
def email(message, settings)
|
|
199
|
-
settings ||= {}
|
|
200
|
-
settings.rekey!
|
|
201
|
-
|
|
202
|
-
server = settings[:server]
|
|
203
|
-
account = settings[:account] || ENV['EMAIL_ACCOUNT']
|
|
204
|
-
passwd = settings[:password] || ENV['EMAIL_PASSWORD']
|
|
205
|
-
login = settings[:login].to_sym
|
|
206
|
-
subject = settings[:subject]
|
|
207
|
-
mail_to = settings[:to] || settings[:mail_to]
|
|
208
|
-
mail_from = settings[:from] || settings[:mail_from]
|
|
209
|
-
secure = settings[:secure]
|
|
210
|
-
domain = settings[:domain] || server
|
|
211
|
-
|
|
212
|
-
port ||= (secure ? 465 : 25)
|
|
213
|
-
account ||= mail_from
|
|
214
|
-
login ||= :plain
|
|
215
|
-
|
|
216
|
-
#mail_to = nil if mail_to.empty?
|
|
217
|
-
|
|
218
|
-
raise ArgumentError, "missing email field -- server" unless server
|
|
219
|
-
raise ArgumentError, "missing email field -- account" unless account
|
|
220
|
-
raise ArgumentError, "missing email field -- subject" unless subject
|
|
221
|
-
raise ArgumentError, "missing email field -- to" unless mail_to
|
|
222
|
-
raise ArgumentError, "missing email field -- from" unless mail_from
|
|
223
|
-
|
|
224
|
-
passwd ||= password(account)
|
|
225
|
-
|
|
226
|
-
mail_to = [mail_to].flatten.compact
|
|
227
|
-
|
|
228
|
-
msg = ""
|
|
229
|
-
msg << "From: #{mail_from}\n"
|
|
230
|
-
msg << "To: #{mail_to.join(';')}\n"
|
|
231
|
-
msg << "Subject: #{subject}\n"
|
|
232
|
-
msg << ""
|
|
233
|
-
msg << message
|
|
234
|
-
|
|
235
|
-
begin
|
|
236
|
-
Net::SMTP.enable_tls if Net::SMTP.respond_to?(:enable_tls) and secure
|
|
237
|
-
Net::SMTP.start(server, port, domain, account, passwd, login) do |s|
|
|
238
|
-
s.send_message( msg, mail_from, mail_to )
|
|
239
|
-
end
|
|
240
|
-
puts "Email sent successfully to #{mail_to.join(';')}."
|
|
241
|
-
return true
|
|
242
|
-
rescue => e
|
|
243
|
-
if trace?
|
|
244
|
-
raise e
|
|
245
|
-
else
|
|
246
|
-
abort "Email delivery failed."
|
|
247
|
-
end
|
|
248
|
-
end
|
|
203
|
+
def require_smtp
|
|
204
|
+
require 'net/smtp'
|
|
205
|
+
rescue LoadError
|
|
206
|
+
raise LoadError, "the `net-smtp` gem is needed to send email"
|
|
249
207
|
end
|
|
250
|
-
=end
|
|
251
208
|
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
module Ratch
|
|
2
|
+
|
|
3
|
+
# Provides a pure-Ruby method for generating RDocs.
|
|
4
|
+
module RDocUtils
|
|
5
|
+
|
|
6
|
+
DEFAULT_RDOC_OPTIONS = {
|
|
7
|
+
:quiet => true
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
# RDoc command.
|
|
11
|
+
#
|
|
12
|
+
# :call-seq:
|
|
13
|
+
# rdoc(file1, file2, ..., :opt1 => val1, ...)
|
|
14
|
+
#
|
|
15
|
+
def rdoc(*files)
|
|
16
|
+
require 'rdoc/rdoc'
|
|
17
|
+
|
|
18
|
+
options = Hash===files.last ? files.pop : {}
|
|
19
|
+
options = options.rekey(&:to_s)
|
|
20
|
+
|
|
21
|
+
title = options.delete('T')
|
|
22
|
+
options['title'] ||= title if title
|
|
23
|
+
|
|
24
|
+
# apply pom (todo?)
|
|
25
|
+
#options['title'] ||= metadata.title
|
|
26
|
+
|
|
27
|
+
options = DEFAULT_RDOC_OPTIONS.rekey(&:to_s).merge(options)
|
|
28
|
+
|
|
29
|
+
locally do
|
|
30
|
+
rdoc = RDoc::RDoc.new
|
|
31
|
+
opts = options.to_argv + files
|
|
32
|
+
$stderr.puts("rdoc " + opts.join(' ')) if ($VERBOSE || $DEBUG)
|
|
33
|
+
disable_warnings do
|
|
34
|
+
rdoc.document(options.to_argv + files)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
#
|
|
40
|
+
# TODO: Implement ri doc generator.
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
require 'ratch/utils/zlib'
|
|
2
|
+
|
|
3
|
+
module Ratch
|
|
4
|
+
|
|
5
|
+
# Utility methods for working with tar archives. They use the tar
|
|
6
|
+
# reader and writer that come with RubyGems, so nothing else is needed.
|
|
7
|
+
#
|
|
8
|
+
# Regular files and directories are archived; links and special files
|
|
9
|
+
# are skipped.
|
|
10
|
+
module TarUtils
|
|
11
|
+
|
|
12
|
+
# When included, include ZlibUtils too.
|
|
13
|
+
def self.included(base)
|
|
14
|
+
require 'rubygems/package'
|
|
15
|
+
base.__send__(:include, ZlibUtils)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
#
|
|
19
|
+
def self.extended(base)
|
|
20
|
+
require 'rubygems/package'
|
|
21
|
+
base.extend(ZlibUtils)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Archive a folder as FOLDER.tar, or as +file+. Returns the archive's
|
|
25
|
+
# path.
|
|
26
|
+
def tar(folder, file=nil, options={})
|
|
27
|
+
options, file = file, nil if Hash === file
|
|
28
|
+
noop, verbose = *util_options(options)
|
|
29
|
+
|
|
30
|
+
file ||= File.basename(localize(folder)) + '.tar'
|
|
31
|
+
|
|
32
|
+
$stderr.puts "tar -cf #{file} #{folder}" if verbose
|
|
33
|
+
|
|
34
|
+
File.open(localize(file), 'wb'){ |io| tar_pack(folder, io) } unless noop
|
|
35
|
+
|
|
36
|
+
path(file)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Unpack a tar archive into the working directory. Returns the paths
|
|
40
|
+
# unpacked.
|
|
41
|
+
def untar(file, options={})
|
|
42
|
+
noop, verbose = *util_options(options)
|
|
43
|
+
|
|
44
|
+
$stderr.puts "tar -xf #{file}" if verbose
|
|
45
|
+
|
|
46
|
+
return [] if noop
|
|
47
|
+
|
|
48
|
+
File.open(localize(file), 'rb'){ |io| tar_unpack(io) }
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Archive a folder as FOLDER.tar.gz, or as +file+. Returns the
|
|
52
|
+
# archive's path.
|
|
53
|
+
def tar_gzip(folder, file=nil, options={})
|
|
54
|
+
options, file = file, nil if Hash === file
|
|
55
|
+
noop, verbose = *util_options(options)
|
|
56
|
+
|
|
57
|
+
file ||= File.basename(localize(folder)) + '.tar.gz'
|
|
58
|
+
|
|
59
|
+
$stderr.puts "tar -czf #{file} #{folder}" if verbose
|
|
60
|
+
|
|
61
|
+
Zlib::GzipWriter.open(localize(file)){ |gz| tar_pack(folder, gz) } unless noop
|
|
62
|
+
|
|
63
|
+
path(file)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
alias_method :tar_z, :tar_gzip
|
|
67
|
+
|
|
68
|
+
# Unpack a gzipped tar archive into the working directory. Returns
|
|
69
|
+
# the paths unpacked.
|
|
70
|
+
def untar_gzip(file, options={})
|
|
71
|
+
noop, verbose = *util_options(options)
|
|
72
|
+
|
|
73
|
+
$stderr.puts "tar -xzf #{file}" if verbose
|
|
74
|
+
|
|
75
|
+
return [] if noop
|
|
76
|
+
|
|
77
|
+
Zlib::GzipReader.open(localize(file)){ |gz| tar_unpack(gz) }
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
alias_method :untar_z, :untar_gzip
|
|
81
|
+
|
|
82
|
+
private
|
|
83
|
+
|
|
84
|
+
# Write the folder and all in it to +io+ as a tar archive, with paths
|
|
85
|
+
# as given, relative to the working directory.
|
|
86
|
+
def tar_pack(folder, io)
|
|
87
|
+
folder = folder.to_s.chomp('/')
|
|
88
|
+
Gem::Package::TarWriter.new(io) do |tar|
|
|
89
|
+
([folder] + glob(File.join(folder, '**/*'), File::FNM_DOTMATCH)).uniq.each do |entry|
|
|
90
|
+
next if entry =~ /(\A|\/)\.\.?\z/
|
|
91
|
+
real = localize(entry)
|
|
92
|
+
stat = File.lstat(real)
|
|
93
|
+
if stat.directory?
|
|
94
|
+
tar.mkdir(entry, stat.mode & 0777)
|
|
95
|
+
elsif stat.file?
|
|
96
|
+
tar.add_file_simple(entry, stat.mode & 0777, stat.size) do |out|
|
|
97
|
+
File.open(real, 'rb'){ |f| IO.copy_stream(f, out) }
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Unpack the tar archive read from +io+ into the working directory.
|
|
105
|
+
# An entry that would land outside it is refused.
|
|
106
|
+
def tar_unpack(io)
|
|
107
|
+
paths = []
|
|
108
|
+
Gem::Package::TarReader.new(io) do |tar|
|
|
109
|
+
tar.each do |entry|
|
|
110
|
+
name = entry.full_name
|
|
111
|
+
dest = File.expand_path(File.join(work.to_s, name))
|
|
112
|
+
unless dest == work.to_s || dest.start_with?(work.to_s + '/')
|
|
113
|
+
raise ArgumentError, "tar entry outside of the directory -- #{name}"
|
|
114
|
+
end
|
|
115
|
+
if entry.directory?
|
|
116
|
+
::FileUtils.mkdir_p(dest)
|
|
117
|
+
elsif entry.file?
|
|
118
|
+
::FileUtils.mkdir_p(File.dirname(dest))
|
|
119
|
+
File.open(dest, 'wb'){ |f| IO.copy_stream(entry, f) }
|
|
120
|
+
File.chmod(entry.header.mode & 0777, dest)
|
|
121
|
+
else
|
|
122
|
+
next
|
|
123
|
+
end
|
|
124
|
+
paths << name
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
paths
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module Ratch
|
|
2
|
+
|
|
3
|
+
# The XDG utility module provides access ot the XDG library functions.
|
|
4
|
+
# This module requires the `xdg` gem.
|
|
5
|
+
#
|
|
6
|
+
# This module simply maps the #xdg method to the XDG function module.
|
|
7
|
+
#
|
|
8
|
+
# NOTE: This module is non-essential since one can just use
|
|
9
|
+
# the XDG module directly, however we want to encourage the
|
|
10
|
+
# use XDG, so it's been provided to encourage that in the context
|
|
11
|
+
# of a Ratch script.
|
|
12
|
+
#
|
|
13
|
+
module XDGUtils
|
|
14
|
+
|
|
15
|
+
def self.included(base)
|
|
16
|
+
begin
|
|
17
|
+
require 'xdg'
|
|
18
|
+
rescue LoadError
|
|
19
|
+
raise LoadError, "the `xdg` gem is needed to use the XDGUtils module"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.extended(base)
|
|
24
|
+
included(base)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Simple access to XDG function module.
|
|
28
|
+
#
|
|
29
|
+
# xdg.config.home #=> "~/.config"
|
|
30
|
+
#
|
|
31
|
+
def xdg
|
|
32
|
+
XDG
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
module Ratch
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
module ZlibUtils
|
|
5
|
+
|
|
6
|
+
#
|
|
7
|
+
def self.included(base)
|
|
8
|
+
require 'zlib'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.extended(base)
|
|
12
|
+
included(base)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Create a gzip file.
|
|
16
|
+
def gzip(file, tofile=nil, options={})
|
|
17
|
+
options, tofile = tofile, nil if Hash === tofile
|
|
18
|
+
noop, verbose = *util_options(options)
|
|
19
|
+
|
|
20
|
+
tofile ||= file.to_s + '.gz'
|
|
21
|
+
|
|
22
|
+
$stderr.puts "gzip #{file}" if verbose
|
|
23
|
+
|
|
24
|
+
file = localize(file)
|
|
25
|
+
tofile = localize(tofile)
|
|
26
|
+
|
|
27
|
+
Zlib::GzipWriter.open(tofile) do |gz|
|
|
28
|
+
gz.write(File.read(file))
|
|
29
|
+
end unless noop
|
|
30
|
+
|
|
31
|
+
return tofile
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Unpack a gzip file.
|
|
35
|
+
def ungzip(file, options={})
|
|
36
|
+
noop, verbose = *util_options(options)
|
|
37
|
+
|
|
38
|
+
fname = file.to_s.chomp(File.extname(file.to_s))
|
|
39
|
+
|
|
40
|
+
$stderr.puts "ungzip #{file}" if verbose
|
|
41
|
+
|
|
42
|
+
fname = localize(fname)
|
|
43
|
+
file = localize(file)
|
|
44
|
+
|
|
45
|
+
Zlib::GzipReader.open(file) do |gz|
|
|
46
|
+
File.open(fname, 'wb'){ |f| f << gz.read }
|
|
47
|
+
end unless noop
|
|
48
|
+
|
|
49
|
+
return fname
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
55
|
+
|
data/lib/ratch.rb
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require 'ratch/version'
|
|
2
|
+
require 'ratch/script'
|
|
3
|
+
|
|
4
|
+
# Utility extension modules, to include in a Shell subclass or extend a
|
|
5
|
+
# shell with. Each loads what it depends on only when it is used.
|
|
6
|
+
require 'ratch/utils/cli'
|
|
7
|
+
require 'ratch/utils/config'
|
|
8
|
+
require 'ratch/utils/zlib'
|
|
9
|
+
require 'ratch/utils/tar'
|
|
10
|
+
require 'ratch/utils/rdoc'
|
|
11
|
+
require 'ratch/utils/email'
|
|
12
|
+
require 'ratch/utils/xdg'
|