Class: Source::Gem::FilesFromGemProvider
- Inherits:
-
FilesProvider
- Object
- FilesProvider
- Source::Gem::FilesFromGemProvider
- Defined in:
- lib/gpm/source/gem.rb
Instance Method Summary collapse
- #file_contents ⇒ Object
-
#initialize(contents) ⇒ FilesFromGemProvider
constructor
A new instance of FilesFromGemProvider.
- #tar_files(io) ⇒ Object
Methods inherited from FilesProvider
Constructor Details
#initialize(contents) ⇒ FilesFromGemProvider
Returns a new instance of FilesFromGemProvider.
11 12 13 |
# File 'lib/gpm/source/gem.rb', line 11 def initialize(contents) @gem_file_contents = contents end |
Instance Method Details
#file_contents ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/gpm/source/gem.rb', line 14 def file_contents return {} unless @gem_file_contents tar_files = tar_files(StringIO.new(@gem_file_contents)) reader = Zlib::GzipReader.new(StringIO.new(tar_files["data.tar.gz"])) contents = tar_files(reader) reader.close contents end |
#tar_files(io) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/gpm/source/gem.rb', line 22 def tar_files(io) tar_reader = ::Gem::Package::TarReader.new(io) tar_files = {} tar_reader.each do |entry| tar_files[entry.full_name] = entry.read end tar_reader.close tar_files end |