Class: Nanoc::CLI::Commands::AutoCompile
- Inherits:
-
Nanoc::CLI::CommandRunner
- Object
- Cri::CommandRunner
- Nanoc::CLI::CommandRunner
- Nanoc::CLI::Commands::AutoCompile
- Defined in:
- lib/nanoc/cli/commands/autocompile.rb
Instance Method Summary (collapse)
Methods inherited from Nanoc::CLI::CommandRunner
#call, call, #debug?, #is_in_site_dir?, #load_site, #require_site, #site
Instance Method Details
- (Object) run
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 67 |
# File 'lib/nanoc/cli/commands/autocompile.rb', line 30 def run warn 'WARNING: The `autocompile` command is deprecated. Please consider using `guard-nanoc` instead (see https://github.com/nanoc/guard-nanoc).' require 'rack' # Make sure we are in a nanoc site directory require_site autocompile_config = site.config[:autocompile] || {} # Set options = { :Port => ([:port] || autocompile_config[:port] || 3000).to_i, :Host => ([:host] || autocompile_config[:host] || '0.0.0.0') } # Guess which handler we should use handler_option = [:handler] || autocompile_config[:handler] handler = Rack::Handler.get(handler_option) unless handler begin handler = Rack::Handler::Mongrel rescue LoadError handler = Rack::Handler::WEBrick end end # Build app autocompiler = Nanoc::Extra::AutoCompiler.new('.') app = Rack::Builder.new do use Rack::CommonLogger, $stderr use Rack::ShowExceptions run autocompiler end.to_app # Run autocompiler puts "Running on http://#{[:Host]}:#{[:Port]}/" handler.run(app, ) end |