read_until_dashes(io)public
Reads lines until a “—” separator is found
# File lib/rubygems/package/old.rb, line 110
def read_until_dashes io # :nodoc:
while (line = io.gets) && line.chomp.strip != "---" do
yield line if block_given?
end
end
##
# Skips the Ruby self-install header in +io+.
def skip_ruby io # :nodoc:
loop do
line = io.gets
return if line.chomp == '__END__'
break unless line
end
raise Gem::Exception, "Failed to find end of Ruby script while reading gem"
end
##
# The specification for this gem
def spec
verify
return @spec if @spec
yaml = String.new
@gem.with_read_io do |io|
skip_ruby io
read_until_dashes io do |line|
yaml << line
end
end
yaml_error = if RUBY_VERSION < '1.9' then
YAML::ParseError
elsif YAML.const_defined?(:ENGINE) && YAML::ENGINE.yamler == 'syck' then
YAML::ParseError
else
YAML::SyntaxError
end
begin
@spec = Gem::Specification.from_yaml yaml
rescue yaml_error
raise Gem::Exception, "Failed to parse gem specification out of gem file"
end
rescue ArgumentError
raise Gem::Exception, "Failed to parse gem specification out of gem file"
end
##
# Raises an exception if a security policy that verifies data is active.
# Old format gems cannot be verified as signed.
def verify
return true unless @security_policy
raise Gem::Security::Exception,
'old format gems do not contain signatures and cannot be verified' if
@security_policy.verify_data
true
end
end Related methods
- Instance methods
- contents
- extract_files
- file_list
- read_until_dashes
- skip_ruby
- spec
- verify
- Class methods
- new