Class: CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/volt/cli.rb,
lib/volt/cli/asset_compile.rb
Class Method Summary collapse
Instance Method Summary collapse
- #component(name) ⇒ Object
- #console ⇒ Object
- #gem(name) ⇒ Object
- #model(name, component = 'main') ⇒ Object
- #new(name) ⇒ Object
- #precompile ⇒ Object
- #server ⇒ Object
- #watch ⇒ Object
Class Method Details
.source_root ⇒ Object
99 100 101 |
# File 'lib/volt/cli.rb', line 99 def self.source_root File.(File.join(File.dirname(__FILE__), '../../templates')) end |
Instance Method Details
#component(name) ⇒ Object
91 92 93 94 95 96 |
# File 'lib/volt/cli.rb', line 91 def component(name) name = name.underscore component_folder = Dir.pwd + "/app/#{name}" @component_name = name directory("component", component_folder, {component_name: name}) end |
#console ⇒ Object
19 20 21 22 |
# File 'lib/volt/cli.rb', line 19 def console require 'volt/console' Console.start end |
#gem(name) ⇒ Object
75 76 77 78 79 |
# File 'lib/volt/cli.rb', line 75 def gem(name) require 'volt/cli/new_gem' NewGem.new(self, name, ) end |
#model(name, component = 'main') ⇒ Object
84 85 86 87 |
# File 'lib/volt/cli.rb', line 84 def model(name, component='main') output_file = Dir.pwd + "/app/#{component.underscore}/models/#{name.underscore.singularize}.rb" template("model/model.rb.tt", output_file, {model_name: name.camelize.singularize}) end |
#new(name) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/volt/cli.rb', line 9 def new(name) # 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 |
#precompile ⇒ Object
4 5 6 |
# File 'lib/volt/cli/asset_compile.rb', line 4 def precompile compile end |
#server ⇒ Object
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/volt/cli.rb', line 26 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.exists?("config.ru") && File.exists?("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 [:port] args += ['-p', [:port].to_s] end Thin::Runner.new(args).run! end # require 'volt/server' # # EM.run do # thin = Rack::Handler.get("thin") # thin.run(Server.new.app, Port: 3000) # end end |
#watch ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/volt/cli/asset_compile.rb', line 9 def watch require 'listen' listener = Listen.to('app') do |modified, added, removed| compile end listener.start # non-blocking Signal.trap("SIGINT") do listener.stop end compile begin sleep rescue ThreadError => e # ignore, breaks out on sigint end end |