Class: CLI

Inherits:
Thor show all
Includes:
Thor::Actions
Defined in:
lib/volt/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



64
65
66
# File 'lib/volt/cli.rb', line 64

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

Instance Method Details

#consoleObject



16
17
18
19
# File 'lib/volt/cli.rb', line 16

def console
  require 'volt/console'
  Console.start
end

#gem(name) ⇒ Object



58
59
60
61
62
# File 'lib/volt/cli.rb', line 58

def gem(name)
  require 'volt/cli/new_gem'
  
  NewGem.new(self, name, options)
end

#new(name) ⇒ Object



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

def new(name)
  directory("project", name)
  
  say "Bundling Gems...."
  `cd #{name} ; bundle -j 4`
end

#serverObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/volt/cli.rb', line 23

def server
  require 'thin'
  require 'fileutils'

  # If we're in a Volt project, clear the temp directory
  # TODO: this is a work around for a bug when switching between
  # source maps and non-source maps.
  if File.exists?("config.ru") && File.exists?("Gemfile")
    FileUtils.rm_rf("tmp/.")
  end

  ENV['SERVER'] = 'true'
  args = ['start', '--threaded', '--max-persistent-conns', '300', "--max-conns", "400"]
  
  if options[:port]
    args += ['-p', options[:port].to_s]
  end
  
  Thin::Runner.new(args).run!
  
  # require 'volt/server'
  # 
  # EM.run do
  #   thin = Rack::Handler.get("thin")
  #   thin.run(Server.new.app, Port: 5000)
  # end
end