Class: Puppet::Module::Tool::Applications::Installer
- Inherits:
-
Application
- Object
- Application
- Puppet::Module::Tool::Applications::Installer
- Defined in:
- lib/puppet/module/tool/applications/installer.rb
Instance Attribute Summary
Attributes inherited from Application
Instance Method Summary collapse
- #force? ⇒ Boolean
-
#initialize(name, options = {}) ⇒ Installer
constructor
A new instance of Installer.
- #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(name, options = {}) ⇒ Installer
Returns a new instance of Installer.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/puppet/module/tool/applications/installer.rb', line 11 def initialize(name, = {}) if File.exist?(name) if File.directory?(name) # TODO Unify this handling with that of Unpacker#check_clobber! abort "Module already installed: #{name}" end @source = :filesystem @filename = File.(name) parse_filename! else @source = :repository begin @username, @module_name = Puppet::Module::Tool::username_and_modname_from(name) rescue ArgumentError abort "Could not install module with invalid name: #{name}" end @version_requirement = [:version] end super() end |
Instance Method Details
#force? ⇒ Boolean
32 33 34 |
# File 'lib/puppet/module/tool/applications/installer.rb', line 32 def force? [:force] end |
#run ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/puppet/module/tool/applications/installer.rb', line 36 def run case @source when :repository if match['file'] begin cache_path = repository.retrieve(match['file']) rescue OpenURI::HTTPError => e abort "Could not install module: #{e.}" end Unpacker.run(cache_path, Dir.pwd, ) else abort "Malformed response from module repository." end when :filesystem repository = Repository.new('file:///') uri = URI.parse("file://#{File.(@filename)}") cache_path = repository.retrieve(uri) Unpacker.run(cache_path, Dir.pwd, ) else abort "Could not determine installation source" end end |