ratch 0.4.1 → 1.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.
Files changed (107) hide show
  1. data/COPYING +17 -669
  2. data/HISTORY +6 -0
  3. data/MANIFEST +36 -0
  4. data/METADATA +14 -0
  5. data/NEWS +7 -0
  6. data/README +67 -17
  7. data/bin/ratch +5 -78
  8. data/demo/tryme-task.ratch +12 -0
  9. data/demo/tryme1.ratch +6 -0
  10. data/lib/ratch/core_ext.rb +6 -0
  11. data/lib/ratch/core_ext/facets.rb +1 -0
  12. data/lib/ratch/core_ext/filetest.rb +52 -0
  13. data/lib/ratch/core_ext/object.rb +8 -0
  14. data/lib/ratch/core_ext/pathname.rb +38 -0
  15. data/lib/ratch/core_ext/string.rb +44 -0
  16. data/lib/ratch/{dsl/console.rb → core_ext/to_console.rb} +2 -76
  17. data/lib/ratch/core_ext/to_list.rb +29 -0
  18. data/lib/ratch/dsl.rb +494 -49
  19. data/lib/ratch/index.rb +4 -0
  20. data/lib/ratch/io.rb +116 -0
  21. data/lib/ratch/pathglob.rb +73 -0
  22. data/lib/ratch/plugin.rb +55 -0
  23. data/lib/ratch/runmode.rb +69 -0
  24. data/lib/ratch/script.rb +52 -0
  25. data/lib/ratch/service.rb +33 -0
  26. data/lib/ratch/task.rb +249 -0
  27. data/lib/ratch/task2.rb +298 -0
  28. data/test/README +1 -0
  29. data/test/test_helper.rb +4 -0
  30. data/test/test_task.rb +46 -0
  31. metadata +90 -150
  32. data/CHANGES +0 -22
  33. data/TODO +0 -2
  34. data/bin/lt +0 -56
  35. data/bin/ludo +0 -14
  36. data/bin/manifest +0 -451
  37. data/bin/ratch-find +0 -21
  38. data/demo/WILMA +0 -1
  39. data/demo/XR +0 -9
  40. data/demo/lib/foo/foo.rb +0 -7
  41. data/demo/p.rb +0 -9
  42. data/demo/r.rb +0 -6
  43. data/demo/t.rb +0 -3
  44. data/demo/task/config.yaml +0 -4
  45. data/demo/task/one +0 -6
  46. data/demo/task/simplebuild +0 -15
  47. data/demo/task/stats +0 -4
  48. data/demo/task/task +0 -6
  49. data/demo/task/tryme +0 -10
  50. data/lib/ratch/dsl/argv.rb +0 -112
  51. data/lib/ratch/dsl/batch.rb +0 -232
  52. data/lib/ratch/dsl/build.rb +0 -174
  53. data/lib/ratch/dsl/email.rb +0 -108
  54. data/lib/ratch/dsl/file.rb +0 -205
  55. data/lib/ratch/dsl/meta.rb +0 -125
  56. data/lib/ratch/dsl/options.rb +0 -98
  57. data/lib/ratch/dsl/setup.rb +0 -124
  58. data/lib/ratch/dsl/sign.rb +0 -243
  59. data/lib/ratch/dsl/stage.rb +0 -147
  60. data/lib/ratch/dsl/task.rb +0 -139
  61. data/lib/ratch/dsl/upload.rb +0 -436
  62. data/lib/ratch/dsl/zip.rb +0 -59
  63. data/lib/ratch/extra/email.rb +0 -5
  64. data/lib/ratch/extra/stage.rb +0 -5
  65. data/lib/ratch/extra/zip.rb +0 -5
  66. data/lib/ratch/manager.rb +0 -53
  67. data/lib/ratch/manifest.rb +0 -540
  68. data/lib/ratch/metadata/information.rb +0 -258
  69. data/lib/ratch/metadata/package.rb +0 -108
  70. data/lib/ratch/metadata/project.rb +0 -523
  71. data/lib/ratch/metadata/release.rb +0 -108
  72. data/lib/ratch/support/errors.rb +0 -4
  73. data/lib/ratch/support/filename.rb +0 -18
  74. data/lib/ratch/support/filetest.rb +0 -29
  75. data/lib/ratch/toolset/ruby/announce +0 -224
  76. data/lib/ratch/toolset/ruby/compile +0 -49
  77. data/lib/ratch/toolset/ruby/install +0 -77
  78. data/lib/ratch/toolset/ruby/notes +0 -185
  79. data/lib/ratch/toolset/ruby/pack/gem +0 -93
  80. data/lib/ratch/toolset/ruby/pack/tgz +0 -46
  81. data/lib/ratch/toolset/ruby/pack/zip +0 -46
  82. data/lib/ratch/toolset/ruby/publish +0 -57
  83. data/lib/ratch/toolset/ruby/release +0 -8
  84. data/lib/ratch/toolset/ruby/setup +0 -1616
  85. data/lib/ratch/toolset/ruby/stamp +0 -33
  86. data/lib/ratch/toolset/ruby/stats +0 -138
  87. data/lib/ratch/toolset/ruby/test/crosstest +0 -305
  88. data/lib/ratch/toolset/ruby/test/extest +0 -129
  89. data/lib/ratch/toolset/ruby/test/isotest +0 -293
  90. data/lib/ratch/toolset/ruby/test/load +0 -39
  91. data/lib/ratch/toolset/ruby/test/loadtest +0 -28
  92. data/lib/ratch/toolset/ruby/test/syntax +0 -29
  93. data/lib/ratch/toolset/ruby/test/test +0 -26
  94. data/lib/ratch/toolset/sandbox/query +0 -11
  95. data/man/ratch.man +0 -73
  96. data/meta/MANIFEST +0 -130
  97. data/meta/config.yaml +0 -9
  98. data/meta/icli.yaml +0 -16
  99. data/meta/project.yaml +0 -20
  100. data/meta/ratch.roll +0 -2
  101. data/meta/xProjectInfo +0 -41
  102. data/task/clobber/package +0 -10
  103. data/task/man +0 -14
  104. data/task/publish +0 -57
  105. data/task/release +0 -9
  106. data/task/setup +0 -1616
  107. data/task/stats +0 -138
