Class: Helproku::Generators::InitGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/helproku.rb

Instance Method Summary collapse

Instance Method Details

#get_github_usernameObject



44
45
46
47
# File 'lib/helproku.rb', line 44

def get_github_username
  @gituser = ask "Enter your Github username:"
  @project = Rails.application.class.parent_name.downcase
end

#include_common_gemsObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/helproku.rb', line 15

def include_common_gems
  gem_group :development do
    gem 'better_errors'
    gem 'binding_of_caller'
    gem 'sqlite3'
  end
  
  gem_group :development, :test do
    gem "rspec-rails"
  end

  gem_group :production do
    gem 'pg'
  end
end

#set_versionObject



31
32
33
34
35
36
# File 'lib/helproku.rb', line 31

def set_version
  append_to_file "Gemfile", "ruby '1.9.3'", after: "source 'https://rubygems.org'\n"
  inside Rails.root do
    run "bundle install"
  end
end

#setup_databasesObject



8
9
10
11
12
13
# File 'lib/helproku.rb', line 8

def setup_databases
  comment_lines "Gemfile", /sqlite3/
  gsub_file "config/database.yml", 
  /adapter: sqlite3\n\s+database: db\/production.sqlite3/, 
  "adapter: postgresql\n  database: db/production"
end

#setup_gitObject



38
39
40
41
42
# File 'lib/helproku.rb', line 38

def setup_git
  git :init
  git add: "."
  git commit: "-am 'Pretty awesome first commit!'"
end

#setup_herokuObject



55
56
57
58
59
60
# File 'lib/helproku.rb', line 55

def setup_heroku
  inside Rails.root do
    run "heroku create"
  end
  git push: "heroku master"
end

#upload_gitObject



49
50
51
52
53
# File 'lib/helproku.rb', line 49

def upload_git
  run "curl -u '#{@gituser}' https://api.github.com/user/repos -d '{\"name\" : \"#{@project}\"}' "
  git remote: "add origin [email protected]:#{@gituser}/#{@project}.git"
  git push: "-u origin master"
end