Class: Puppet::Module::Tool::Applications::Unpacker
- Inherits:
-
Application
- Object
- Application
- Puppet::Module::Tool::Applications::Unpacker
- Defined in:
- lib/puppet/module/tool/applications/unpacker.rb
Instance Attribute Summary
Attributes inherited from Application
Instance Method Summary collapse
- #force? ⇒ Boolean
-
#initialize(filename, environment_path, options = {}) ⇒ Unpacker
constructor
A new instance of Unpacker.
- #run ⇒ Object
Methods inherited from Application
#discuss, #load_modulefile!, #metadata, #parse_filename!, #repository, run
Methods included from Utils::Interrogation
#confirms?, #header, #prompt, #say, #subheader
Constructor Details
#initialize(filename, environment_path, options = {}) ⇒ Unpacker
Returns a new instance of Unpacker.
10 11 12 13 14 15 |
# File 'lib/puppet/module/tool/applications/unpacker.rb', line 10 def initialize(filename, environment_path, = {}) @filename = Pathname.new(filename) @environment_path = Pathname.new(environment_path) parse_filename! super() end |
Instance Method Details
#force? ⇒ Boolean
17 18 19 |
# File 'lib/puppet/module/tool/applications/unpacker.rb', line 17 def force? [:force] end |
#run ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/puppet/module/tool/applications/unpacker.rb', line 21 def run check_clobber! build_dir = Puppet::Module::Tool::Cache.base_path + "tmp-unpacker-#{Digest::SHA1.hexdigest(@filename.basename)}" build_dir.mkpath begin FileUtils.cp @filename, build_dir Dir.chdir(build_dir) do unless system "tar xzf #{@filename.basename}" abort "Could not extract contents of module archive." end end # grab the first directory extracted = build_dir.children.detect { |c| c.directory? } if force? FileUtils.rm_rf @full_name rescue nil end FileUtils.cp_r extracted, @full_name tag_revision ensure build_dir.rmtree end say "Installed #{@release_name.inspect} into directory: #{@full_name}" end |