ratch 0.3.0 → 0.4.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.
- data/{log/history → CHANGES} +0 -0
- data/{log/todo → TODO} +0 -0
- data/bin/manifest +451 -0
- data/bin/ratch +3 -3
- data/demo/task/config.yaml +4 -0
- data/lib/ratch/{batch/argvutils.rb → dsl/argv.rb} +9 -4
- data/lib/ratch/dsl/batch.rb +226 -0
- data/lib/ratch/{batch → dsl}/build.rb +83 -4
- data/lib/ratch/{batch/consoleutils.rb → dsl/console.rb} +13 -5
- data/lib/ratch/{batch/emailutils.rb → dsl/email.rb} +21 -25
- data/lib/ratch/{batch/fileutils.rb → dsl/file.rb} +56 -56
- data/lib/ratch/dsl/meta.rb +132 -0
- data/lib/ratch/{batch → dsl}/options.rb +7 -5
- data/lib/ratch/dsl/setup.rb +124 -0
- data/lib/ratch/{support/signiture.rb → dsl/sign.rb} +9 -18
- data/lib/ratch/dsl/stage.rb +147 -0
- data/lib/ratch/dsl/task.rb +139 -0
- data/lib/ratch/{uploadutils.rb → dsl/upload.rb} +7 -5
- data/lib/ratch/{batch/task.rb → dsl/zip.rb} +30 -14
- data/lib/ratch/dsl.rb +52 -0
- data/lib/ratch/extra/email.rb +5 -0
- data/lib/ratch/extra/stage.rb +5 -0
- data/lib/ratch/extra/zip.rb +5 -0
- data/lib/ratch/manifest.rb +540 -0
- data/lib/ratch/{project → metadata}/information.rb +1 -0
- data/lib/ratch/{project → metadata}/package.rb +28 -2
- data/lib/ratch/{project → metadata}/project.rb +8 -16
- data/lib/ratch/{project → metadata}/release.rb +6 -6
- data/lib/ratch/support/errors.rb +4 -0
- data/lib/ratch/support/filename.rb +18 -0
- data/lib/ratch/toolset/ruby/compile +49 -0
- data/lib/ratch/toolset/ruby/pack/gem +26 -18
- data/lib/ratch/toolset/ruby/pack/tgz +25 -64
- data/lib/ratch/toolset/ruby/pack/zip +46 -0
- data/lib/ratch/toolset/ruby/publish +23 -24
- data/lib/ratch/toolset/ruby/release +8 -0
- data/lib/ratch/toolset/ruby/stamp +33 -0
- data/lib/ratch/toolset/sandbox +11 -0
- data/meta/MANIFEST +101 -23
- data/meta/ROLLRC +1 -1
- data/meta/config.yaml +10 -0
- data/meta/icli.yaml +2 -2
- data/meta/project.yaml +9 -10
- data/meta/xProjectInfo +41 -0
- data/task/release +1 -4
- metadata +82 -156
- data/demo/task/rdoc +0 -88
- data/demo/task/rdoc-old +0 -182
- data/doc/images/clipboard.jpg +0 -0
- data/doc/images/clipboard2.png +0 -0
- data/doc/images/milles-tn.jpg +0 -0
- data/doc/images/mints.png +0 -0
- data/doc/images/ratch2.png +0 -0
- data/doc/images/ruby-sm.png +0 -0
- data/doc/images/silver.gif +0 -0
- data/doc/images/toolbox.jpg +0 -0
- data/doc/index.html +0 -181
- data/doc/notes/original.rb +0 -308
- data/doc/rdoc/classes/Array.html +0 -194
- data/doc/rdoc/classes/Dir.html +0 -317
- data/doc/rdoc/classes/Hash.html +0 -217
- data/doc/rdoc/classes/Ratch/ArgvUtils/Ext.html +0 -285
- data/doc/rdoc/classes/Ratch/ArgvUtils.html +0 -173
- data/doc/rdoc/classes/Ratch/BatchFile.html +0 -207
- data/doc/rdoc/classes/Ratch/BatchManager.html +0 -250
- data/doc/rdoc/classes/Ratch/BatchScript.html +0 -127
- data/doc/rdoc/classes/Ratch/Batchable.html +0 -373
- data/doc/rdoc/classes/Ratch/Build.html +0 -321
- data/doc/rdoc/classes/Ratch/BuildManager.html +0 -319
- data/doc/rdoc/classes/Ratch/Buildable.html +0 -202
- data/doc/rdoc/classes/Ratch/ConfigUtils.html +0 -281
- data/doc/rdoc/classes/Ratch/ConsoleUtils.html +0 -189
- data/doc/rdoc/classes/Ratch/EmailUtils.html +0 -209
- data/doc/rdoc/classes/Ratch/FileUtils.html +0 -674
- data/doc/rdoc/classes/Ratch/GeneralOptions.html +0 -430
- data/doc/rdoc/classes/Ratch/Task.html +0 -201
- data/doc/rdoc/classes/Ratch/TaskManager.html +0 -330
- data/doc/rdoc/classes/Ratch/Taskable.html +0 -231
- data/doc/rdoc/classes/Ratch/UploadUtils.html +0 -566
- data/doc/rdoc/classes/Ratch.html +0 -201
- data/doc/rdoc/created.rid +0 -1
- data/doc/rdoc/files/COPYING.html +0 -1003
- data/doc/rdoc/files/README.html +0 -143
- data/doc/rdoc/files/lib/ratch/argvutils_rb.html +0 -131
- data/doc/rdoc/files/lib/ratch/batch_rb.html +0 -155
- data/doc/rdoc/files/lib/ratch/batchable_rb.html +0 -131
- data/doc/rdoc/files/lib/ratch/batchfile_rb.html +0 -148
- data/doc/rdoc/files/lib/ratch/buildable_rb.html +0 -131
- data/doc/rdoc/files/lib/ratch/consoleutils_rb.html +0 -131
- data/doc/rdoc/files/lib/ratch/emailutils_rb.html +0 -139
- data/doc/rdoc/files/lib/ratch/facets/multiglob_rb.html +0 -137
- data/doc/rdoc/files/lib/ratch/fileutils_rb.html +0 -139
- data/doc/rdoc/files/lib/ratch/options_rb.html +0 -131
- data/doc/rdoc/files/lib/ratch/taskable_rb.html +0 -131
- data/doc/rdoc/files/lib/ratch/uploadutils_rb.html +0 -150
- data/doc/rdoc/fr_class_index.html +0 -48
- data/doc/rdoc/fr_file_index.html +0 -41
- data/doc/rdoc/fr_method_index.html +0 -133
- data/doc/rdoc/index.html +0 -24
- data/doc/rdoc/rdoc-style.css +0 -208
- data/doc/scrap/flexihead-flip.jpg +0 -0
- data/doc/scrap/flexihead.jpg +0 -0
- data/doc/scrap/head1.jpg +0 -0
- data/doc/scrap/ratch.jpg +0 -0
- data/doc/scrap/ratch1.png +0 -0
- data/doc/scrap/ratch2.jpg +0 -0
- data/doc/scrap/ratch3.png +0 -0
- data/doc/scrap/red-ratch.jpg +0 -0
- data/doc/scrap/redratchet.jpg +0 -0
- data/doc/scrap/ruby-kit/ruby.png +0 -0
- data/doc/scrap/scrap.red +0 -256
- data/doc/sitemap.yaml +0 -10
- data/doc/siteparts/index.red +0 -100
- data/doc/siteparts/layout.rhtml +0 -56
- data/doc/siteparts/tutorial.red +0 -578
- data/doc/style.css +0 -112
- data/doc/tutorial.html +0 -722
- data/lib/ratch/batch.rb +0 -488
- data/lib/ratch/support/setuputils.rb +0 -124
- data/lib/ratch/support/stage.rb +0 -292
- data/lib/ratch/toolset/ruby/rdoc +0 -88
- data/task/rdoc +0 -6
- data/work/old/batchfile.rb +0 -95
- data/work/project-old.rb +0 -67
- data/work/scrap/install +0 -89
- data/work/scrap/install.0 +0 -49
- data/work/scrap/install.1 +0 -63
- data/work/scrap/ludo +0 -25
- data/work/scrap/oldtaskable.rb +0 -573
- data/work/scrap/ratch.man +0 -39
- data/work/scrap/taskable-simple.rb +0 -42
- data/work/scrap/taskable.rb +0 -120
@@ -0,0 +1,132 @@
|
|
1
|
+
# = TITLE:
|
2
|
+
#
|
3
|
+
# Metadata / Configuration DSL
|
4
|
+
#
|
5
|
+
# = COPYING:
|
6
|
+
#
|
7
|
+
# Copyright (c) 2007 Psi T Corp.
|
8
|
+
#
|
9
|
+
# This file is part of the Ratch program.
|
10
|
+
#
|
11
|
+
# Ratch is free software: you can redistribute it and/or modify
|
12
|
+
# it under the terms of the GNU General Public License as published by
|
13
|
+
# the Free Software Foundation, either version 3 of the License, or
|
14
|
+
# (at your option) any later version.
|
15
|
+
#
|
16
|
+
# Ratch is distributed in the hope that it will be useful,
|
17
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19
|
+
# GNU General Public License for more details.
|
20
|
+
#
|
21
|
+
# You should have received a copy of the GNU General Public License
|
22
|
+
# along with Ratch. If not, see <http://www.gnu.org/licenses/>.
|
23
|
+
|
24
|
+
require 'yaml'
|
25
|
+
require 'ratch/support/filename' # string ?
|
26
|
+
require 'ratch/metadata/package'
|
27
|
+
require 'ratch/metadata/release'
|
28
|
+
|
29
|
+
module Ratch
|
30
|
+
module Dsl
|
31
|
+
|
32
|
+
module Meta
|
33
|
+
|
34
|
+
DEFAULT_FOLD = '{,meta/,meta/config/}'
|
35
|
+
DEFAULT_FILE = '{config,meta/config,meta/config/general}{.yaml,.yml,}'
|
36
|
+
|
37
|
+
def package
|
38
|
+
@package ||= Package.load
|
39
|
+
end
|
40
|
+
|
41
|
+
# Roll file information.
|
42
|
+
|
43
|
+
def rollrc
|
44
|
+
@rollrc ||= Release.load
|
45
|
+
# @rollrc ||= (
|
46
|
+
# file = Dir.glob('{meta/,}rollrc', File::FNM_CASEFOLD).first
|
47
|
+
# data = File.read(file).split(/\n/)
|
48
|
+
# data, *libpath = *data
|
49
|
+
# name, version, status, date, default, *null = *data.split(/\s+/)
|
50
|
+
# klass = Struct.new("ROLLRC", :file, :name, :version, :status, :date, :default, :libpath)
|
51
|
+
# klass.new(file, name, version, status, date, default, libpath)
|
52
|
+
# )
|
53
|
+
end
|
54
|
+
|
55
|
+
# Load configuration data from a file. The file will
|
56
|
+
# be looked for in the current script directory then
|
57
|
+
# from the project root.
|
58
|
+
#
|
59
|
+
# Since they are YAML files, they can optionally
|
60
|
+
# end with '.yaml' or '.yml'.
|
61
|
+
|
62
|
+
def configuration(file=nil)
|
63
|
+
@configuration ||= {}
|
64
|
+
@configuration[file] ||= (
|
65
|
+
if file = config_file(file)
|
66
|
+
config_read(file)
|
67
|
+
else
|
68
|
+
Hash.new{ |h,k| h[k] = {} }
|
69
|
+
end
|
70
|
+
)
|
71
|
+
end
|
72
|
+
|
73
|
+
# If a +path+ is given it will first be looked for in the config directory of
|
74
|
+
# the utility directory. If not there, then it will be looked for in the project's trunk.
|
75
|
+
#
|
76
|
+
# If +path+ is not given then config.yaml or config/general.yaml will be used.
|
77
|
+
#
|
78
|
+
# TODO: Consider more carfully where configuration should be stored.
|
79
|
+
|
80
|
+
def config_file(path=nil)
|
81
|
+
if path
|
82
|
+
find = DEFAULT_FOLD + "#{path}{.yaml,.yml,}"
|
83
|
+
else
|
84
|
+
find = DEFAULT_FILE
|
85
|
+
end
|
86
|
+
Dir.glob(find, File::FNM_CASEFOLD).find{ |f| File.file?(f) }
|
87
|
+
end
|
88
|
+
|
89
|
+
#
|
90
|
+
|
91
|
+
def config_read(path)
|
92
|
+
#find = "{#{utility_directory}/,}#{path}{.yaml,.yml,}"
|
93
|
+
#if file = Dir.glob(find)[0]
|
94
|
+
if File.file?(path)
|
95
|
+
YAML::load(File.open(path)) || {} # The || {} is in case the file is empty.
|
96
|
+
else
|
97
|
+
raise LoadError, "Missing file -- #{path}"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# Create an argument vector from a set of config options.
|
102
|
+
# TODO Deprecate in favor of Hash extension.
|
103
|
+
|
104
|
+
def config_vector(config, args_field=nil)
|
105
|
+
config.command_vector(args_field)
|
106
|
+
end
|
107
|
+
|
108
|
+
# # Load task configuration if any.
|
109
|
+
#
|
110
|
+
# def config_load(*names) #, defaults=nil)
|
111
|
+
#
|
112
|
+
# names.inject({}) do |memo, name|
|
113
|
+
# name = name.to_s
|
114
|
+
# #defaults = defaults || {}
|
115
|
+
#
|
116
|
+
# if file = config_file(name)
|
117
|
+
# config = YAML.load(File.open(file))
|
118
|
+
# elsif file = Dir.glob("#{utility_directory}/config{,.yaml,.yml}")[0]
|
119
|
+
# config = YAML.load(File.open(file))[name.to_s]
|
120
|
+
# else
|
121
|
+
# config = {}
|
122
|
+
# end
|
123
|
+
#
|
124
|
+
# config.update(memo)
|
125
|
+
# end
|
126
|
+
# #return defaults.update(config || {})
|
127
|
+
# end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
# TITLE:
|
1
|
+
# = TITLE:
|
2
2
|
#
|
3
|
-
#
|
3
|
+
# Options DSL
|
4
4
|
#
|
5
|
-
# COPYING:
|
5
|
+
# = COPYING:
|
6
6
|
#
|
7
7
|
# Copyright (c) 2007 Psi T Corp.
|
8
8
|
#
|
@@ -22,10 +22,11 @@
|
|
22
22
|
# along with Ratch. If not, see <http://www.gnu.org/licenses/>.
|
23
23
|
|
24
24
|
module Ratch
|
25
|
+
module Dsl
|
25
26
|
|
26
|
-
#
|
27
|
+
# Options. There are derived from ARGV.
|
27
28
|
|
28
|
-
module
|
29
|
+
module Options
|
29
30
|
|
30
31
|
# Duplicate of ARGV.
|
31
32
|
|
@@ -94,3 +95,4 @@ module Ratch
|
|
94
95
|
end
|
95
96
|
|
96
97
|
end
|
98
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
# = TITLE:
|
2
|
+
#
|
3
|
+
# Setup DSL
|
4
|
+
#
|
5
|
+
# = SYNOPSIS:
|
6
|
+
#
|
7
|
+
# Mixen used to setup a package, eg. a manual install.
|
8
|
+
#
|
9
|
+
# = COPYING:
|
10
|
+
#
|
11
|
+
# Copyright (c) 2007 Psi T Corp.
|
12
|
+
#
|
13
|
+
# This file is part of the ProUtils' Box program.
|
14
|
+
#
|
15
|
+
# Box is free software: you can redistribute it and/or modify
|
16
|
+
# it under the terms of the GNU General Public License as published by
|
17
|
+
# the Free Software Foundation, either version 3 of the License, or
|
18
|
+
# (at your option) any later version.
|
19
|
+
#
|
20
|
+
# Box is distributed in the hope that it will be useful,
|
21
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
22
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
23
|
+
# GNU General Public License for more details.
|
24
|
+
#
|
25
|
+
# You should have received a copy of the GNU General Public License
|
26
|
+
# along with Box. If not, see <http://www.gnu.org/licenses/>.
|
27
|
+
|
28
|
+
#
|
29
|
+
module Ratch
|
30
|
+
module Dsl
|
31
|
+
|
32
|
+
# = Setup DSL
|
33
|
+
#
|
34
|
+
# Setup utilities provides a convenient way to install
|
35
|
+
# a ruby project via setup.rb.
|
36
|
+
|
37
|
+
module Setup
|
38
|
+
|
39
|
+
# Installation to a prefix destination using setup.rb.
|
40
|
+
# Some package types need this.
|
41
|
+
|
42
|
+
def prefix_install(prefix)
|
43
|
+
mkdir_p(prefix)
|
44
|
+
|
45
|
+
unless setup_rb
|
46
|
+
raise "Setup.rb is missing. Forced to abort."
|
47
|
+
end
|
48
|
+
# mock install
|
49
|
+
cmd = ''
|
50
|
+
cmd << 'ruby setup.rb '
|
51
|
+
cmd << '-q ' unless project.verbose?
|
52
|
+
cmd << 'config --installdirs=std ; '
|
53
|
+
cmd << 'ruby setup.rb '
|
54
|
+
cmd << '-q ' unless project.verbose?
|
55
|
+
cmd << "install --prefix=#{prefix}"
|
56
|
+
sh cmd
|
57
|
+
end
|
58
|
+
|
59
|
+
# If setup.rb is not found add a copy to the project.
|
60
|
+
# FIXME
|
61
|
+
|
62
|
+
def setup_rb
|
63
|
+
unless File.exist?('setup.rb')
|
64
|
+
f = File.join(libdir,'vendor','setup.rb')
|
65
|
+
if File.exist?(f)
|
66
|
+
cp(f,'.')
|
67
|
+
else
|
68
|
+
raise "setup.rb is not avaialble"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
true
|
72
|
+
end
|
73
|
+
|
74
|
+
# # Setup and install. This builds and installs a project
|
75
|
+
# # using setup.rb or install.rb. If neither exist setup.rb
|
76
|
+
# # will be created for the purpose.
|
77
|
+
# #
|
78
|
+
# # options Command line options to add to shell command.
|
79
|
+
# # script Install script, default is install.rb or setup.rb
|
80
|
+
# #--
|
81
|
+
# # source Location of source. (Defaults to current directory)
|
82
|
+
# #++
|
83
|
+
#
|
84
|
+
# def setup(keys={})
|
85
|
+
#
|
86
|
+
# options = keys['options']
|
87
|
+
# script = keys['script']
|
88
|
+
# #source = keys.source || Dir.pwd
|
89
|
+
#
|
90
|
+
# options = [options].flatten.compact
|
91
|
+
#
|
92
|
+
# if script
|
93
|
+
# exe = script + ' '
|
94
|
+
# exe << options.join(' ')
|
95
|
+
# elsif File.exist?('install.rb')
|
96
|
+
# exe = 'ruby install.rb '
|
97
|
+
# exe << options.join(' ')
|
98
|
+
# elsif File.exist?('setup.rb') or setup_rb
|
99
|
+
# exe = 'ruby setup.rb '
|
100
|
+
# exe << '-q ' unless verbose?
|
101
|
+
# exe << options.join(' ')
|
102
|
+
# exe << ' all'
|
103
|
+
# else
|
104
|
+
# puts "Script setup.rb or install.rb is missing."
|
105
|
+
# return nil
|
106
|
+
# end
|
107
|
+
#
|
108
|
+
# # SHELLS OUT!
|
109
|
+
#
|
110
|
+
# #Dir.chdir(source) do
|
111
|
+
# #begin
|
112
|
+
# success = sh(exe)
|
113
|
+
# puts "Installation complete!" if success
|
114
|
+
# #rescue Errno::EACCES
|
115
|
+
# # puts "Permission denied"
|
116
|
+
# # exit -1
|
117
|
+
# #end
|
118
|
+
# #end
|
119
|
+
# end
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
# TITLE:
|
1
|
+
# = TITLE:
|
2
2
|
#
|
3
|
-
# Sign
|
3
|
+
# Sign DSL
|
4
4
|
#
|
5
|
-
# COPYING:
|
5
|
+
# = COPYING:
|
6
6
|
#
|
7
7
|
# Copyright (c) 2007 Psi T Corp.
|
8
8
|
#
|
@@ -21,7 +21,7 @@
|
|
21
21
|
# You should have received a copy of the GNU General Public License
|
22
22
|
# along with Box. If not, see <http://www.gnu.org/licenses/>.
|
23
23
|
#
|
24
|
-
# TODO:
|
24
|
+
# = TODO:
|
25
25
|
# - Do signitures belong under data/{name}/?
|
26
26
|
# Heck do all these metadata files belong there?
|
27
27
|
# OTOH using remote require, how would one access these?
|
@@ -30,22 +30,13 @@
|
|
30
30
|
#require 'autorake/tasks/manifest'
|
31
31
|
|
32
32
|
#
|
33
|
-
module
|
33
|
+
module Ratch
|
34
|
+
module Dsl
|
34
35
|
|
35
36
|
# Create signitures for libraries.
|
36
|
-
#
|
37
|
-
class Sign #< Tool
|
37
|
+
# FIXME
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
def task_sign
|
42
|
-
|
43
|
-
desc "Generate file signitures"
|
44
|
-
task :sign do
|
45
|
-
project.sign
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
39
|
+
module Sign
|
49
40
|
|
50
41
|
# Default set of files to sign.
|
51
42
|
DEFAULT_SIGN_FILES = ['lib/**/*', 'ext/**/*']
|
@@ -249,4 +240,4 @@ module Box
|
|
249
240
|
end
|
250
241
|
|
251
242
|
end
|
252
|
-
|
243
|
+
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
# = TITLE:
|
2
|
+
#
|
3
|
+
# Stage DSL
|
4
|
+
#
|
5
|
+
# = COPYING:
|
6
|
+
#
|
7
|
+
# Copyright (c) 2007 Psi T Corp.
|
8
|
+
#
|
9
|
+
# This file is part of the ProUtils' Box program.
|
10
|
+
#
|
11
|
+
# Box is free software: you can redistribute it and/or modify
|
12
|
+
# it under the terms of the GNU General Public License as published by
|
13
|
+
# the Free Software Foundation, either version 3 of the License, or
|
14
|
+
# (at your option) any later version.
|
15
|
+
#
|
16
|
+
# Box is distributed in the hope that it will be useful,
|
17
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19
|
+
# GNU General Public License for more details.
|
20
|
+
#
|
21
|
+
# You should have received a copy of the GNU General Public License
|
22
|
+
# along with Box. If not, see <http://www.gnu.org/licenses/>.
|
23
|
+
|
24
|
+
module Ratch
|
25
|
+
module Dsl
|
26
|
+
|
27
|
+
# Stage package by hard linking included files to a stage directory.
|
28
|
+
|
29
|
+
module Stage
|
30
|
+
|
31
|
+
# Stage package.
|
32
|
+
#
|
33
|
+
# stage Stage directory.
|
34
|
+
# filelist Files to link to stage.
|
35
|
+
|
36
|
+
def stage(stage, filelist)
|
37
|
+
stage_link(stage, filelist)
|
38
|
+
stage_manifest(stage)
|
39
|
+
return stage
|
40
|
+
end
|
41
|
+
|
42
|
+
# Prepare stage directory.
|
43
|
+
|
44
|
+
def stage_link(stage_directory, files)
|
45
|
+
return stage_directory if dryrun? # Don't link to stage if dryrun.
|
46
|
+
|
47
|
+
stage_clear(stage_directory)
|
48
|
+
mkdir_p(stage_directory) #dir = File.expand_path(stage)
|
49
|
+
|
50
|
+
#files = package.filelist #+ [package.manifest_file]
|
51
|
+
|
52
|
+
# TODO Dryrun test here or before folder creation?
|
53
|
+
files.each do |f| # Link files into staging area.
|
54
|
+
file = File.join(stage_directory, f)
|
55
|
+
if File.directory?(f)
|
56
|
+
mkdir_p(file)
|
57
|
+
else
|
58
|
+
unless File.exist?(file) and File.mtime(file) >= File.mtime(f)
|
59
|
+
ln(f, file) #safe_ln ?
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
return stage_directory
|
64
|
+
end
|
65
|
+
|
66
|
+
# Clear old stage, if any.
|
67
|
+
|
68
|
+
def stage_clear(stage_directory)
|
69
|
+
if File.directory?(stage_directory) # Ensure existance of staging area
|
70
|
+
#raise(OverwriteError, stage_directory) unless force?
|
71
|
+
rm_r(stage_directory)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Create manifest for stage directory.
|
76
|
+
# TODO Do this programatically rather then via shell.
|
77
|
+
|
78
|
+
def stage_manifest(stage_directory)
|
79
|
+
#cd(stage_directory) do
|
80
|
+
# sh 'manifest up'
|
81
|
+
#end
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
#
|
94
|
+
# # Build packages.
|
95
|
+
# # TODO Move this to Manager ?
|
96
|
+
#
|
97
|
+
# def generate_packages
|
98
|
+
# package_files = formats.collect do |format|
|
99
|
+
# #format = clean_type(format)
|
100
|
+
# say '' if format == 'gem' # FIXME This is here b/c Gems outputs on it's own.
|
101
|
+
# file = create_package(format)
|
102
|
+
# unless dryrun? or (format == 'gem')
|
103
|
+
# report_package_built(format, file) if file
|
104
|
+
# end
|
105
|
+
# file
|
106
|
+
# end
|
107
|
+
# report_packaging_complete(package_files.size)
|
108
|
+
# end
|
109
|
+
#
|
110
|
+
# # Create package.
|
111
|
+
#
|
112
|
+
# def create_package(type)
|
113
|
+
# package.format = type
|
114
|
+
#
|
115
|
+
# builder_class = FormatBuilder.registry[type]
|
116
|
+
# builder = builder_class.new(package, stage_directory, options)
|
117
|
+
# file = builder.build
|
118
|
+
#
|
119
|
+
# transfer(file) unless dryrun?
|
120
|
+
#
|
121
|
+
# return file
|
122
|
+
# end
|
123
|
+
#
|
124
|
+
# # Transfer package file to storage dir.
|
125
|
+
#
|
126
|
+
# def transfer(file)
|
127
|
+
# dest = File.join(store, File.basename(file)) # move to store, unless already there
|
128
|
+
# dest = File.expand_path(dest)
|
129
|
+
# mv(file, store) unless file == dest
|
130
|
+
# end
|
131
|
+
#
|
132
|
+
# # Report that a package has been built.
|
133
|
+
#
|
134
|
+
# def report_package_built(type, file)
|
135
|
+
# r = ''
|
136
|
+
# r << "\n Successfully built #{type}"
|
137
|
+
# r << "\n Name: #{package.name}"
|
138
|
+
# r << "\n Version: #{package.version}"
|
139
|
+
# r << "\n File: #{File.basename(file)}"
|
140
|
+
# say r
|
141
|
+
# end
|
142
|
+
#
|
143
|
+
# # Report that packaging is complete.
|
144
|
+
#
|
145
|
+
# def report_packaging_complete(size)
|
146
|
+
# say "\nSuccessfully built #{size} packages at #{store}/."
|
147
|
+
# end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
# = TITLE:
|
2
|
+
#
|
3
|
+
# Task DSL
|
4
|
+
#
|
5
|
+
# = COPYING:
|
6
|
+
#
|
7
|
+
# Copyright (c) 2007 Psi T Corp.
|
8
|
+
#
|
9
|
+
# This file is part of the ProUtils' Ratch program.
|
10
|
+
#
|
11
|
+
# Ratch is free software: you can redistribute it and/or modify
|
12
|
+
# it under the terms of the GNU General Public License as published by
|
13
|
+
# the Free Software Foundation, either version 3 of the License, or
|
14
|
+
# (at your option) any later version.
|
15
|
+
#
|
16
|
+
# Ratch is distributed in the hope that it will be useful,
|
17
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19
|
+
# GNU General Public License for more details.
|
20
|
+
#
|
21
|
+
# You should have received a copy of the GNU General Public License
|
22
|
+
# along with Ratch. If not, see <http://www.gnu.org/licenses/>.
|
23
|
+
|
24
|
+
module Ratch
|
25
|
+
module Dsl
|
26
|
+
|
27
|
+
module Tasks
|
28
|
+
|
29
|
+
# Define main task.
|
30
|
+
|
31
|
+
def main(name, &block)
|
32
|
+
name, deps, block = *parse_task_dependencies(name, &block)
|
33
|
+
define_main(name, *deps, &block)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Define a task.
|
37
|
+
|
38
|
+
def task(name, &block)
|
39
|
+
name, deps, block = *parse_task_dependencies(name, &block)
|
40
|
+
define_task(name, *deps, &block)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Run a task.
|
44
|
+
|
45
|
+
def run(name, arguments=nil)
|
46
|
+
task_plan(name).each{ |name| tasks[name].call }
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def tasks ; @tasks ||= {} ; end
|
52
|
+
|
53
|
+
def main_task ; @main ; end
|
54
|
+
|
55
|
+
#
|
56
|
+
|
57
|
+
def parse_task_dependencies(name_deps, &block)
|
58
|
+
if Hash===name_deps
|
59
|
+
name = name_deps.keys[0]
|
60
|
+
deps = name_deps.values[0]
|
61
|
+
else
|
62
|
+
name = name_deps
|
63
|
+
deps = []
|
64
|
+
end
|
65
|
+
[name, deps, block]
|
66
|
+
end
|
67
|
+
|
68
|
+
def define_main(name=nil, *depend, &block)
|
69
|
+
@main = define_task(name, *depend, &block)
|
70
|
+
#@main = Task.new(name, *depend, &block)
|
71
|
+
#tasks[@main.name] = @main
|
72
|
+
end
|
73
|
+
|
74
|
+
def define_task(name, *depend, &block)
|
75
|
+
task = Task.new(name, *depend, &block)
|
76
|
+
tasks[task.name] = task
|
77
|
+
end
|
78
|
+
|
79
|
+
# Call main task.
|
80
|
+
#--
|
81
|
+
# TODO If @main is nil try task by same name a file (?)
|
82
|
+
# If so, be careful of infinite loop via method_missing.
|
83
|
+
#++
|
84
|
+
|
85
|
+
def run_main
|
86
|
+
return unless main_task
|
87
|
+
run(main_task.name)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Prepare plan, checking for circular dependencies.
|
91
|
+
|
92
|
+
def task_plan(name, list=[])
|
93
|
+
if list.include?(name)
|
94
|
+
raise "Circular dependency #{name}."
|
95
|
+
end
|
96
|
+
if task = tasks[name]
|
97
|
+
task.needs.each do |need|
|
98
|
+
need = need.to_s
|
99
|
+
next if list.include?(need)
|
100
|
+
#@tasks[need].task_plan(need, list)
|
101
|
+
task_plan(need, list)
|
102
|
+
end
|
103
|
+
list << task.name
|
104
|
+
else
|
105
|
+
# TODO THIS TIES TASKS INTO BATCH, BETTER WAY?
|
106
|
+
if name != main_task && fname = batch?(name)
|
107
|
+
task = Task.new(name) do
|
108
|
+
batch(fname)
|
109
|
+
end
|
110
|
+
tasks[name] = task
|
111
|
+
list << task.name
|
112
|
+
else
|
113
|
+
abort "no task -- #{name}"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
return list
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
# Task is a very simple store for defined actions
|
122
|
+
# and their prerequisites.
|
123
|
+
|
124
|
+
class Task
|
125
|
+
attr_reader :name, :needs, :action
|
126
|
+
|
127
|
+
def initialize(name, *needs, &action)
|
128
|
+
@name = name.to_s
|
129
|
+
@needs = needs
|
130
|
+
@action = action
|
131
|
+
end
|
132
|
+
|
133
|
+
def call
|
134
|
+
@action.call if @action
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
# TITLE:
|
1
|
+
# = TITLE:
|
2
2
|
#
|
3
|
-
#
|
3
|
+
# Upload DSL
|
4
4
|
#
|
5
|
-
# COPYING:
|
5
|
+
# = COPYING:
|
6
6
|
#
|
7
7
|
# Copyright (c) 2007 Psi T Corp.
|
8
8
|
#
|
@@ -21,7 +21,7 @@
|
|
21
21
|
# You should have received a copy of the GNU General Public License
|
22
22
|
# along with Ratch. If not, see <http://www.gnu.org/licenses/>.
|
23
23
|
#
|
24
|
-
# TODO:
|
24
|
+
# = TODO:
|
25
25
|
#
|
26
26
|
# - Incorporate password into scp and ftp ?
|
27
27
|
# - rsync needs --delete option
|
@@ -33,6 +33,7 @@ require 'tmpdir'
|
|
33
33
|
require 'facets/openobject'
|
34
34
|
|
35
35
|
module Ratch
|
36
|
+
module Dsl
|
36
37
|
|
37
38
|
# Upload files to host. These means of uploading are current
|
38
39
|
# supported: ftp, sftp, scp and rsync.
|
@@ -66,7 +67,7 @@ module Ratch
|
|
66
67
|
# The internal template used for the outbound destination
|
67
68
|
# is 'username@host:root/'.
|
68
69
|
|
69
|
-
module
|
70
|
+
module Upload
|
70
71
|
|
71
72
|
module_function
|
72
73
|
|
@@ -309,6 +310,7 @@ module Ratch
|
|
309
310
|
end
|
310
311
|
|
311
312
|
end
|
313
|
+
end
|
312
314
|
|
313
315
|
|
314
316
|
=begin
|