Class: Locomotive::Cmd::Installer

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/locomotive_cmd/installer.rb

Instance Method Summary collapse

Instance Method Details

#ask_user_if_heroku_and_the_restObject

HEROKU PART ####



65
66
67
68
69
70
# File 'lib/locomotive_cmd/installer.rb', line 65

def ask_user_if_heroku_and_the_rest
  @opts.heroku = yes?("Deploy to heroku?", :yellow)
  if @opts.heroku
    get_options_from_user_for_heroku
  end
end

#create_rails_appObject



32
33
34
35
36
37
# File 'lib/locomotive_cmd/installer.rb', line 32

def create_rails_app
  say :create, @app_path if @opts.verbose
  rails_cmd = "rails new #{@app_path} --skip-active-record --skip-test-unit --skip-javascript --skip-bundle"
  run_silently rails_cmd
  say 'Create Rails app: Done', :green
end

#generate_options_hashObject



25
26
27
28
29
30
# File 'lib/locomotive_cmd/installer.rb', line 25

def generate_options_hash
  @opts = OpenStruct.new
  @opts.version = options[:version]
  @opts.verbose = options[:verbose]
  @opts.app_name = options[:app_name]
end

#herokuObject



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/locomotive_cmd/installer.rb', line 72

def heroku
  if @opts.heroku
    insert_ruby_version_in_gemfile
    install_bundler_pre
    set_gems_for_heroku
    bundle_install
    configure_locomotive_for_heroku
    edit_locomotive_config_file
    precompiling_assets
  end
end

#initialize_locomotiveObject



53
54
55
56
57
58
59
# File 'lib/locomotive_cmd/installer.rb', line 53

def initialize_locomotive
  say_status :locomotive, :initialize if @opts.verbose
  inside @app_path do
    run_silently "rails generate locomotive:install"
  end
  say 'Adding Locomotive: Done', :green
end

#multi_siteObject

MULTI SITE PART ###



88
89
90
91
92
93
94
95
96
# File 'lib/locomotive_cmd/installer.rb', line 88

def multi_site
  @opts.multi_site = yes?('Will you use the multi-site feature?', :yellow)
  if @opts.multi_site
    @opts.domain_name = ask('What is your base domain name for the multi sites?', :yellow)
    set_domain_name_in_locomotive
    add_domains_to_heroku_if_needed
    say "Don't forget for local dev to edit /ect/hosts or use Pow according to : http://doc.locomotivecms.com/guides/multisites", :green
  end
end

#replace_gemfileObject



39
40
41
42
43
44
45
# File 'lib/locomotive_cmd/installer.rb', line 39

def replace_gemfile
  inside @app_path do
    remove_file 'Gemfile', verbose: @opts.verbose
  end
  gemfile = 'Gemfile'
  template 'Gemfile', "#{@app_path}/Gemfile", verbose: @opts.verbose
end

#send_to_herokuObject

PUSH TO HEROKU ###



102
103
104
105
106
# File 'lib/locomotive_cmd/installer.rb', line 102

def send_to_heroku
  if @opts.heroku
    launch_it
  end
end

#set_gemsObject



48
49
50
51
# File 'lib/locomotive_cmd/installer.rb', line 48

def set_gems
  set_gems_from_config_group 'gems'
  bundle_install
end

#show_readmeObject



108
109
110
# File 'lib/locomotive_cmd/installer.rb', line 108

def show_readme
  puts File.read(find_in_source_paths('README')) unless @opts.verbose
end

#verify_railsObject



18
19
20
21
22
23
# File 'lib/locomotive_cmd/installer.rb', line 18

def verify_rails
  if existing_project?
    say "#{@app_path} exists already"
    exit 1
  end
end