ratch 0.1 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/{LICENSE.txt → LICENSE} +0 -0
- data/README +37 -0
- data/bin/lt +54 -2
- data/bin/ludo +12 -2
- data/bin/ratch +48 -2
- data/data/{mint/ratch → ratch/rubyproject}/announce +0 -0
- data/data/ratch/rubyproject/extest +129 -0
- data/data/{mint/ratch → ratch/rubyproject}/install +0 -0
- data/data/ratch/rubyproject/install2 +63 -0
- data/data/ratch/rubyproject/install3 +74 -0
- data/data/ratch/rubyproject/load +39 -0
- data/data/{mint/ratch → ratch/rubyproject}/notes +0 -0
- data/data/ratch/rubyproject/publish +58 -0
- data/data/{mint/ratch → ratch/rubyproject}/rdoc +0 -0
- data/data/{mint/ratch → ratch/rubyproject}/setup +0 -0
- data/data/{mint/ratch → ratch/rubyproject}/stats +0 -0
- data/dev/install +89 -0
- data/dev/ludo +25 -0
- data/dev/oldtaskable.rb +573 -0
- data/dev/taskable.rb +75 -528
- data/lib/ratch/argvutils.rb +56 -0
- data/lib/ratch/batch.rb +7 -1
- data/lib/ratch/{runnable.rb → batchable.rb} +49 -27
- data/lib/ratch/buildable.rb +107 -0
- data/lib/ratch/options.rb +1 -1
- data/lib/ratch/taskable.rb +70 -60
- data/lib/ratch/taskutils.rb +2 -5
- data/meta/{manifest.txt → MANIFEST} +23 -20
- data/meta/{project.yaml → RATCH-0.2.1.roll} +4 -2
- metadata +26 -23
- data/README.txt +0 -10
- data/data/mint/ratch/publish +0 -44
- data/lib/ratch/cli/lt.rb +0 -56
- data/lib/ratch/cli/ludo.rb +0 -14
- data/lib/ratch/cli/ratch.rb +0 -47
- data/misc/original.rb +0 -308
data/{LICENSE.txt → LICENSE}
RENAMED
File without changes
|
data/README
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
= Ratch
|
2
|
+
|
3
|
+
== Welcome to Ratch
|
4
|
+
|
5
|
+
Ratch is a Ruby-based Batch file system. It provides a Ruby-based DSL
|
6
|
+
for creating utility/task scripts. It is similar in function to build tools,
|
7
|
+
like Make, Ant, Maven, Rake, et al. But unlike these it stears clear
|
8
|
+
of monolithic ? and instead more closely follows the "UNIX-way".
|
9
|
+
|
10
|
+
|
11
|
+
== Installation
|
12
|
+
|
13
|
+
$ gem install ratch
|
14
|
+
|
15
|
+
Or download the tar.gz and install manually,
|
16
|
+
|
17
|
+
$ tar -xvzf ratch-x.y.z.tar.gz
|
18
|
+
$ cd ratch-x.y.z
|
19
|
+
$ sudo task/setup
|
20
|
+
|
21
|
+
For Windows users the last line will be:
|
22
|
+
|
23
|
+
$ ruby task/setup
|
24
|
+
|
25
|
+
|
26
|
+
== Usage
|
27
|
+
|
28
|
+
Basic usage simply entails writing a script that utilizes Ratch's syntax.
|
29
|
+
|
30
|
+
|
31
|
+
== License
|
32
|
+
|
33
|
+
Copyright (c) 2007 Thomas Sawyer (Trans)
|
34
|
+
|
35
|
+
GPL 3 ???
|
36
|
+
|
37
|
+
|
data/bin/lt
CHANGED
@@ -1,4 +1,56 @@
|
|
1
|
-
#! /usr/bin/
|
1
|
+
#! /usr/bin/ruby1.8
|
2
2
|
|
3
|
-
|
3
|
+
# scan task scripts for descriptions
|
4
4
|
|
5
|
+
def script_desc( dir )
|
6
|
+
help = {}
|
7
|
+
files = Dir.glob( File.join( dir, '*' ) )
|
8
|
+
files.each do |fname|
|
9
|
+
next if FileTest.directory?( fname )
|
10
|
+
next unless FileTest.executable?( fname )
|
11
|
+
desc = ''
|
12
|
+
File.open(fname) do |f|
|
13
|
+
line = ''
|
14
|
+
until f.eof?
|
15
|
+
line = f.gets
|
16
|
+
case line
|
17
|
+
when /^(#!|\s*$)/
|
18
|
+
next
|
19
|
+
when /^\s*#(.*)/
|
20
|
+
desc = $1.strip; break
|
21
|
+
else
|
22
|
+
desc = nil; break
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
help[File.basename(fname)] = desc
|
27
|
+
end
|
28
|
+
help
|
29
|
+
end
|
30
|
+
|
31
|
+
def show( dir )
|
32
|
+
tasks = script_desc( dir )
|
33
|
+
max = tasks.keys.max{ |a,b| a.size <=> b.size }.size
|
34
|
+
if dir == ''
|
35
|
+
max += 4 + 2
|
36
|
+
else
|
37
|
+
max += dir.size + 2
|
38
|
+
end
|
39
|
+
tasks.each do |name, sum|
|
40
|
+
#sum = Sake.help_summary( type )
|
41
|
+
if dir == ''
|
42
|
+
cmd = "sake #{name}"
|
43
|
+
else
|
44
|
+
cmd = File.join( dir.chomp('/'), name )
|
45
|
+
end
|
46
|
+
puts "%-#{max}s # %s" % [cmd, sum]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
dir = ARGV[0] || '.'
|
51
|
+
|
52
|
+
if File.directory?( dir )
|
53
|
+
show( dir )
|
54
|
+
else
|
55
|
+
puts "#{dir} is not a directory"
|
56
|
+
end
|
data/bin/ludo
CHANGED
@@ -1,4 +1,14 @@
|
|
1
|
-
#! /usr/bin/
|
1
|
+
#! /usr/bin/ruby1.8
|
2
2
|
|
3
|
-
|
3
|
+
require 'facets/filetest'
|
4
4
|
|
5
|
+
name = ARGV[0]
|
6
|
+
|
7
|
+
if name
|
8
|
+
Dir.chdir '..' until FileTest.executable?(name) or FileTest.root?(Dir.pwd)
|
9
|
+
if FileTest.executable?( name )
|
10
|
+
system name
|
11
|
+
end
|
12
|
+
else
|
13
|
+
puts "Script #{name} not found."
|
14
|
+
end
|
data/bin/ratch
CHANGED
@@ -1,6 +1,52 @@
|
|
1
|
-
#! /usr/bin/
|
1
|
+
#! /usr/bin/ruby1.8
|
2
2
|
|
3
|
-
require '
|
3
|
+
#require 'shellwords'
|
4
|
+
require 'rbconfig' # replace with facets/rbsystem in future ?
|
5
|
+
require 'ratch/batch'
|
6
|
+
|
7
|
+
module Ratch
|
8
|
+
|
9
|
+
class RatchCommand
|
10
|
+
|
11
|
+
# Quick start.
|
12
|
+
|
13
|
+
def self.start(file)
|
14
|
+
new.run(file)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Run task.
|
18
|
+
|
19
|
+
def run(file)
|
20
|
+
if file
|
21
|
+
BatchFile.new(file).call
|
22
|
+
else
|
23
|
+
help
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Dispaly help.
|
28
|
+
|
29
|
+
def help
|
30
|
+
help = <<-END
|
31
|
+
USAGE:
|
32
|
+
|
33
|
+
ratch [options] <taskfile>
|
34
|
+
|
35
|
+
OPTIONS:
|
36
|
+
|
37
|
+
--dryrun --nohram
|
38
|
+
|
39
|
+
--trace
|
40
|
+
|
41
|
+
--debug
|
42
|
+
END
|
43
|
+
puts help.gsub(/^\s+/, '')
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
end
|
4
50
|
|
5
51
|
#load($0 = ARGV.shift)
|
6
52
|
|
File without changes
|
@@ -0,0 +1,129 @@
|
|
1
|
+
#!/usr/bin/env ratch
|
2
|
+
|
3
|
+
# Extract embedded tests.
|
4
|
+
|
5
|
+
# Extract unit tests. This task scans every package script
|
6
|
+
# looking for sections of the form:
|
7
|
+
#
|
8
|
+
# =begin test
|
9
|
+
# ...
|
10
|
+
# =end
|
11
|
+
#
|
12
|
+
# With appropriate headers, it copies these sections to files
|
13
|
+
# in your project's test/ dir, which then can be run using the
|
14
|
+
# Ratchet test task. The exact directory layout of the files to
|
15
|
+
# be tested is reflected in the test directory. You can then
|
16
|
+
# use project.rb's test task to run the tests.
|
17
|
+
#
|
18
|
+
# files Files to extract ['lib/**/*.rb']
|
19
|
+
# output Test directory ['test/']
|
20
|
+
|
21
|
+
main :extest do
|
22
|
+
extract_tests # Deal with arg once rathc has better support fot it.
|
23
|
+
end
|
24
|
+
|
25
|
+
# Extract tests for scripts.
|
26
|
+
|
27
|
+
def extract_tests(files=nil)
|
28
|
+
output = 'test/embedded' # Don't think output should be setable.
|
29
|
+
|
30
|
+
files = files || 'lib/**/*.rb'
|
31
|
+
files = 'lib/**/*.rb' if TrueClass == files
|
32
|
+
files = [files].flatten.compact
|
33
|
+
|
34
|
+
filelist = files.collect{ |f| Dir.glob(f) }
|
35
|
+
filelist.flatten!
|
36
|
+
if filelist.empty?
|
37
|
+
puts "No scripts found from which to extract tests."
|
38
|
+
return
|
39
|
+
end
|
40
|
+
|
41
|
+
mkdir_p(output) unless directory?(output)
|
42
|
+
|
43
|
+
#vrunner = VerbosityRunner.new("Extracting", verbosity?)
|
44
|
+
#vrunner.setup(filelist.size)
|
45
|
+
|
46
|
+
filelist.each do |file|
|
47
|
+
#vrunner.prepare(file)
|
48
|
+
|
49
|
+
testing = extract_test_from_file( file )
|
50
|
+
if testing.strip.empty?
|
51
|
+
status = "[NONE]"
|
52
|
+
else
|
53
|
+
complete_test = create_test(testing, file)
|
54
|
+
libpath = File.dirname(file)
|
55
|
+
testfile = "test_" + File.basename(file)
|
56
|
+
fp = File.join(output, libpath, testfile)
|
57
|
+
unless directory?( File.dirname(fp))
|
58
|
+
mkdir_p(File.dirname(fp))
|
59
|
+
end
|
60
|
+
if dryrun?
|
61
|
+
puts "write #{fp}"
|
62
|
+
else
|
63
|
+
File.open(fp, "w"){ |fw| fw << complete_test }
|
64
|
+
end
|
65
|
+
status = "[TEST]"
|
66
|
+
end
|
67
|
+
|
68
|
+
#vrunner.complete(file, status)
|
69
|
+
end
|
70
|
+
|
71
|
+
#vrunner.finish(
|
72
|
+
# :normal => "#{filelist.size} files had tests extracted.",
|
73
|
+
# :check => false
|
74
|
+
#)
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
# Extract test from a file's testing comments.
|
80
|
+
|
81
|
+
def extract_test_from_file( file )
|
82
|
+
return nil if ! File.file?( file )
|
83
|
+
tests = ""; inside = false
|
84
|
+
fstr = File.read( file )
|
85
|
+
fstr.split(/\n/).each do |l|
|
86
|
+
if l =~ /^=begin[ ]*test/i
|
87
|
+
tests << "\n"
|
88
|
+
inside = true
|
89
|
+
next
|
90
|
+
elsif inside and l =~ /^=[ ]*end/
|
91
|
+
inside = false
|
92
|
+
next
|
93
|
+
end
|
94
|
+
if inside
|
95
|
+
tests << l << "\n"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
tests
|
99
|
+
end
|
100
|
+
|
101
|
+
# Generate the test.
|
102
|
+
|
103
|
+
def create_test( testing, file )
|
104
|
+
fp = file.split(/[\/]/)
|
105
|
+
if fp[0] == 'lib'
|
106
|
+
reqf = "require '#{fp[1..-1].join('/')}'"
|
107
|
+
else
|
108
|
+
reqf = ''
|
109
|
+
end
|
110
|
+
str = []
|
111
|
+
str << " # _____ _"
|
112
|
+
str << " # |_ _|__ ___| |_"
|
113
|
+
str << " # | |/ _ \\/ __| __|"
|
114
|
+
str << " # | | __/\\__ \\ |"
|
115
|
+
str << " # |_|\\___||___/\\__|"
|
116
|
+
str << " #"
|
117
|
+
str << " # for #{file}"
|
118
|
+
str << " #"
|
119
|
+
str << " # Extracted #{Time.now}"
|
120
|
+
str << " # w/ Test Extraction Ratchet"
|
121
|
+
str << " #"
|
122
|
+
str << ""
|
123
|
+
str << " #{reqf}"
|
124
|
+
str << ""
|
125
|
+
str << testing
|
126
|
+
str << "\n"
|
127
|
+
str = str.join("\n")
|
128
|
+
str
|
129
|
+
end
|
File without changes
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/usr/bin/env ratch
|
2
|
+
|
3
|
+
# install package to site_ruby
|
4
|
+
|
5
|
+
# This tool installs the package to site_ruby
|
6
|
+
# using Ruby's defualt configuration settings.
|
7
|
+
# If you want to change these you can can supply
|
8
|
+
# config settings for 'prefix' and/or 'sitedir'.
|
9
|
+
|
10
|
+
main :install do
|
11
|
+
|
12
|
+
system_prefix = Config::CONFIG['prefix']
|
13
|
+
system_libdir = Config::CONFIG['sitelibdir']
|
14
|
+
|
15
|
+
config = config_load('install')
|
16
|
+
|
17
|
+
prefix = config['prefix'] || system_prefix
|
18
|
+
libdir = config['libdir']
|
19
|
+
|
20
|
+
unless libdir
|
21
|
+
if (prefix == system_prefix) then
|
22
|
+
libdir = system_libdir
|
23
|
+
else
|
24
|
+
libdir = File.join(prefix, system_libdir[system_prefix.size..-1])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# TODO Probably should get files from manifest, if it exists.
|
29
|
+
# files = projectinfo.filelist
|
30
|
+
files = Dir.glob("{lib,ext,bin}/**/*").select{ |f| File.file?(f) }
|
31
|
+
|
32
|
+
lib_files = files.grep(/^(lib|ext)/)
|
33
|
+
bin_files = files.grep(/^bin/)
|
34
|
+
|
35
|
+
# Copy files to proper locations.
|
36
|
+
|
37
|
+
lib_files.each do |file|
|
38
|
+
dest = File.dirname(file).sub('lib/', '')
|
39
|
+
dest = File.join(libdir, dest)
|
40
|
+
#dest.sub!(/(core|more)\//, '') # SPECIAL FOR FACETS !!!!!
|
41
|
+
if noharm?
|
42
|
+
puts "mkdir -p #{dest}"
|
43
|
+
puts "install -m 0444 #{file} #{dest}"
|
44
|
+
else
|
45
|
+
mkdir_p dest unless File.directory?(dest)
|
46
|
+
install file, dest, :mode => 0444
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
bin_files.each do |file|
|
51
|
+
dest = File.dirname(file)
|
52
|
+
dest = File.join(prefix, dest)
|
53
|
+
if noharm?
|
54
|
+
puts "mkdir -p #{dest}"
|
55
|
+
puts "install -m 0555 #{file} #{dest}"
|
56
|
+
else
|
57
|
+
mkdir_p dest unless File.directory?(dest)
|
58
|
+
install file, dest, :mode => 0555
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
@@ -0,0 +1,74 @@
|
|
1
|
+
#!/usr/bin/env ratch
|
2
|
+
|
3
|
+
# Install package to site_ruby.
|
4
|
+
#
|
5
|
+
# This script installs Facets to site_ruby location
|
6
|
+
# using Ruby's defualt configuration settings.
|
7
|
+
# If you want to change these, you can supply
|
8
|
+
# configuration settings for 'prefix' and/or 'sitedir'.
|
9
|
+
|
10
|
+
main :install do
|
11
|
+
|
12
|
+
system_prefix = Config::CONFIG['prefix']
|
13
|
+
system_libdir = Config::CONFIG['sitelibdir']
|
14
|
+
|
15
|
+
config = configuration['install'] || {}
|
16
|
+
|
17
|
+
prefix = config['prefix'] || system_prefix
|
18
|
+
libdir = config['libdir']
|
19
|
+
|
20
|
+
unless libdir
|
21
|
+
if (prefix == system_prefix) then
|
22
|
+
libdir = system_libdir
|
23
|
+
else
|
24
|
+
libdir = File.join(prefix, system_libdir[system_prefix.size..-1])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
libpaths = configuration('meta/project.yaml')['libpaths']
|
29
|
+
|
30
|
+
# We need to copy them into site_ruby in the opposite order they
|
31
|
+
# would be searched for by require.
|
32
|
+
|
33
|
+
libpaths.reverse!
|
34
|
+
|
35
|
+
# Copy lib files to site_ruby location, in proper order!
|
36
|
+
|
37
|
+
lib_files = Dir.glob("lib/**/*").select{ |f| File.file?(f) }
|
38
|
+
|
39
|
+
#['core', 'fore', 'more' ]
|
40
|
+
libpaths.each do |loc|
|
41
|
+
files = lib_files.grep(/^#{loc}/)
|
42
|
+
files.each do |file|
|
43
|
+
dest = File.dirname(file)
|
44
|
+
#dest.sub!('lib/', '')
|
45
|
+
#dest.sub!(loc, '')
|
46
|
+
dest.sub!(loc, '')
|
47
|
+
dest = File.join(libdir, dest)
|
48
|
+
if noharm?
|
49
|
+
puts "mkdir -p #{dest}" unless File.directory?(dest)
|
50
|
+
puts "install -m 0444 #{file} #{dest}"
|
51
|
+
else
|
52
|
+
mkdir_p dest unless File.directory?(dest)
|
53
|
+
install file, dest, :mode => 0444
|
54
|
+
end
|
55
|
+
end
|
56
|
+
lib_files -= files # speed things up be removing what we've already covered.
|
57
|
+
end
|
58
|
+
|
59
|
+
# Copy bin files to site_ruby location.
|
60
|
+
|
61
|
+
bin_files = Dir.glob("bin/*").select{ |f| File.file?(f) }
|
62
|
+
bin_files.each do |file|
|
63
|
+
dest = File.dirname(file)
|
64
|
+
dest = File.join(prefix, dest)
|
65
|
+
if noharm?
|
66
|
+
puts "mkdir -p #{dest}" unless File.directory?(dest)
|
67
|
+
puts "install -m 0555 #{file} #{dest}"
|
68
|
+
else
|
69
|
+
mkdir_p dest unless File.directory?(dest)
|
70
|
+
install file, dest, :mode => 0555
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|