Class: Volt::CLI
- Includes:
- Thor::Actions, Bundle
- 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
- #console ⇒ Object
- #drop_collection(collection) ⇒ Object
- #new(name) ⇒ Object
- #precompile ⇒ Object
- #runner(file_path) ⇒ Object
- #server ⇒ Object
Methods included from Bundle
Class Method Details
.source_root ⇒ Object
172 173 174 |
# File 'lib/volt/cli.rb', line 172 def self.source_root File.(File.join(File.dirname(__FILE__), '../../templates')) end |
Instance Method Details
#console ⇒ Object
37 38 39 40 |
# File 'lib/volt/cli.rb', line 37 def console require 'volt/cli/console' Console.start end |
#drop_collection(collection) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/volt/cli.rb', line 109 def drop_collection(collection) ENV['SERVER'] = 'true' move_to_root require 'volt/boot' Volt.boot(Dir.pwd) db = Volt::DataStore.fetch drop = db.drop_collection(collection) say("Collection #{collection} could not be dropped", :red) if drop == false say("Collection #{collection} dropped", :green) if drop == true end |
#new(name) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/volt/cli.rb', line 22 def new(name) new_project(name) say "" say "Your app is now ready in the #{name} directory.", :green say "" say "To run your app: " say "" say " cd #{name}" say " bundle exec volt server" end |
#precompile ⇒ Object
5 6 7 8 |
# File 'lib/volt/cli/asset_compile.rb', line 5 def precompile move_to_root compile end |
#runner(file_path) ⇒ Object
99 100 101 102 103 104 105 |
# File 'lib/volt/cli.rb', line 99 def runner(file_path) ENV['SERVER'] = 'true' move_to_root require 'volt/cli/runner' Volt::CLI::Runner.run_file(file_path) end |
#server ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/volt/cli.rb', line 46 def server move_to_root if ENV['PROFILE_BOOT'] begin require 'ruby-prof' RubyProf.start rescue LoadError => e puts "To run volt in a profile mode, you must add ruby-prof gem to the app's Gemfile" end end require 'fileutils' require 'volt/server' require 'volt/utils/recursive_exists' # 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 RecursiveExists.exists_here_or_up?('config.ru') && RecursiveExists.exists_here_or_up?('Gemfile') # FileUtils.rm_rf('tmp/sass') # FileUtils.rm_rf('tmp/sprockets') else say('Current folder is not a Volt project', :red) return end ENV['SERVER'] = 'true' app = Volt::Server.new.app server = Rack::Handler.get(RUNNING_SERVER) opts = {} opts[:Port] = [:port] || 3000 opts[:Host] = [:bind] if [:bind] server.run(app, opts) do |server| case RUNNING_SERVER when 'thin' server.maximum_persistent_connections = 300 server.maximum_connections = 500 unless Gem.win_platform? server.threaded = true # We need to disable the timeout on thin, otherwise it will keep # disconnecting the websockets. server.timeout = 0 end end end |