Class: Rails

Inherits:
Thor
  • Object
show all
Includes:
GitConfig, Thor::Actions
Defined in:
lib/rails.rb

Overview

TODO abstract out the heroku stuff

Class Method Summary collapse

Instance Method Summary collapse

Methods included from GitConfig

#author, #email, #github_token, #github_user, #jenkins_password, #jenkins_server, #jenkins_user

Class Method Details

.source_rootObject



13
14
15
# File 'lib/rails.rb', line 13

def self.source_root
  File.join(File.dirname(__FILE__), '..', 'templates', 'rails')
end

Instance Method Details

#preflightObject



18
19
20
21
22
23
24
25
26
# File 'lib/rails.rb', line 18

def preflight
  # bit rough and ready, but no heroku api for querying
  # app namespace
  abort "#{name} is already taken on heroku" unless
    HTTParty.get("http://#{name}.heroku.com").code == 404

  # these will abort anyway.
  author && email
end

#setupObject



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/rails.rb', line 29

def setup

  guarded "git clone git://github.com/mwotton/railstemplate.git #{name}"
  guarded "rm #{name}/config/database.yml"
  template "database_yml.tt", "#{name}/config/database.yml"
  Dir.chdir name do
    system "git remote rm origin 2>/dev/null >/dev/null" # hide the evidence
    guarded "heroku create #{name}"
    File.open("runtests.sh", "w") do |f|
      f.write "bundle exec rspec spec"
    end
  end
end