ratch 1.2.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/README.rdoc +86 -66
- data/bin/ludo +26 -10
- data/lib/ratch/batch.rb +115 -74
- data/lib/ratch/core_ext/facets.rb +2 -1
- data/lib/ratch/core_ext/to_console.rb +11 -11
- data/lib/ratch/file_list.rb +6 -15
- data/lib/ratch/script.rb +1 -1
- data/lib/ratch/shell.rb +356 -518
- data/lib/ratch/utils/config.rb +4 -4
- data/lib/ratch/utils/email.rb +20 -97
- data/lib/ratch/utils/rdoc.rb +4 -7
- data/lib/ratch/utils/tar.rb +94 -50
- data/lib/ratch/utils/xdg.rb +2 -3
- data/lib/ratch/utils/zlib.rb +5 -4
- data/lib/ratch/version.rb +3 -0
- data/lib/ratch.rb +8 -24
- metadata +134 -157
- data/.ruby +0 -99
- data/History.rdoc +0 -35
- data/License.txt +0 -204
- data/Version +0 -1
- data/lib/ratch/console.rb +0 -199
- data/lib/ratch/system.rb +0 -15
- data/lib/ratch/utils/ftp.rb +0 -134
- data/lib/ratch/utils/pom.rb +0 -22
- data/lib/ratch.yml +0 -99
- data/man/ratch.1 +0 -28
- data/spec/01_shell.rdoc +0 -198
- data/spec/02_script.rdoc +0 -34
- data/spec/03_batch.rdoc +0 -71
- data/spec/04_system.rdoc +0 -3
- data/spec/applique/array.rb +0 -8
- data/spec/applique/setup.rb +0 -20
- data/test/case_batch.rb +0 -63
- data/test/case_shell.rb +0 -46
- data/test/core_ext/case_pathname.rb +0 -361
- data/test/helper.rb +0 -4
- data/test/utils/case_cli.rb +0 -6
- data/test/utils/case_config.rb +0 -12
- data/test/utils/case_email.rb +0 -10
- data/test/utils/case_ftp.rb +0 -6
- data/test/utils/case_pom.rb +0 -17
- data/test/utils/case_rdoc.rb +0 -23
- data/test/utils/case_tar.rb +0 -6
- data/test/utils/case_zlib.rb +0 -11
- data/test/utils/fixtures/pom_sample/Profile +0 -4
- data/test/utils/fixtures/rdoc_sample/README.rdoc +0 -4
- data/test/utils/fixtures/rdoc_sample/lib/rdoc_sample/rdoc_sample.rb +0 -9
- /data/{COPYING → LICENSE.txt} +0 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 79b7a105b218cf3320ccaf308cf6fd164a389d012763a591cf5b69bfa8025786
|
|
4
|
+
data.tar.gz: 17c463febd50d32012df3b54cb803ecd39ea68c269654c9396b8b83ac9ebe7cc
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: fe619e0d3ce099896acf859ab58f61a4a5e7690a30ce2affc685624eee32d02877b654b18855c7c58cc23698d0b942a2266d20fee72be5d74f99525a2efc20af
|
|
7
|
+
data.tar.gz: 4988d90ff2722d1214a6d542ef02def96502b177672bc52a2d0fcb0440b9338d9ee61bf3069a068c98f985956b7812a62657a68c940ac406aeb2211ae992a920
|
data/HISTORY.rdoc
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
= RELEASE HISTORY
|
|
2
|
+
|
|
3
|
+
== 2.0.0 | 2026-11-25
|
|
4
|
+
|
|
5
|
+
Ratch is revived, for Ruby 3.1 and up. Neither 1.2.0 nor the unreleased
|
|
6
|
+
code after it ran on Ruby 3: file operations failed on their options, and
|
|
7
|
+
the development line didn't load.
|
|
8
|
+
|
|
9
|
+
Changes:
|
|
10
|
+
|
|
11
|
+
* Shell no longer changes the process's working directory to do its work.
|
|
12
|
+
Paths are resolved against the shell's own directory, so shells at
|
|
13
|
+
different directories can be used side by side and from threads. Only
|
|
14
|
+
+cd+ with a block changes the process's directory, for the block.
|
|
15
|
+
* Shell does its own tracing, to standard error, with paths as they were
|
|
16
|
+
given.
|
|
17
|
+
* Shell#/ gives a new shell at the sub-directory, in the same mode.
|
|
18
|
+
* Shell#sh takes a command in parts as well as a string, returns whether
|
|
19
|
+
it succeeded, and drops the command's output in quiet mode.
|
|
20
|
+
* Shell#glob gives paths relative to the shell's directory.
|
|
21
|
+
* Shell#batch gives a Batch in the shell's mode.
|
|
22
|
+
* Modes can be given for one command (:noop, :trace, :dryrun).
|
|
23
|
+
* Batch.new takes options as its last argument; a destination is taken
|
|
24
|
+
from the batch's directory.
|
|
25
|
+
* TarUtils uses the tar reader and writer that come with RubyGems, so
|
|
26
|
+
minitar is no longer needed. Unpacking refuses entries that would land
|
|
27
|
+
outside the directory.
|
|
28
|
+
* EmailUtils uses the current Net::SMTP interface.
|
|
29
|
+
* Array#to_argv and Hash#to_argv give plain arguments, without quotes;
|
|
30
|
+
#to_console quotes for the shell.
|
|
31
|
+
* ludo is rewritten: it passes arguments on, runs the script from the
|
|
32
|
+
directory it was found in, reports a script it can't find, and returns
|
|
33
|
+
the script's exit status.
|
|
34
|
+
* Tests run on Spectrum.
|
|
35
|
+
|
|
36
|
+
Fixes:
|
|
37
|
+
|
|
38
|
+
* Batch#rm removed nothing.
|
|
39
|
+
* Batch#exists? and Shell#exists? used a method Ruby has dropped.
|
|
40
|
+
* Batch's map methods (#rename and so on) ignored their options.
|
|
41
|
+
* Script#define_method lost the method's name.
|
|
42
|
+
* FileList#ext needed Rake to be loaded.
|
|
43
|
+
* TarUtils failed on being included, and #untar emptied the archive.
|
|
44
|
+
* XDGUtils didn't report a missing xdg gem.
|
|
45
|
+
|
|
46
|
+
Removed:
|
|
47
|
+
|
|
48
|
+
* FTPUtils, which was unfinished and could not run.
|
|
49
|
+
* POMUtils, as the POM project is gone.
|
|
50
|
+
* Ratch::System and Ratch::Console, a stub and an unfinished console.
|
|
51
|
+
* FileList#pathmap, which needed Rake.
|
|
52
|
+
* The ShellUtils module, an unfinished refactoring.
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
== 1.2.0 | 2011-01-24
|
|
56
|
+
|
|
57
|
+
Ratch has remerged with the Path gem (formerly Folio), and will be taking over
|
|
58
|
+
for its services from here on. In the process the library has been further
|
|
59
|
+
refined.
|
|
60
|
+
|
|
61
|
+
Changes:
|
|
62
|
+
|
|
63
|
+
* Essentially, the Path library has become Ratch.
|
|
64
|
+
* Primary class are now Script and Shell.
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
== 1.1.0 | 2008-11-21
|
|
68
|
+
|
|
69
|
+
This is the second public release of Ratch. Folio is now used a Ratch's backend.
|
|
70
|
+
Folio handles a great deal of what Ratch requires, so much of Ratch is now just
|
|
71
|
+
a thin wrapper around Folio.
|
|
72
|
+
|
|
73
|
+
Changes:
|
|
74
|
+
|
|
75
|
+
* Overhauled system to use Folio on the backend.
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
== 1.0.0 | 2009-09-22
|
|
79
|
+
|
|
80
|
+
This is the initial stand-alone release of Path, a collection
|
|
81
|
+
of Path-related classes partially spun-off from Ruby Facets
|
|
82
|
+
and briefly called Folio.
|
|
83
|
+
|
|
84
|
+
Changes:
|
|
85
|
+
|
|
86
|
+
* Happy Birthday!
|
|
87
|
+
|
data/README.rdoc
CHANGED
|
@@ -1,113 +1,133 @@
|
|
|
1
|
-
= Ratch
|
|
1
|
+
= Ratch
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
{Source Code}[https://github.com/rubyworks/ratch] /
|
|
4
|
+
{Report Issue}[https://github.com/rubyworks/ratch/issues]
|
|
5
|
+
{<img src="https://github.com/rubyworks/ratch/actions/workflows/ci.yml/badge.svg" alt="CI" />}[https://github.com/rubyworks/ratch/actions/workflows/ci.yml]
|
|
4
6
|
|
|
7
|
+
<b>A file system shell in code, and batch scripts in Ruby.</b>
|
|
5
8
|
|
|
6
|
-
|
|
9
|
+
Ratch needs Ruby 3.1 or newer.
|
|
7
10
|
|
|
8
|
-
Ratch is Ruby-based DSL for building batch scripts. It's intent
|
|
9
|
-
is to ease the burden of batch script writers by supplementing
|
|
10
|
-
the standard ruby environment to be more conducive to the needs
|
|
11
|
-
of batch scripting.
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
it makes a very powerful library for other applications that
|
|
15
|
-
require batch-like functionality. In general any program that
|
|
16
|
-
access the file system extensively could benefit from it's use.
|
|
12
|
+
== The Shell
|
|
17
13
|
|
|
14
|
+
A Ratch::Shell stands at a directory and works from there, as a shell
|
|
15
|
+
prompt does. Paths given to it are taken from its directory, whatever the
|
|
16
|
+
process's own working directory is.
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
require 'ratch'
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
* code: http://github.com/rubyworks/ratch
|
|
23
|
-
* talk: http://googlegroups.com/
|
|
20
|
+
shell = Ratch::Shell.new('project')
|
|
24
21
|
|
|
25
|
-
|
|
22
|
+
shell.file?('README.md') #=> true
|
|
23
|
+
shell.glob('lib/**/*.rb') #=> ["lib/project.rb", ...]
|
|
24
|
+
shell.read('VERSION') #=> "1.0.0\n"
|
|
26
25
|
|
|
27
|
-
|
|
26
|
+
shell.mkdir_p('tmp/cache')
|
|
27
|
+
shell.cp('README.md', 'tmp')
|
|
28
|
+
shell.write('tmp/stamp', Time.now.to_s)
|
|
29
|
+
shell.sh('git status') #=> true, if the command succeeded
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
It has the tests of FileTest, the operations of FileUtils (+mkdir+, +rm+,
|
|
32
|
+
+cp+, +mv+, +ln+, +install+, +chmod+, +touch+ and their variations),
|
|
33
|
+
+read+, +write+ and +append+, +glob+, and +sh+ to run a command.
|
|
30
34
|
|
|
31
|
-
|
|
35
|
+
Moving about:
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
name to the ratch executable instead.
|
|
37
|
+
lib = shell / 'lib' # a new shell at project/lib
|
|
35
38
|
|
|
36
|
-
|
|
39
|
+
shell.cd('lib') # move this shell
|
|
40
|
+
shell.cd('..')
|
|
37
41
|
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
shell.cd('lib') do # move it for a block only
|
|
43
|
+
shell.files #=> [#<Pathname:project.rb>, ...]
|
|
44
|
+
end
|
|
40
45
|
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
A shell can be put in a mode in which it only pretends, to rehearse a
|
|
47
|
+
script before it touches anything:
|
|
43
48
|
|
|
44
|
-
|
|
49
|
+
shell = Ratch::Shell.new('project', :dryrun=>true)
|
|
45
50
|
|
|
46
|
-
|
|
51
|
+
shell.rm_r('tmp') # prints "rm -r tmp" and removes nothing
|
|
52
|
+
shell.sh('make install') # prints the command and doesn't run it
|
|
47
53
|
|
|
54
|
+
The modes are <tt>:noop</tt> (change nothing), <tt>:trace</tt> (report
|
|
55
|
+
each step to standard error), <tt>:dryrun</tt> (both) and <tt>:quiet</tt>.
|
|
56
|
+
The first three can also be given to a single command:
|
|
48
57
|
|
|
49
|
-
|
|
58
|
+
shell.rm('old.txt', :dryrun=>true)
|
|
50
59
|
|
|
51
|
-
|
|
60
|
+
To build on it, subclass Ratch::Shell, or keep one and delegate to it.
|
|
52
61
|
|
|
53
|
-
require 'ratch'
|
|
54
62
|
|
|
55
|
-
|
|
63
|
+
== Batches
|
|
56
64
|
|
|
57
|
-
|
|
58
|
-
@shell = Ratch::Shell.new(path)
|
|
59
|
-
end
|
|
65
|
+
A Ratch::Batch does the same over a list of files.
|
|
60
66
|
|
|
61
|
-
|
|
67
|
+
batch = shell.batch('**/*.txt')
|
|
62
68
|
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
batch.file? # are they all files?
|
|
70
|
+
batch.cp('backup')
|
|
71
|
+
batch.rename{ |name| name.sub('.txt', '.text') }
|
|
65
72
|
|
|
73
|
+
It keeps its files in a Ratch::FileList, which is Rake's lazy file list:
|
|
74
|
+
patterns are resolved when the list is first read, and version control
|
|
75
|
+
directories, backup and core files are left out.
|
|
66
76
|
|
|
67
|
-
== Bonus Feature
|
|
68
77
|
|
|
69
|
-
|
|
70
|
-
It will ascend up the directory tree searching for a matching executable
|
|
71
|
-
script. If it finds one it will execute the script relative the currently
|
|
72
|
-
ascended directory.
|
|
78
|
+
== Scripts
|
|
73
79
|
|
|
80
|
+
The +ratch+ command runs a Ruby script inside a shell at the present
|
|
81
|
+
directory, so the script can use all of the above without a receiver.
|
|
74
82
|
|
|
75
|
-
|
|
83
|
+
#!/usr/bin/env ratch
|
|
76
84
|
|
|
77
|
-
|
|
85
|
+
glob('*.md').each do |file|
|
|
86
|
+
cp file, 'site'
|
|
87
|
+
end
|
|
78
88
|
|
|
79
|
-
|
|
89
|
+
sh 'rsync -a site/ host:/var/www'
|
|
80
90
|
|
|
81
|
-
|
|
91
|
+
The shell's modes can be given on the command line, and anything else is
|
|
92
|
+
in +arguments+:
|
|
82
93
|
|
|
83
|
-
$
|
|
84
|
-
$ cd ratch-1.0.0
|
|
85
|
-
$ setup.rb
|
|
94
|
+
$ ./publish.ratch --dryrun
|
|
86
95
|
|
|
87
96
|
|
|
88
|
-
==
|
|
97
|
+
== Utilities
|
|
89
98
|
|
|
90
|
-
|
|
99
|
+
These modules add to a shell when included in a subclass:
|
|
91
100
|
|
|
92
|
-
|
|
101
|
+
Ratch::ZlibUtils:: +gzip+ and +ungzip+
|
|
102
|
+
Ratch::TarUtils:: +tar+, +untar+, +tar_gzip+ and +untar_gzip+
|
|
103
|
+
Ratch::ConfigUtils:: +configuration+, to load a YAML file
|
|
104
|
+
Ratch::RDocUtils:: +rdoc+, to generate documentation (needs the +rdoc+ gem on Ruby 4)
|
|
105
|
+
Ratch::EmailUtils:: +email+, to send a message by SMTP (needs the +net-smtp+ gem)
|
|
106
|
+
Ratch::XDGUtils:: +xdg+ (needs the +xdg+ gem)
|
|
107
|
+
Ratch::CLI:: takes options and +arguments+ from the command line
|
|
93
108
|
|
|
94
|
-
|
|
95
|
-
|
|
109
|
+
The email delivery itself is not covered by the tests.
|
|
96
110
|
|
|
97
|
-
== Copying
|
|
98
111
|
|
|
99
|
-
|
|
112
|
+
== ludo
|
|
113
|
+
|
|
114
|
+
Ratch also comes with the +ludo+ command, which stands for "lookup and
|
|
115
|
+
do". It looks for an executable script by name in the present directory
|
|
116
|
+
and then in each directory above it, and runs the first it finds, from
|
|
117
|
+
the directory it is in.
|
|
100
118
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
You may obtain a copy of the License at
|
|
119
|
+
$ cd project/lib/project
|
|
120
|
+
$ ludo script/test --verbose # runs project/script/test
|
|
104
121
|
|
|
105
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
106
122
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
123
|
+
== Installation
|
|
124
|
+
|
|
125
|
+
$ gem install ratch
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
== Copying
|
|
112
129
|
|
|
130
|
+
Copyright (c) 2008 Thomas Sawyer, Rubyworks
|
|
113
131
|
|
|
132
|
+
Ratch is distributed under the terms of the Apache License, Version 2.0.
|
|
133
|
+
See LICENSE.txt for details.
|
data/bin/ludo
CHANGED
|
@@ -1,16 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
# for
|
|
4
|
-
|
|
3
|
+
# ludo: "lookup and do". Looks for an executable script by name, in the
|
|
4
|
+
# present directory and then in each directory above it, and runs the
|
|
5
|
+
# first one found, from the directory it is in, passing along any further
|
|
6
|
+
# arguments.
|
|
7
|
+
#
|
|
8
|
+
# $ ludo script/test --verbose
|
|
5
9
|
|
|
6
|
-
name = ARGV
|
|
10
|
+
name, *args = ARGV
|
|
7
11
|
|
|
8
|
-
if name
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
if name.nil? || name == '-h' || name == '--help'
|
|
13
|
+
$stderr.puts "Usage: ludo SCRIPT [ARGUMENTS]"
|
|
14
|
+
$stderr.puts "Run the first executable SCRIPT found in this directory or one above it."
|
|
15
|
+
exit(name.nil? ? 1 : 0)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
dir = Dir.pwd
|
|
19
|
+
|
|
20
|
+
loop do
|
|
21
|
+
file = File.join(dir, name)
|
|
22
|
+
if File.file?(file) && File.executable?(file)
|
|
23
|
+
Dir.chdir(dir)
|
|
24
|
+
exec(file, *args)
|
|
12
25
|
end
|
|
13
|
-
|
|
14
|
-
|
|
26
|
+
parent = File.dirname(dir)
|
|
27
|
+
break if parent == dir
|
|
28
|
+
dir = parent
|
|
15
29
|
end
|
|
16
30
|
|
|
31
|
+
$stderr.puts "ludo: script not found -- #{name}"
|
|
32
|
+
exit 1
|