aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Rakefile6
-rw-r--r--lib/bundler/ssl_certs/certificate_manager.rb54
-rw-r--r--spec/other/ssl_cert_spec.rb8
3 files changed, 36 insertions, 32 deletions
diff --git a/Rakefile b/Rakefile
index 0d469613..b4c2b6b9 100644
--- a/Rakefile
+++ b/Rakefile
@@ -4,7 +4,7 @@ require 'rubygems'
require 'shellwords'
require 'benchmark'
-RUBYGEMS_REPO = "tmp/rubygems"
+RUBYGEMS_REPO = File.expand_path("tmp/rubygems")
def safe_task(&block)
yield
@@ -146,7 +146,7 @@ begin
desc "Run the tests on Travis CI against a rubygem version (using ENV['RGV'])"
task :travis do
- rg = ENV['RGV'] || 'v1.8.24'
+ rg = ENV['RGV'] || raise("Rubygems version is required on Travis!")
puts "\n\e[1;33m[Travis CI] Running bundler specs against rubygems #{rg}\e[m\n\n"
specs = safe_task { Rake::Task["spec:rubygems:#{rg}"].invoke }
@@ -223,7 +223,7 @@ end
desc "Update vendored SSL certs to match the certs vendored by Rubygems"
task :update_certs => "spec:rubygems:clone_rubygems_master" do
require 'bundler/ssl_certs/certificate_manager'
- CertificateManager.update_from!(RUBYGEMS_REPO)
+ Bundler::SSLCerts::CertificateManager.update_from!(RUBYGEMS_REPO)
end
require 'bundler/gem_tasks'
diff --git a/lib/bundler/ssl_certs/certificate_manager.rb b/lib/bundler/ssl_certs/certificate_manager.rb
index d17e928c..dea184dd 100644
--- a/lib/bundler/ssl_certs/certificate_manager.rb
+++ b/lib/bundler/ssl_certs/certificate_manager.rb
@@ -1,39 +1,41 @@
require 'fileutils'
-class CertificateManager
- attr_reader :bundler_cert_path, :bundler_certs, :rubygems_certs
+module Bundler
+ module SSLCerts
+ class CertificateManager
+ attr_reader :bundler_cert_path, :bundler_certs, :rubygems_certs
- def self.update_from!(rubygems_path)
- new(rubygems_path).update!
- end
+ def self.update_from!(rubygems_path)
+ new(rubygems_path).update!
+ end
- def initialize(rubygems_path)
- rubygems_certs = File.join(rubygems_path, 'lib/rubygems/ssl_certs')
- @rubygems_certs = certificates_in(rubygems_certs)
+ 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
+ @bundler_cert_path = File.expand_path("..", __FILE__)
+ @bundler_certs = certificates_in(bundler_cert_path)
+ end
- def up_to_date?
- return false if bundler_certs != rubygems_certs
+ 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
- bundler_certs.zip(rubygems_certs).all? do |bc, rc|
- FileUtils.compare_file(bc, rc)
- end
- end
+ def update!
+ return if up_to_date?
- def update!
- return if up_to_date?
+ FileUtils.rm bundler_certs
+ FileUtils.cp rubygems_certs, bundler_cert_path
+ end
- FileUtils.rm bundler_certs
- FileUtils.cp rubygems_certs, bundler_cert_path
- end
+ private
-private
+ def certificates_in(path)
+ Dir[File.join(path, "*.pem")].sort
+ end
- def certificates_in(path)
- Dir[File.join(path, "*.pem")].sort
+ end
end
-
end
diff --git a/spec/other/ssl_cert_spec.rb b/spec/other/ssl_cert_spec.rb
index 14b5af20..ac9283a2 100644
--- a/spec/other/ssl_cert_spec.rb
+++ b/spec/other/ssl_cert_spec.rb
@@ -1,8 +1,10 @@
-require_relative '../../lib/bundler/ssl_certs/certificate_manager'
+require 'spec_helper'
+require 'bundler/ssl_certs/certificate_manager'
-describe "SSL Certificates" do
+describe "SSL Certificates", :if => (ENV['RGV'] == "master") do
it "are up to date with Rubygems" do
- manager = CertificateManager.new
+ rubygems = File.expand_path("../../../tmp/rubygems", __FILE__)
+ manager = Bundler::SSLCerts::CertificateManager.new(rubygems)
expect(manager).to be_up_to_date
end
end