Class: Volt::CLI
- 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
- #console ⇒ Object
- #drop_collection(collection) ⇒ Object
- #new(name) ⇒ Object
- #precompile ⇒ Object
- #runner(file_path) ⇒ Object
- #server ⇒ Object
Class Method Details
.source_root ⇒ Object
108 109 110 |
# File 'lib/volt/cli.rb', line 108 def self.source_root File.(File.join(File.dirname(__FILE__), '../../templates')) end |
Instance Method Details
#console ⇒ Object
29 30 31 32 |
# File 'lib/volt/cli.rb', line 29 def console require 'volt/cli/console' Console.start end |
#drop_collection(collection) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/volt/cli.rb', line 89 def drop_collection(collection) ENV['SERVER'] = 'true' require 'mongo' require 'volt/boot' Volt.boot(Dir.pwd) host = Volt.config.db_host || 'localhost' port = Volt.config.db_port || Mongo::MongoClient::DEFAULT_PORT name = Volt.config.db_name say("Connecting to #{host}:#{port}", :yellow) db = Mongo::MongoClient.new(host, port).db(name) drop = db.drop_collection(collection) say("Collection #{collection} on #{name} couldn't be dropped", :red) if drop == false say("Collection #{collection} on #{name} dropped", :green) if drop == true end |
#new(name) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/volt/cli.rb', line 17 def new(name) require 'securerandom' # Grab the current volt version directory('project', name, version: Volt::Version::STRING, name: name, domain: name.dasherize.downcase, app_name: name.capitalize) say 'Bundling Gems...' `cd #{name} && bundle` end |
#precompile ⇒ Object
5 6 7 |
# File 'lib/volt/cli/asset_compile.rb', line 5 def precompile compile end |
#runner(file_path) ⇒ Object
80 81 82 83 84 85 |
# File 'lib/volt/cli.rb', line 80 def runner(file_path) ENV['SERVER'] = 'true' require 'volt/cli/runner' Volt::CLI::Runner.run_file(file_path) end |
#server ⇒ Object
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 69 70 71 72 73 74 75 76 |
# File 'lib/volt/cli.rb', line 38 def server require 'fileutils' require 'volt/server' # 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/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 |