Class: Cartage::Manifest
- Defined in:
- lib/cartage/manifest.rb,
lib/cartage/manifest/commands.rb
Overview
(‘.cartignore’).
Defined Under Namespace
Modules: HandleMissingManifest Classes: CheckCommand, InstallDefaultIgnoreCommand, ManifestCommand, ShowCommand
Constant Summary collapse
- MissingError =
This exception is raised if the package manifest is missing.
Class.new(StandardError) do def "Cartage cannot create a package without a Manifest.txt file. You may generate\nor update the Manifest.txt file with the following command:\n\n exception\n end\nend\n"
- DIFF =
:nodoc:
if system('gdiff', __FILE__, __FILE__) #:nodoc: 'gdiff' else 'diff' end
Class Method Summary collapse
-
.commands ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#check ⇒ Object
Checks Manifest.txt.
-
#generate ⇒ Object
Generates Manifest.txt.
-
#initialize(cartage) ⇒ Manifest
constructor
:nodoc:.
-
#install_default_ignore(mode: nil) ⇒ Object
Installs the default .cartignore file.
-
#resolve(path = nil, command: nil) ⇒ Object
Resolve the Manifest to something that can be used by
tar -T.
Methods inherited from Plugin
decorate, inherited, load, registered
Constructor Details
#initialize(cartage) ⇒ Manifest
:nodoc:
22 23 24 |
# File 'lib/cartage/manifest.rb', line 22 def initialize(cartage) #:nodoc: @cartage = cartage end |
Class Method Details
.commands ⇒ Object
:nodoc:
97 98 99 100 101 102 103 104 |
# File 'lib/cartage/manifest/commands.rb', line 97 def self.commands #:nodoc: [ ManifestCommand, CheckCommand, InstallDefaultIgnoreCommand, ShowCommand ] end |
Instance Method Details
#check ⇒ Object
Checks Manifest.txt
67 68 69 70 71 72 73 74 |
# File 'lib/cartage/manifest.rb', line 67 def check raise MissingError unless manifest_file.exist? tmp = create_file_list('Manifest.tmp') system(DIFF, '-du', manifest_file.basename.to_s, tmp.to_s) $?.success? ensure tmp.unlink if tmp end |
#generate ⇒ Object
Generates Manifest.txt.
62 63 64 |
# File 'lib/cartage/manifest.rb', line 62 def generate create_file_list(manifest_file) end |
#install_default_ignore(mode: nil) ⇒ Object
Installs the default .cartignore file.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/cartage/manifest.rb', line 77 def install_default_ignore(mode: nil) mode = mode.to_s.downcase.strip save = mode || !ignore_file.exist? if mode == :merge data = strip_comments_and_empty_lines(ignore_file.readlines) if data.empty? data = DEFAULT_IGNORE else data += strip_comments_and_empty_lines(DEFAULT_IGNORE.split($/)) data = data.uniq.join("\n") end else data = DEFAULT_IGNORE end ignore_file.open('w') { |f| f.puts data } if save end |
#resolve(path = nil, command: nil) ⇒ Object
Resolve the Manifest to something that can be used by tar -T. The manifest should be relative to the files in the repository, as reported from git ls-files. tar requires either full paths, or files relative to the directory you are packaging from (and we want relative files).
This reads the manifest, prunes it with package ignores, and then writes it in a GNU tar compatible format as a tempfile. It does this by taking the expanded version of path, grabbing the basename, and inserting that in front of every line in the Manifest.
If path is not provided, Dir.pwd is used.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/cartage/manifest.rb', line 38 def resolve(path = nil, command: nil) # :yields: resolved manifest filename raise MissingError unless manifest_file.exist? data = strip_comments_and_empty_lines(manifest_file.readlines) raise "Manifest.txt is empty." if data.empty? path = Pathname(path || Dir.pwd)..basename tmpfile = Tempfile.new('Manifest') tmpfile.puts prune(data, with_slugignore: true).map { |line| path.join(line).to_s }.join("\n") tmpfile.close yield tmpfile.path ensure if tmpfile tmpfile.close tmpfile.unlink end end |