Class: Bundler::SSLCerts::CertificateManager
- Inherits:
-
Object
- Object
- Bundler::SSLCerts::CertificateManager
- Defined in:
- lib/bundler/ssl_certs/certificate_manager.rb
Instance Attribute Summary collapse
-
#bundler_cert_path ⇒ Object
readonly
Returns the value of attribute bundler_cert_path.
-
#bundler_certs ⇒ Object
readonly
Returns the value of attribute bundler_certs.
-
#rubygems_certs ⇒ Object
readonly
Returns the value of attribute rubygems_certs.
Class Method Summary collapse
Instance Method Summary collapse
- #connect_to(host) ⇒ Object
-
#initialize(rubygems_path = nil) ⇒ CertificateManager
constructor
A new instance of CertificateManager.
- #up_to_date? ⇒ Boolean
- #update! ⇒ Object
Constructor Details
#initialize(rubygems_path = nil) ⇒ CertificateManager
Returns a new instance of CertificateManager.
14 15 16 17 18 19 20 21 22 |
# File 'lib/bundler/ssl_certs/certificate_manager.rb', line 14 def initialize(rubygems_path = nil) if rubygems_path rubygems_cert_path = File.join(rubygems_path, 'lib/rubygems/ssl_certs') @rubygems_certs = certificates_in(rubygems_cert_path) end @bundler_cert_path = File.("..", __FILE__) @bundler_certs = certificates_in(bundler_cert_path) end |
Instance Attribute Details
#bundler_cert_path ⇒ Object (readonly)
Returns the value of attribute bundler_cert_path.
8 9 10 |
# File 'lib/bundler/ssl_certs/certificate_manager.rb', line 8 def bundler_cert_path @bundler_cert_path end |
#bundler_certs ⇒ Object (readonly)
Returns the value of attribute bundler_certs.
8 9 10 |
# File 'lib/bundler/ssl_certs/certificate_manager.rb', line 8 def bundler_certs @bundler_certs end |
#rubygems_certs ⇒ Object (readonly)
Returns the value of attribute rubygems_certs.
8 9 10 |
# File 'lib/bundler/ssl_certs/certificate_manager.rb', line 8 def rubygems_certs @rubygems_certs end |
Class Method Details
.update_from!(rubygems_path) ⇒ Object
10 11 12 |
# File 'lib/bundler/ssl_certs/certificate_manager.rb', line 10 def self.update_from!(rubygems_path) new(rubygems_path).update! end |
Instance Method Details
#connect_to(host) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/bundler/ssl_certs/certificate_manager.rb', line 39 def connect_to(host) http = Net::HTTP.new(host, 443) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_PEER http.cert_store = store http.head('/') end |
#up_to_date? ⇒ Boolean
24 25 26 27 28 29 30 |
# File 'lib/bundler/ssl_certs/certificate_manager.rb', line 24 def up_to_date? rubygems_certs.all? do |rc| bundler_certs.find do |bc| File.basename(bc) == File.basename(rc) && FileUtils.compare_file(bc, rc) end end end |
#update! ⇒ Object
32 33 34 35 36 37 |
# File 'lib/bundler/ssl_certs/certificate_manager.rb', line 32 def update! return if up_to_date? FileUtils.rm bundler_certs FileUtils.cp rubygems_certs, bundler_cert_path end |