Class: Volt::CLI

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

Defined Under Namespace

Classes: Runner

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



93
94
95
# File 'lib/volt/cli.rb', line 93

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

Instance Method Details

#consoleObject



27
28
29
30
# File 'lib/volt/cli.rb', line 27

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

#gem(name) ⇒ Object



87
88
89
90
91
# File 'lib/volt/cli.rb', line 87

def gem(name)
  require 'volt/cli/new_gem'

  NewGem.new(self, name, options)
end

#new(name) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/volt/cli.rb', line 14

def new(name)
  require 'securerandom'

  # Grab the current volt version
  version = File.read(File.join(File.dirname(__FILE__), '../../VERSION'))
  directory('project', name, version: version, name: name)

  say 'Bundling Gems....'
  `cd #{name} && bundle`
end

#precompileObject



5
6
7
# File 'lib/volt/cli/asset_compile.rb', line 5

def precompile
  compile
end

#runner(file_path) ⇒ Object



72
73
74
75
76
77
# File 'lib/volt/cli.rb', line 72

def runner(file_path)
  ENV['SERVER'] = 'true'
  require 'volt/cli/runner'

  Volt::CLI::Runner.run_file(file_path)
end

#serverObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/volt/cli.rb', line 35

def server
  if RUBY_PLATFORM == 'java'
    require 'volt/server'
  else
    require 'thin'
  end

  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.exist?('config.ru') && File.exist?('Gemfile')
    FileUtils.rm_rf('tmp/.')
  else
    say('Current folder is not a Volt project', :red)
    return
  end

  if RUBY_PLATFORM == 'java'
    server = Server.new.app
    Rack::Handler::Jubilee.run(server)
    Thread.stop
  else
    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!
  end
end