Class: G2::Cli

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/g2/cli.rb

Instance Method Summary collapse

Instance Method Details

#cObject



63
64
65
# File 'lib/g2/cli.rb', line 63

def c
  say "not implemented yet ):", :yellow
end

#gObject



68
69
70
# File 'lib/g2/cli.rb', line 68

def g
  say "not implemented yet ):", :yellow
end

#new(app_root) ⇒ Object



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
# File 'lib/g2/cli.rb', line 10

def new app_root
  say "create a new grape goliath application named #{app_root}", :green
  @app_name = app_root.capitalize

  # create folder structure
  %w{app app/apis app/helpers app/models config config/environments db script log tmp tmp/pids spec}.each do |item|
    empty_directory app_root + "/" + item
  end

  # create basic files
  {
    application: "config/application.rb",
    database: "config/database.yml",
    spec_helper: "spec/spec_helper.rb",
    gemfile: "Gemfile",
    guardfile: "Guardfile",
    rakefile: "Rakefile",
    rspec_config: ".rspec",
    server: "script/server.rb"
  }.each do |k, v|
    template("templates/#{k}.erb", "#{app_root}/#{v}")
  end

  inside app_root do
    run "bundle install"
  end
end

#sObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/g2/cli.rb', line 44

def s
  command = "ruby script/server.rb -p #{options[:port] || 3030} -e #{options[:environment] || 'development'}"

  if options[:log]
    command += " -l #{options[:log]}"
  else
    command += " -s"
  end
  if options[:pid]
    command += " -P #{options[:pid]}"
  end
  if options[:daemon]
    command += " -d"
  end

  exec command
end