Class: PuppetLibrary::ModuleRepo
- Inherits:
-
Object
- Object
- PuppetLibrary::ModuleRepo
- Defined in:
- lib/puppet_library/module_repo.rb
Instance Method Summary collapse
- #get_metadata(author, module_name) ⇒ Object
- #get_module(author, name, version) ⇒ Object
-
#initialize(module_dir) ⇒ ModuleRepo
constructor
A new instance of ModuleRepo.
Constructor Details
#initialize(module_dir) ⇒ ModuleRepo
Returns a new instance of ModuleRepo.
21 22 23 |
# File 'lib/puppet_library/module_repo.rb', line 21 def initialize(module_dir) @module_dir = module_dir end |
Instance Method Details
#get_metadata(author, module_name) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/puppet_library/module_repo.rb', line 35 def (, module_name) Dir["#{@module_dir}/#{author}-#{module_name}*"].map do |module_path| tar = Gem::Package::TarReader.new(Zlib::GzipReader.open(module_path)) tar.rewind = tar.find {|e| e.full_name =~ /[^\/]+\/metadata\.json/} JSON.parse(.read) end end |
#get_module(author, name, version) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/puppet_library/module_repo.rb', line 25 def get_module(, name, version) file_name = "#{author}-#{name}-#{version}.tar.gz" path = File.join(File.(@module_dir), file_name) if File.exist? path File.open(path, 'r') else nil end end |