Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/rubygems/specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2414,7 +2414,10 @@ def test_files # :nodoc:
# still have their default values are omitted.

def to_ruby
require 'openssl'
begin
require 'openssl'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
require 'openssl'
require 'openssl'
has_openssl = true

rescue LoadError

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rescue LoadError
rescue LoadError
has_openssl = false

end
mark_version
result = []
result << "# -*- encoding: utf-8 -*-"
Expand Down Expand Up @@ -2454,7 +2457,9 @@ def to_ruby
next if handled.include? attr_name
current_value = self.send(attr_name)
if current_value != default_value(attr_name) || self.class.required_attribute?(attr_name)
result << " s.#{attr_name} = #{ruby_code current_value}" unless current_value.is_a?(OpenSSL::PKey::RSA)
unless defined?(OpenSSL) && current_value.is_a?(OpenSSL::PKey::RSA)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
unless defined?(OpenSSL) && current_value.is_a?(OpenSSL::PKey::RSA)
unless has_openssl && current_value.is_a?(OpenSSL::PKey::RSA)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this approach

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i prefer keeping consistent with the library by checking for the constant

result << " s.#{attr_name} = #{ruby_code current_value}"
end
end
end

Expand Down