Class: Revamp::Parser::PuppetTarball
- Inherits:
-
Object
- Object
- Revamp::Parser::PuppetTarball
- Defined in:
- lib/revamp/parser/puppet-tarball.rb
Overview
This class is a parser for Puppet’s tarballs format
Defined Under Namespace
Classes: Entry
Instance Method Summary collapse
-
#initialize(tarball_file) ⇒ PuppetTarball
constructor
A new instance of PuppetTarball.
- #parse ⇒ Object
Constructor Details
#initialize(tarball_file) ⇒ PuppetTarball
Returns a new instance of PuppetTarball.
9 10 11 |
# File 'lib/revamp/parser/puppet-tarball.rb', line 9 def initialize(tarball_file) @tarball = tarball_file end |
Instance Method Details
#parse ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/revamp/parser/puppet-tarball.rb', line 13 def parse model = nil File.open(@tarball, 'rb') do |file| Zlib::GzipReader.wrap(file) do |gz| Gem::Package::TarReader.new(gz) do |tar| model = Revamp::Model::PuppetModule.new tar.each do |tarfile| entry = Entry.new(tarfile) (model, entry) if entry. model.add_file(entry.name, entry.content) if entry.file? end end end end normalize(model) end |