mast 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/.ruby ADDED
@@ -0,0 +1,49 @@
1
+ ---
2
+ source:
3
+ - meta
4
+ authors:
5
+ - name: Trans
6
+ email: transfire@gmail.com
7
+ copyrights:
8
+ - holder: Thomas Sawyer
9
+ year: '2009'
10
+ replacements: []
11
+ alternatives: []
12
+ requirements:
13
+ - name: detroit
14
+ groups:
15
+ - build
16
+ development: true
17
+ - name: qed
18
+ groups:
19
+ - test
20
+ development: true
21
+ dependencies: []
22
+ conflicts: []
23
+ repositories:
24
+ - uri: git://github.com/rubyworks/mast.git
25
+ scm: git
26
+ name: upstream
27
+ resources:
28
+ home: http://rubyworks.github.com/mast/
29
+ code: http://github.com/rubyworks/mast/
30
+ mail: http://groups.google.com/group/rubyworks-mailinglist
31
+ extra: {}
32
+ load_path:
33
+ - lib
34
+ revision: 0
35
+ created: '2009-08-17'
36
+ summary: Mast is a command line tool for generating manifests and digests.
37
+ title: Mast
38
+ version: 1.4.0
39
+ name: mast
40
+ description: ! 'Mast is a command line tool for generating manifests and digests.
41
+ Mast makes
42
+
43
+ it easy to compare a manifest to a current directory structure, and to update
44
+
45
+ the manifest with a simple command by storing the command options it the
46
+
47
+ manifest file itself.'
48
+ organization: rubyworks
49
+ date: '2011-10-30'
@@ -0,0 +1,31 @@
1
+ = COPYRIGHT NOTICES
2
+
3
+ == Mast
4
+
5
+ Copyright:: (c) 2009 Rubyworks
6
+ License:: BSD-2-Clause
7
+ Website:: http://rubyworks.github.com/tapout
8
+
9
+ Copyright 2009 Rubyworks. All rights reserved.
10
+
11
+ Redistribution and use in source and binary forms, with or without
12
+ modification, are permitted provided that the following conditions are met:
13
+
14
+ 1. Redistributions of source code must retain the above copyright notice,
15
+ this list of conditions and the following disclaimer.
16
+
17
+ 2. Redistributions in binary form must reproduce the above copyright
18
+ notice, this list of conditions and the following disclaimer in the
19
+ documentation and/or other materials provided with the distribution.
20
+
21
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
+ COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
28
+ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+
@@ -1,5 +1,20 @@
1
1
  = RELEASE HISTORY
2
2
 
3
+ == 1.3.0 / 2011-10-30
4
+
5
+ This release adds a few additional features, see changes list below. It also
6
+ changes the license to BSD-2-Clause and modernizes the build configuration.
7
+
8
+ Changes:
9
+
10
+ * Add `--recent` command to check if up to date.
11
+ * Add `--no-head` option to suppress header.
12
+ * Improve help system with man-page.
13
+ * Update output shows diff if file changed.
14
+ * Modernize build configuration.
15
+ * Switch to BSD-2-Cluase license.
16
+
17
+
3
18
  == 1.3.0 / 2010-11-21
4
19
 
5
20
  Version 1.3 primarily makes a few adjustment under-the-hood. It switches
@@ -7,7 +22,7 @@ GetoptLong out for OptionParser, gets rid of it's dependency on Ruby Facets'
7
22
  Kernel#ask method, and changes the diff comment short name from `-d` to `-D`.
8
23
  Lowecase `-d` is now used as a short name for the `--dir` option. In the
9
24
  process a bug was fixed where this `-d` option was not being added to the
10
- manifest's bang line. Lastly, the `-s`/`--show` option has been enamed to
25
+ manifest's bang line. Lastly, the `-s`/`--show` option has been renamed to
11
26
  `-b`/`--bang`, which is more descriptive.
12
27
 
13
28
  Changes:
@@ -2,7 +2,7 @@
2
2
 
