Module: Turbine::StandardCommands

Includes:
FileUtils
Included in:
Application
Defined in:
lib/turbine/commands/init.rb

Instance Method Summary collapse

Instance Method Details

#initObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/turbine/commands/init.rb', line 9

def init
  current_dir = File.dirname(__FILE__)

  mkdir_p(".turbine")
  mkdir_p(".turbine/log")
  mkdir_p(".turbine/commands")
  mkdir_p(".turbine/commands/custom")

  key  = params[:api_key] || ENV['TURBINE_API_KEY']
  url  = params[:arguments][0]
  project_name = params[:arguments][1] || "default"

  raise if key.nil?

  write_file("log/#{key}.json") { |f| f << [].to_json }


  write_file("config.rb") do |f|
    template    = File.read("#{current_dir}/../../../data/config.rb.erb")
    f << ERB.new(template).result(binding)
  end

  write_file("current_project") do |f|
    f << project_name
  end

  write_file("projects.json") do |f|
   f << { project_name => url }.to_json
  end

  update_standard_commands
  update_version
end