@@ -1,125 +0,0 @@
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 release
44
- @rollrc ||= Release.load
45
- end
46
- alias_method :rollrc, :release
47
-
48
- # Load configuration data from a file. The file will
49
- # be looked for in the current script directory then
50
- # from the project root.
51
- #
52
- # Since they are YAML files, they can optionally
53
- # end with '.yaml' or '.yml'.
54
-
55
- def configuration(file=nil)
56
- @configuration ||= {}
57
- @configuration[file] ||= (
58
- if file = config_file(file)
59
- config_read(file)
60
- else
61
- Hash.new{ |h,k| h[k] = {} }
62
- end
63
- )
64
- end
65
-
66
- # If a +path+ is given it will first be looked for in the config directory of
67
- # the utility directory. If not there, then it will be looked for in the project's trunk.
68
- #
69
- # If +path+ is not given then config.yaml or config/general.yaml will be used.
70
- #
71
- # TODO: Consider more carfully where configuration should be stored.
72
-
73
- def config_file(path=nil)
74
- if path
75
- find = DEFAULT_FOLD + "#{path}{.yaml,.yml,}"
76
- else
77
- find = DEFAULT_FILE
78
- end
79
- Dir.glob(find, File::FNM_CASEFOLD).find{ |f| File.file?(f) }
80
- end
81
-
82
- #
83
-
84
- def config_read(path)
85
- #find = "{#{utility_directory}/,}#{path}{.yaml,.yml,}"
86
- #if file = Dir.glob(find)[0]
87
- if File.file?(path)
88
- YAML::load(File.open(path)) || {} # The || {} is in case the file is empty.
89
- else
90
- raise LoadError, "Missing file -- #{path}"
91
- end
92
- end
93
-
94
- # Create an argument vector from a set of config options.
95
- # TODO Deprecate in favor of Hash extension.
96
-
97
- def config_vector(config, args_field=nil)
98
- config.command_vector(args_field)
99
- end
100
-
101
- # # Load task configuration if any.
102
- #
103
- # def config_load(*names) #, defaults=nil)
104
- #
105
- # names.inject({}) do |memo, name|
106
- # name = name.to_s
107
- # #defaults = defaults || {}
108
- #
109
- # if file = config_file(name)
110
- # config = YAML.load(File.open(file))
111
- # elsif file = Dir.glob("#{utility_directory}/config{,.yaml,.yml}")[0]
112
- # config = YAML.load(File.open(file))[name.to_s]
113
- # else
114
- # config = {}
115
- # end
116
- #
117
- # config.update(memo)
118
- # end
119
- # #return defaults.update(config || {})
120
- # end
121
-
122
- end
123
-
124
- end
125
- end
@@ -1,98 +0,0 @@
1
- # = TITLE:
2
- #
3
- # Options 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
- # Options. There are derived from ARGV.
28
-
29
- module Options
30
-
31
- # Duplicate of ARGV.
32
-
33
- def argv
34
- @argv ||= ARGV.dup
35
- end
36
-
37
- # Convert command line argv to args.
38
- #
39
- # TODO Is this implmented as expected?
40
-
41
- def command_parameters
42
- argv.to_params
43
- end
44
-
45
- # Debug mode.
46
-
47
- def debug?
48
- @debug ||= %w{--debug}.any?{|a| argv.delete(a)}
49
- end
50
-
51
- #
52
-
53
- def verbose?
54
- @verbose ||= %w{--verbose}.any?{|a| argv.delete(a)}
55
- end
56
-
57
- #
58
-
59
- def verbose!
60
- @verbose = true
61
- end
62
-
63
- #
64
-
65
- def trace?
66
- @trace ||= %w{--trace}.any?{|a| argv.delete(a)}
67
- end
68
-
69
- #
70
-
71
- def trace!
72
- @trace = true
73
- end
74
-
75
- #
76
-
77
- def noharm?
78
- @noharm ||= %w{--dryrun --dry-run --noharm}.any?{|a| argv.delete(a)}
79
- end
80
- alias_method :dryrun?, :noharm? ; module_function :dryrun?
81
-
82
- def noharm!
83
- @noharm = true
84
- end
85
- alias_method :dryrun!, :noharm! ; module_function :dryrun!
86
-
87
- # Force mode.
88
-
89
- def force?
90
- @force ||= %w{--force}.any?{|a| argv.delete(a)}
91
- end
92
-
93
- def force! ; @force = true ; end
94
-
95
- end
96
-
97
- end
98
- end
@@ -1,124 +0,0 @@
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,243 +0,0 @@
1
- # = TITLE:
2
- #
3
- # Sign 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
- # = TODO:
25
- # - Do signitures belong under data/{name}/?
26
- # Heck do all these metadata files belong there?
27
- # OTOH using remote require, how would one access these?
28
- # should they be contigious to the libs themselves?
29
-
30
- #require 'autorake/tasks/manifest'
31
-
32
- #
33
- module Ratch
34
- module Dsl
35
-
36
- # Create signitures for libraries.
37
- # FIXME
38
-
39
- module Sign
40
-
41
- # Default set of files to sign.
42
- DEFAULT_SIGN_FILES = ['lib/**/*', 'ext/**/*']
43
-
44
- DEFAULT_PUBLIC_KEY = 'pubkey.pem'
45
- DEFAULT_PRIVATE_KEY = '_privkey.pem'
46
-
47
- # Generate file signitures. This task generates signitures
48
- # for each library file using public/private keys.
49
- # The sign script will generate encrypted signitures for
50
- # files in the project --by default the lib/ and ext/ files.
51
- #
52
- # name Project name [name]
53
- # keyfile Pathname to .pem file for private key
54
- # files Files to include/exclude.
55
- # output Directory to store signiture files
56
- # [data/{name}/signitures/]
57
- #
58
- # By default the keyfile is '_privkey.pem'. (BE SURE NEVER
59
- # TO PUBLISH THIS FILE!!!) But if no a private key file is
60
- # given/found, this will ask if you would like to
61
- # generate one. It also can generate a public key for the
62
- # project if it does not have one.
63
- #
64
- # There are two ways to approach key usage here. Either
65
- # a per project key pair, or use a personal key pair.
66
-
67
- def sign( override=nil )
68
- name = info.project
69
- keyfile = info.private_key
70
-
71
- output = info.sign_output
72
- files = info.sign_files
73
-
74
- files ||= DEFAULT_SIGN_FILES
75
- keyfile ||= DEFAULT_PRIVATE_KEY
76
- output ||= File.join('data',name,'signitures')
77
-
78
- files = Dir.multiglob_with_default(DEFAULT_SIGN_FILES, files)
79
-
80
- unless File.directory?( dir = File.dirname(output) )
81
- puts "Output directory #{dir} doesn't exist."
82
- return nil
83
- end
84
-
85
- output = File.expand_path(output)
86
-
87
- unless keyfile and File.exist?(keyfile)
88
- ans = ask("Private key file required. Generate one?", "yN")
89
- case ans
90
- when 'y', 'Y'
91
- keyfile = genkey(name)
92
- puts "\nFile '#{keyfile}' created. Be sure to keep this file private and secure."
93
- else
94
- puts "Task cancelled."
95
- exit -1
96
- #return nil
97
- end
98
- end
99
-
100
- keyfile = File.expand_path(keyfile)
101
-
102
- generate_signitures(keyfile, files, output)
103
- end
104
-
105
- private
106
-
107
- # Generate a signiture for a file.
108
-
109
- def generate_signitures( keyfile, files, to_folder )
110
- privkey = load_key(keyfile)
111
-
112
- dir = File.dirname(to_folder)
113
- save_key(privkey.public_key, File.join(dir, DEFAULT_PUBLIC_KEY))
114
-
115
- fu.mkdir_p(to_folder)
116
- files.each do |file|
117
- next if File.directory?(file)
118
- sig = sign_file(privkey, file)
119
- write_signiture(to_folder, file, sig)
120
- end
121
- end
122
-
123
- # Write signiture to file.
124
-
125
- def write_signiture( to_folder, file, sig )
126
- sigfile = File.join(to_folder, file + '.sig')
127
- fu.mkdir_p(File.dirname(sigfile))
128
- if project.dryrun?
129
- puts "(save #{sigfile})" unless project.quiet?
130
- else
131
- File.open( sigfile, 'w' ) do |f|
132
- f << sig
133
- end
134
- end
135
- end
136
-
137
- # Generate a signiture of a file.
138
-
139
- def sign_file( key, file )
140
- plain = File.read( file )
141
- dig = digester(info.digest||'sha256').new
142
- sig = key.sign(dig, plain)
143
- return sig
144
- end
145
-
146
- # Verify a signiture of a file.
147
-
148
- def verify_signiture?( pubkey, sig, plain )
149
- plain = plain.read if IO === plain
150
- dig = digester(info.digest||'sha256').new
151
- success = pubkey.verify(dig, sig, plain)
152
- return success
153
- end
154
-
155
- # Generate a public key from a private key.
156
- #
157
- #def pubkey( privkey )
158
- # pubkey = privkey.public_key
159
- # return pubkey
160
- #end
161
-
162
- # Load key.
163
-
164
- def load_key( file )
165
- key = OpenSSL::PKey::RSA.new(File.read(file))
166
- end
167
-
168
- # Save key.
169
-
170
- def save_key( key, file )
171
- if project.dryrun?
172
- puts "(save #{file})" unless project.quiet?
173
- else
174
- File.open( file, 'w' ) do |f|
175
- f << key.to_pem
176
- end
177
- end
178
- end
179
-
180
- # Generate a private key and save it to '_privkey.pem'.
181
-
182
- def genkey( name )
183
- key = OpenSSL::PKey::RSA.new(2048){ print "." } # @name }
184
- save_key( key, PRIVATE_KEY )
185
- return PRIVATE_KEY
186
- end
187
-
188
- # def write_keypair( libname )
189
- # privkey = genkey( libname )
190
- # pubkey = privkey.public_key
191
- # save_key( privkey, "privkey.pem" )
192
- # save_key( pubkey, "pubkey.pem" )
193
- # puts "Key pair generated. Please secure privkey.pem."
194
- # end
195
- #
196
- # # Generate a private key.
197
- #
198
- # def genkey( libname='.' )
199
- # key = OpenSSL::PKey::RSA.new(2048) { print "." } # libname }
200
- # return key
201
- # end
202
- #
203
- # # Generate a public key from a private key.
204
- #
205
- # def pubkey( privkey )
206
- # pubkey = privkey.public_key
207
- # return pubkey
208
- # end
209
-
210
- # Return a digest class for given +type+.
211
- # Supported digests are:
212
- #
213
- # * md5
214
- # * sha1
215
- # * sha128 (same as sha1)
216
- # * sha256
217
- # * sha512
218
- #
219
- # Default digest type is sha256.
220
-
221
- # def digester( type=nil )
222
- # require 'openssl'
223
- # type = 'sha256' unless type
224
- # case type.to_s.downcase
225
- # when 'md5'
226
- # require 'digest/md5'
227
- # Digest::MD5
228
- # when 'sha128', 'sha1'
229
- # require 'digest/sha1' #need?
230
- # OpenSSL::Digest::SHA1
231
- # when 'sha256'
232
- # require 'digest/sha1' #need?
233
- # OpenSSL::Digest::SHA256
234
- # when 'sha512'
235
- # require 'digest/sha1' #need?
236
- # OpenSSL::Digest::SHA512
237
- # end
238
- # end
239
-
240
- end
241
-
242
- end
243
- end