3
3
  Mast in a manifest and digest generator.
4
4
 
5
- Let say we have a directory containing a set of files as follows:
5
+ Lets say we have a directory containing a set of files as follows:
6
6
 
7
7
  README.txt
8
8
  lib/foo.rb
@@ -84,7 +84,6 @@ a file name:
84
84
  Once saved, `mast` has an update mode via the `-u` option:
85
85
 
86
86
  $ mast -u
87
- MANIFEST.txt updated.
88
87
 
89
88
  By default this works for any manifest file with a name matching "manifest{,.*}",
90
89
  case insensitvive. An alternate file name can be supplied using the `-f` option.
@@ -94,7 +93,6 @@ verification that a manifest file matches the current contents of the directory
94
93
  can be had via the `-v`/`--verify` option:
95
94
 
96
95
  $ mast -v
97
- Manifest is good.
98
96
 
99
97
  To see what files are new, that is to say added to the the directory but not
100
98
  listed in the manifest file, use the `-n/--new` option. For instance, let's
@@ -131,3 +129,29 @@ on the bang line of a manifest file via the `-b`/`--bang` option:
131
129
  lib/bar.rb
132
130
  lib/baz.rb
133
131
 
132
+
133
+ == Manifest Generation
134
+
135
+ Lets say we have a directory containing a set of files as follows:
136
+
137
+ README.txt
138
+ lib/foo.rb
139
+ lib/bar.rb
140
+
141
+ We can crate a new Manifest object, utilizing a StringIO object to catch
142
+ the output.
143
+
144
+ out = ''
145
+
146
+ manifest = Mast::Manifest.new(:io=>StringIO.new(out))
147
+
148
+ If we call the generate method, then the output should list the
149
+ above file along with a generic shebang header.
150
+
151
+ manifest.generate
152
+
153
+ list = out.split("\n").sort
154
+
155
+ list.assert == ['#!mast *','README.txt','lib/bar.rb','lib/foo.rb']
156
+
157
+
@@ -7,11 +7,18 @@
7
7
  '-----------'
8
8
 
9
9
 
