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



67
68
69
# File 'lib/volt/cli.rb', line 67

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



61
62
63
64
65
# File 'lib/volt/cli.rb', line 61

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
50
51
52
# 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/.")
  else
    say("Current folder is not a Volt project", :red)
    return
  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: 3000)
  # end
end