def load_specification(file_name)
return nil unless file_name and File.exist? file_name
spec_code = if RUBY_VERSION < '1.9' then
File.read file_name
else
File.read file_name, :encoding => 'UTF-8'
end.untaint
begin
gemspec = eval spec_code, binding, file_name
if gemspec.is_a?(Gem::Specification)
gemspec.loaded_from = file_name
return gemspec
end
alert_warning "File '#{file_name}' does not evaluate to a gem specification"
rescue SignalException, SystemExit
raise
rescue SyntaxError => e
alert_warning e
alert_warning spec_code
rescue Exception => e
alert_warning "#{e.inspect}\n#{spec_code}"
alert_warning "Invalid .gemspec format in '#{file_name}'"
end
return nil
end