Module: Packmule
- Defined in:
- lib/packmule/version.rb,
lib/packmule.rb,
lib/packmule/cli.rb,
lib/packmule/archiver.rb,
lib/packmule/archiver/tar.rb,
lib/packmule/archiver/zip.rb
Overview
Packmule Copyright © 2012-2015 Nirix github.com/nirix
Packmule is released under the GNU GPL v3 only license.
Defined Under Namespace
Constant Summary collapse
- VERSION =
"0.7.0"
Class Method Summary collapse
-
.pack(options) ⇒ Object
The center of Packmule, takes the Packfile and packs the directory according to the options.
-
.read_packfile ⇒ Object
Reads configuration from the ‘Packfile`.
-
.remove_files(dir, files) ⇒ Object
Removes the specified files from the specified directory.
-
.run_commands(dir, commands) ⇒ Object
Runs the specified commands in the specified directory.
Class Method Details
.pack(options) ⇒ Object
The center of Packmule, takes the Packfile and packs the directory according to the options.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/packmule.rb', line 19 def self.pack() require 'yaml' require 'fileutils' require 'tmpdir' tempdir = Dir.mktmpdir # Read the Packfile and exit if it doesn't exist puts "Reading the Packfile..." config = self.read_packfile # Options opt = { :filename => config['package-as'] + ([:version] != '' ? '-' + [:version] : ''), :formats => config['formats'], :version => [:version], :ignore => config['ignore'], :commands => config['commands'] } # Clone directory ::FileUtils.cp_r './', tempdir # Any commands? if opt[:commands] self.run_commands tempdir, opt[:commands] end # Remove ignored files and directories if opt[:ignore] self.remove_files tempdir, opt[:ignore] end # Archive the directory Packmule::Archiver.create({ :filename => opt[:filename], :formats => opt[:formats], :ignore => opt[:ignore], :dir => tempdir }) # Cleanup FileUtils.remove_entry_secure tempdir puts "Packaging complete" exit end |
.read_packfile ⇒ Object
Reads configuration from the ‘Packfile`
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/packmule.rb', line 69 def self.read_packfile begin config = YAML::load_file('./Packfile') rescue puts "No Packfile found, stopping" exit; end return config end |
.remove_files(dir, files) ⇒ Object
Removes the specified files from the specified directory.
91 92 93 94 95 |
# File 'lib/packmule.rb', line 91 def self.remove_files(dir, files) files.each do |file| ::FileUtils.rm_rf Dir["#{dir}/#{file}"], :secure => true end end |
.run_commands(dir, commands) ⇒ Object
Runs the specified commands in the specified directory.
82 83 84 85 86 87 |
# File 'lib/packmule.rb', line 82 def self.run_commands(dir, commands) commands.each do |c| # Change to tempdir and run `cd #{dir}; #{c}` end end |