Class: FPM::Fry::Tar::Reader
- Inherits:
-
Object
- Object
- FPM::Fry::Tar::Reader
- Includes:
- Enumerable
- Defined in:
- lib/fpm/fry/tar.rb
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(io) ⇒ Reader
constructor
A new instance of Reader.
- #map ⇒ Object
Constructor Details
#initialize(io) ⇒ Reader
Returns a new instance of Reader.
11 12 13 |
# File 'lib/fpm/fry/tar.rb', line 11 def initialize(io) @reader = Gem::Package::TarReader.new(io) end |
Instance Method Details
#each ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fpm/fry/tar.rb', line 15 def each return to_enum(:each) unless block_given? last_pax_header = nil @reader.each do |entry| if entry.header.typeflag == 'x' last_pax_header = extract_pax_header(entry.read) else if last_pax_header && (path = last_pax_header["path"]) entry.header.instance_variable_set :@name, path last_pax_header = nil end yield entry end end end |
#map ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/fpm/fry/tar.rb', line 32 def map return to_enum(:map) unless block_given? res = [] each do |entry| res << yield(entry) end res end |