Class: Bundler::SSLCerts::CertificateManager

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/ssl_certs/certificate_manager.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rubygems_path) ⇒ CertificateManager

Returns a new instance of CertificateManager.



12
13
14
15
16
17
18
# File 'lib/bundler/ssl_certs/certificate_manager.rb', line 12

def initialize(rubygems_path)
  rubygems_certs = File.join(rubygems_path, 'lib/rubygems/ssl_certs')
  @rubygems_certs = certificates_in(rubygems_certs)

  @bundler_cert_path = File.expand_path("..", __FILE__)
  @bundler_certs = certificates_in(bundler_cert_path)
end

Instance Attribute Details

#bundler_cert_pathObject (readonly)

Returns the value of attribute bundler_cert_path.



6
7
8
# File 'lib/bundler/ssl_certs/certificate_manager.rb', line 6

def bundler_cert_path
  @bundler_cert_path
end

#bundler_certsObject (readonly)

Returns the value of attribute bundler_certs.



6
7
8
# File 'lib/bundler/ssl_certs/certificate_manager.rb', line 6

def bundler_certs
  @bundler_certs
end

#rubygems_certsObject (readonly)

Returns the value of attribute rubygems_certs.



6
7
8
# File 'lib/bundler/ssl_certs/certificate_manager.rb', line 6

def rubygems_certs
  @rubygems_certs
end

Class Method Details

.update_from!(rubygems_path) ⇒ Object



8
9
10
# File 'lib/bundler/ssl_certs/certificate_manager.rb', line 8

def self.update_from!(rubygems_path)
  new(rubygems_path).update!
end

Instance Method Details

#up_to_date?Boolean

Returns:

  • (Boolean)


20
21
22
23
24
# File 'lib/bundler/ssl_certs/certificate_manager.rb', line 20

def up_to_date?
  bundler_certs.zip(rubygems_certs).all? do |bc, rc|
    File.basename(bc) == File.basename(rc) && FileUtils.compare_file(bc, rc)
  end
end

#update!Object



26
27
28
29
30
31
# File 'lib/bundler/ssl_certs/certificate_manager.rb', line 26

def update!
  return if up_to_date?

  FileUtils.rm bundler_certs
  FileUtils.cp rubygems_certs, bundler_cert_path
end