Class: Henry::Bootstrap
- Inherits:
-
Object
- Object
- Henry::Bootstrap
- Defined in:
- lib/henry/bootstrap.rb
Instance Method Summary collapse
- #add_henry ⇒ Object
- #create_project ⇒ Object
- #encrypt_api_key ⇒ Object
-
#initialize(shell = Thor.new) ⇒ Bootstrap
constructor
A new instance of Bootstrap.
- #perform ⇒ Object
- #setup_deployment ⇒ Object
- #travis ⇒ Object
Constructor Details
#initialize(shell = Thor.new) ⇒ Bootstrap
Returns a new instance of Bootstrap.
4 5 6 |
# File 'lib/henry/bootstrap.rb', line 4 def initialize(shell = Thor.new) @shell = shell end |
Instance Method Details
#add_henry ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/henry/bootstrap.rb', line 35 def add_henry @shell.say('Adding Henry to your .travis.yml', :green) t = travis t['after_success'] ||= [] t['after_success'] << 'gem install henry' t['after_success'] << 'henry deploy' File.open('.travis.yml', 'w+') do |f| f.write(t.to_yaml) end end |
#create_project ⇒ Object
15 16 17 18 19 20 |
# File 'lib/henry/bootstrap.rb', line 15 def create_project return if File.exist?('.travis.yml') @shell.say("Your project doesn't seem to have a `.travis.yml` - creating one now", :green) version = @shell.ask('What version of Ruby do you want to test against? |2.1.4|') system "travis init ruby --rvm #{version.empty? ? '2.1.4' : version}" end |
#encrypt_api_key ⇒ Object
29 30 31 32 33 |
# File 'lib/henry/bootstrap.rb', line 29 def encrypt_api_key github_api_key = @shell.ask("Please enter your Github oauth token - visit https://github.com/settings/tokens/new?description=Henry%20Token to set one up if you haven't already") @shell.say('Encrypting your token and adding it to your .travis.yml', :green) `travis encrypt GITHUB_OUATH_TOKEN=#{github_api_key} --add` end |
#perform ⇒ Object
8 9 10 11 12 13 |
# File 'lib/henry/bootstrap.rb', line 8 def perform create_project setup_deployment encrypt_api_key add_henry end |
#setup_deployment ⇒ Object
22 23 24 25 26 27 |
# File 'lib/henry/bootstrap.rb', line 22 def setup_deployment if travis['deploy'].nil? @shell.say('Setting up deployment with Rubygems', :green) system "travis setup rubygems" end end |
#travis ⇒ Object
46 47 48 |
# File 'lib/henry/bootstrap.rb', line 46 def travis YAML.load_file('.travis.yml') end |