diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-25 15:13:14 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-25 15:13:14 +0000 |
commit | d0233291bc8a5068e52c69c210e5979e5324b5bc (patch) | |
tree | 7d9459449c33792c63eeb7baa071e76352e0baab /trunk/lib/rubygems/format.rb | |
parent | 0dc342de848a642ecce8db697b8fecd83a63e117 (diff) | |
parent | 72eaacaa15256ab95c3b52ea386f88586fb9da40 (diff) |
re-adding tag v1_9_0_4 as an alias of trunk@18848v1_9_0_4
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_9_0_4@18849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'trunk/lib/rubygems/format.rb')
-rw-r--r-- | trunk/lib/rubygems/format.rb | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/trunk/lib/rubygems/format.rb b/trunk/lib/rubygems/format.rb deleted file mode 100644 index 7dc127d5f4..0000000000 --- a/trunk/lib/rubygems/format.rb +++ /dev/null @@ -1,87 +0,0 @@ -#-- -# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. -# All rights reserved. -# See LICENSE.txt for permissions. -#++ - -require 'fileutils' - -require 'rubygems/package' - -module Gem - - ## - # The format class knows the guts of the RubyGem .gem file format - # and provides the capability to read gem files - # - class Format - attr_accessor :spec, :file_entries, :gem_path - extend Gem::UserInteraction - - ## - # Constructs an instance of a Format object, representing the gem's - # data structure. - # - # gem:: [String] The file name of the gem - # - def initialize(gem_path) - @gem_path = gem_path - end - - ## - # Reads the named gem file and returns a Format object, representing - # the data from the gem file - # - # file_path:: [String] Path to the gem file - # - def self.from_file_by_path(file_path, security_policy = nil) - format = nil - - unless File.exist?(file_path) - raise Gem::Exception, "Cannot load gem at [#{file_path}] in #{Dir.pwd}" - end - - # check for old version gem - if File.read(file_path, 20).include?("MD5SUM =") - require 'rubygems/old_format' - - format = OldFormat.from_file_by_path(file_path) - else - open file_path, Gem.binary_mode do |io| - format = from_io io, file_path, security_policy - end - end - - return format - end - - ## - # Reads a gem from an io stream and returns a Format object, representing - # the data from the gem file - # - # io:: [IO] Stream from which to read the gem - # - def self.from_io(io, gem_path="(io)", security_policy = nil) - format = new gem_path - - Package.open io, 'r', security_policy do |pkg| - format.spec = pkg.metadata - format.file_entries = [] - - pkg.each do |entry| - size = entry.header.size - mode = entry.header.mode - - format.file_entries << [{ - "size" => size, "mode" => mode, "path" => entry.full_name, - }, - entry.read - ] - end - end - - format - end - - end -end |