Created
February 16, 2015 06:33
-
-
Save ToadJamb/09b6d575f1745ff55988 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| ### Bundle env | |
| # Bundler 1.6.2 | |
| # Ruby 2.1.2 (2014-05-08 patchlevel 95) [x86_64-linux] | |
| # Rubygems 2.2.2 | |
| # rvm 1.26.10 (latest) | |
| # GEM_HOME /home/toadjamb/.rvm/gems/ruby-2.1.2 | |
| # GEM_PATH /home/toadjamb/.rvm/gems/ruby-2.1.2:/home/toadjamb/.rvm/gems/ruby-2.1.2@global | |
| # | |
| # | |
| # Gemfile | |
| # source 'https://www.rubygems.org' | |
| # gemspec | |
| # | |
| # | |
| # Gemfile.lock | |
| # PATH | |
| # remote: . | |
| # specs: | |
| # cert_sample (0.0.0) | |
| # | |
| # GEM | |
| # remote: https://www.rubygems.org/ | |
| # specs: | |
| # | |
| # PLATFORMS | |
| # ruby | |
| # | |
| # DEPENDENCIES | |
| # cert_sample! | |
| require 'rubygems/security' | |
| GEMSPEC = " | |
| Gem::Specification.new do |spec| | |
| spec.name = 'cert_sample' | |
| spec.version = '0.0.0' | |
| spec.authors << 'me' | |
| spec.email = 'me@example.com' | |
| spec.homepage = 'http://www.example.com' | |
| spec.license = 'MIT' | |
| spec.summary = 'Cert Signing on bundle install' | |
| spec.description = 'Cert Sign Example' | |
| end | |
| ".strip | |
| GEMFILE = " | |
| source 'https://www.rubygems.org' | |
| gemspec | |
| ".strip | |
| def home | |
| File.expand_path '~' | |
| end | |
| def gem_path | |
| File.join home, '.gem' | |
| end | |
| def private_key | |
| File.join gem_path, 'gem-private_key.pem' | |
| end | |
| def public_key | |
| File.join gem_path, 'gem-public_cert.pem' | |
| end | |
| if File.exists?(private_key) or File.exists?(public_key) | |
| puts 'WARNING"!!!!' | |
| puts "#{private_key}\nand/or\n#{public_key}\nalready exist." | |
| puts 'This script will overwrite them.' | |
| puts 'Please put them in a safe place ' + | |
| 'until you are done playing with dangerous toys.' | |
| exit | |
| end | |
| ################################################################################ | |
| puts 'You must specify a password now to create a cert.' | |
| puts 'Passwords must be a minimum of four characters.' | |
| system 'gem cert --build me@example.com' | |
| FileUtils.mkdir_p File.join(home, '.gem') | |
| FileUtils.mv 'gem-private_key.pem', private_key | |
| FileUtils.mv 'gem-public_cert.pem', public_key | |
| File.write 'Gemfile', GEMFILE | |
| File.write 'cert_sample.gemspec', GEMSPEC | |
| puts 'Running `bundle install` - you should be prompted for your password here.' | |
| system 'bundle install' | |
| puts 'Done! You should have been prompted for your password ' + | |
| 'after running `bundle install`' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment