read_until_dashes(io)
public
Reads lines until a “—” separator is found
Show source
def read_until_dashes io
while (line = io.gets) && line.chomp.strip != "---" do
yield line if block_given?
end
end
def skip_ruby io
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
def spec
verify
return @spec if @spec
yaml = ''
open @gem, 'rb' 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::ENGINE.yamler == 'syck' then
YAML::ParseError
else
YAML::SyntaxError
end
begin
@spec = Gem::Specification.from_yaml yaml
rescue yaml_error => e
raise Gem::Exception, "Failed to parse gem specification out of gem file"
end
rescue ArgumentError => e
raise Gem::Exception, "Failed to parse gem specification out of gem file"
end
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