10
+ {Homepage}[http://rubyworks.github.com/mast/] |
11
+ {Source Code}[http://github.com/rubyworks/mast/] | #rubyworks
12
+
13
+
14
+ {<img src="http://travis-ci.org/rubyworks/mast.png" />}[http://travis-ci.org/rubyworks/mast]
15
+
16
+
10
17
  == DESCRIPTION
11
18
 
12
19
  Mast is a commandline utility for generating MANIFEST and DIGEST lists.
13
- It can be useful in conjunction with packaging tools (such as Box),
14
- or as a stand-alone tool for monitoring file changes.
20
+ It can be useful in conjunction with packaging tools, or as a stand-alone
21
+ tool for monitoring file changes.
15
22
 
16
23
 
17
24
  == FEATURES
@@ -21,13 +28,6 @@ or as a stand-alone tool for monitoring file changes.
21
28
  * Checksum digests can highlight file changes.
22
29
 
23
30
 
24
- == RESOURCES
25
-
26
- * home: http://rubyworks.github.com/mast/
27
- * work: http://github.com/rubyworks/mast/
28
- * wiki: http://wiki.github.com/rubyworks/mast/
29
-
30
-
31
31
  == USAGE
32
32
 
33
33
  Mast makes the process of generating manifests very easy, and even allows
@@ -135,17 +135,8 @@ See {Ruby Setup}[http://rubyworks.github.com/setup] for more information.
135
135
 
136
136
  == COPYRIGHT
137
137
 
138
- Copyright (c) 2009 Thomas Sawyer
139
-
140
- Licensed under the Apache License, Version 2.0 (the "License");
141
- you may not use this file except in compliance with the License.
142
- You may obtain a copy of the License at
143
-
144
- http://www.apache.org/licenses/LICENSE-2.0
138
+ Copyright (c) 2009 Rubyworks
145
139
 
146
- Unless required by applicable law or agreed to in writing, software
147
- distributed under the License is distributed on an "AS IS" BASIS,
148
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
149
- See the License for the specific language governing permissions and
150
- limitations under the License.
140
+ Mast is distributable according to the terms of the BSD-2-Clause license.
151
141
 
142
+ See COPYING.rdoc for details.
@@ -1,2 +1,20 @@
1
- require 'mast/meta/data'
1
+ module Mast
2
+ # Access to project metadata.
3
+ def self.metadata
4
+ @metadata ||= (
5
+ require 'yaml'
6
+ YAML.load(File.new(File.dirname(__FILE__) + '/mast.yml'))
7
+ )
8
+ end
9
+
10
+ # Access project metadata via constants.
11
+ def self.const_missing(name)
12
+ key = name.to_s.downcase
13
+ package[key] || super(name)
14
+ end
15
+
16
+ # becuase Ruby 1.8~ gets in the way
17
+ VERSION = metadata['version']
18
+ end
19
+
2
20
  require 'mast/manifest'
@@ -0,0 +1,49 @@
1
+ ---
2
+ source:
3
+ - meta
4
+ authors:
5
+ - name: Trans
6
+ email: transfire@gmail.com
7
+ copyrights:
8
+ - holder: Thomas Sawyer
9
+ year: '2009'
10
+ replacements: []
11
+ alternatives: []
12
+ requirements:
13
+ - name: detroit
14
+ groups:
15
+ - build
16
+ development: true
17
+ - name: qed
18
+ groups:
19
+ - test
20
+ development: true
21
+ dependencies: []
22
+ conflicts: []
23
+ repositories:
24
+ - uri: git://github.com/rubyworks/mast.git
25
+ scm: git
26
+ name: upstream
27
+ resources:
28
+ home: http://rubyworks.github.com/mast/
29
+ code: http://github.com/rubyworks/mast/
30
+ mail: http://groups.google.com/group/rubyworks-mailinglist
31
+ extra: {}
32
+ load_path:
33
+ - lib
34
+ revision: 0
35
+ created: '2009-08-17'
36
+ summary: Mast is a command line tool for generating manifests and digests.
37
+ title: Mast
38
+ version: 1.4.0
39
+ name: mast
40
+ description: ! 'Mast is a command line tool for generating manifests and digests.
41
+ Mast makes
42
+
43
+ it easy to compare a manifest to a current directory structure, and to update
44
+
45
+ the manifest with a simple command by storing the command options it the
46
+
47
+ manifest file itself.'
48
+ organization: rubyworks
49
+ date: '2011-10-30'
@@ -1,50 +1,3 @@
1
- # mast v1.0.0
2
- #
3
- # Usage:
4
- # mast [command] [options...]
5
- #
6
- # The manifest listing tool is used to list, create or update a
7
- # manifest for a directory (eg. to define a "package"), or compare
8
- # a manifest to actual directory contents. Mast is part of the
9
- # ProUtils set of tools.
10
- #
11
- # When no command is given, a manifest is dumped to standard out.
12
- # If --file is specified, it will generate to that file instead.
13
- #
14
- # Examples:
15
- # mast
16
- # mast -u -f PUBLISH
17
- #
18
- # Commands:
19
- # -c --create Generate a new manifest. (default)
20
- # -u --update Update an existing manifest.
21
- # -l --list List the files given in the manifest file. (Use -f to specify an alternate file.)
22
- # -D --diff Diff manifest file against actual.
23
- # -n --new List existant files that are not given in the manifest.
24
- # -o --old List files given in the manifest but are non-existent.
25
- # --clean Remove non-manifest files. (Will ask for confirmation first.)
26
- # -v --verify Verify that a manifest matches actual.
27
- # -h --help Display this help message.
28
- #
29
- # Options:
30
- # -a --all Include all files. This deactivates deafult exclusions
31
- # so it is possible to make complete list of all contents.
32
- # -d --dir When creating a list include directory paths; by default
33
- # only files are listed.
34
- # -b --bang Produce new manifest but using options from the bang line of the manifest file.
35
- # -f --file PATH Path to manifest file. This applies to comparison commands.
36
- # If not given then the file matching 'MANIFEST', case-insensitive
37
- # and with an optional '.txt' extension, in the current directory
38
- # is used. If the path of the manifest file is anything else then
39
- # the --file option must be specified.
40
- # -g --digest TYPE Include crytographic signiture. Type can be either
41
- # md5, sha1, sha128, sha256, or sha512.
42
- # -x --exclude PATH Exclude a file or dir from the manifest matching against
43
- # full pathname. You can use --exclude repeatedly.
44
- # -i --ignore PATH Exclude a file or dir from the manifest matching against
45
- # an entries basename. You can use --ignore repeatedly.
46
- # -q --quiet Suppress any extraneous output.
47
-
48
1
  require 'mast'
49
2
  require 'optparse'
50
3
 
@@ -117,6 +70,7 @@ module Mast
117
70
  when :old then old
118
71
  when :verify then verify
119
72
  when :clean then clean
73
+ when :recent then recent
120
74
  else
121
75
  generate
122
76
  end
@@ -125,58 +79,68 @@ module Mast
125
79
  # Parse command line options.
126
80
  def option_parser
127
81
  OptionParser.new do |opt|
128
- opt.on "--file", "-f FILE" do |file|
82
+ opt.on "-f", "--file FILE", "Path to manifest file. Looks for file matching /MANIFEST(|.txt)/i by default." do |file|
129
83
  @options[:file] = file
130
84
  end
131
- opt.on "--digest", "-g TYPE" do |digest|
85
+ opt.on "-g", "--digest TYPE", "Include cryptographic signature. Type can be either md5, sha1, sha128, sha256, or sha512." do |digest|
132
86
  @options[:digest] = digest
133
87
  end
134
- opt.on "--exclude", "-x GLOB" do |glob|
88
+ opt.on "-x", "--exclude GLOB", "Exclude file or dir from the manifest matching against full pathname. Can be used repeatedly." do |glob|
135
89
  @options[:exclude] << glob
136
90
  end
137
- opt.on "--ignore", "-i GLOB" do |glob|
91
+ opt.on "-i", "--ignore GLOB",
92
+ "Exclude file or dir from manifest matching against an entry's basename. Can be used repeatedly." do |glob|
138
93
  @options[:ignore] << glob
139
94
  end
140
- opt.on "--all", "-a" do |bool|
95
+ opt.on "-a", "--all", "Include all files. This deactivates default exclusions so it is possible to make complete list of all contents." do |bool|
141
96
  @options[:all] = true
142
97
  end
143
- opt.on "--bang", "-b" do |bool|
98
+ opt.on "--bang", "-b", "Generate manifest using the options from the bang line of the manifest file." do |bool|
144
99
  @options[:bang] = true
145
100
  end
146
- opt.on "--dir", "-d" do |bool|
101
+ opt.on "--dir", "-d", "When creating a list include directory paths; by default only files are listed." do |bool|
147
102
  @options[:dir] = bool
148
103
  end
149
- #opt.on "--quiet", "-q", "" do |bool|
150
- # @quiet = bool
151
- #end
152
- opt.on "--create", "-c" do
104
+ opt.on "--[no-]head", "Suppress mast header from output." do |bool|
105
+ @options[:headless] = !bool
106
+ end
107
+ opt.on "-c", "--create", "Generate a new manifest. (default)" do
153
108
  @command << :create
154
109
  end
155
- opt.on "--update", "-u" do
110
+ opt.on "-u", "--update", "Update an existing manifest." do
156
111
  @command << :update
157
112
  end
158
- opt.on "--list", "-l" do
113
+ opt.on "-l", "--list", "List the files given in the manifest file. (Use -f to specify an alternate file.)" do
159
114
  @command << :list
160
115
  end
161
- opt.on "--diff", "-D" do
116
+ opt.on "-D", "--diff", "Diff manifest file against actual." do
162
117
  @command << :diff
163
118
  end
164
- opt.on "--new", "-n" do
119
+ opt.on "-n", "--new", "List existent files that are not given in the manifest." do
165
120
  @command << :new
166
121
  end
167
- opt.on "--old", "-o" do
122
+ opt.on "-o", "--old", "List files given in the manifest but are non-existent." do
168
123
  @command << :old
169
124
  end
170
- opt.on "--verify", "-v" do
125
+ opt.on "-v", "--verify", "Verify that a manifest matches actual." do
171
126
  @command << :verify
172
127
  end
173
- opt.on "--clean" do
128
+ opt.on "--clean", "Remove non-manifest files. (Will ask for confirmation first.)" do
174
129
  @command << :clean
175
130
  end
176
- opt.on "--help" do
131
+ opt.on "-r", "--recent", "Verify that a manifest is more recent than actual." do
132
+ @command << :recent
133
+ end
134
+ opt.on "-h", "--help", "Display this help message." do
177
135
  @command << :help
178
136
  end
179
- opt.on "--debug" do
137
+ opt.on "-H" do
138
+ puts opt; exit
139
+ end
140
+ opt.on "-q", "--quiet", "Suppress all extraneous output." do
141
+ @quiet = true
142
+ end
143
+ opt.on "--debug", "Run in debug mode." do
180
144
  $DEBUG = true
181
145
  end
182
146
  end
@@ -193,13 +157,18 @@ module Mast
193
157
 
194
158
  # Update a MANIFEST file for this package.
195
159
  def update
196
- begin
197
- file = manifest.update
198
- rescue NoManifestError => e
199
- puts e.message
200
- exit -1
160
+ if manifest.verify
161
+ else
162
+ begin
163
+ diff = manifest.diff
164
+ file = manifest.update
165
+ rescue Manifest::NoManifestError => e
166
+ puts e.message
167
+ exit -1
168
+ end
169
+ report_difference(diff)
170
+ #report_updated(file)
201
171
  end
202
- report_updated(file)
203
172
  end
204
173
 
205
174
  alias_method :up, :update
@@ -255,6 +224,20 @@ module Mast
255
224
  end
256
225
  end
257
226
 
227
+ # Verify manifest, then check to see that it is not older than files
228
+ # it lists.
229
+ def recent
230
+ check = manifest.verify
231
+ if !check
232
+ report_verify(check)
233
+ exit -1
234
+ end
235
+ if !FileUtils.uptodate?(manifest.file, manifest.filelist)
236
+ report_outofdate
237
+ exit -1
238
+ end
239
+ end
240
+
258
241
  # Display command help information.
259
242
  def help
260
243
  report_help
@@ -345,13 +328,12 @@ module Mast
345
328
  # Show help.
346
329
  def report_help
347
330
  doc = false
348
- File.readlines(__FILE__).each do |line|
349
- line = line.strip
350
- break if doc && line.empty?
351
- next if line =~ /^#!/
352
- next if line.empty?
353
- puts line[1..-1].sub(/^\ \ /,'')
354
- doc = true
331
+ man_page = File.dirname(__FILE__) + '/../../man/man1/mast.1'
332
+ ronn_file = File.dirname(__FILE__) + '/../../man/man1/mast.1.ronn'
333
+ if File.exist?(man_page)
334
+ system "man #{man_page}" || puts(File.read(ronn_file))
335
+ else
336
+ puts option_parser
355
337
  end
356
338
  end
357
339
 
@@ -384,6 +366,11 @@ module Mast
384
366
  end
385
367
  end
386
368
 
369
+ #
370
+ def report_outofdate
371
+ report "Manifest is older than listed file(s)."
372
+ end
373
+
387
374
  #
388
375
  def ask(prompt=nil)
389
376
  $stdout << "#{prompt}"