Class: Nanoc3::CLI::Commands::View
- Inherits:
-
Cri::Command
- Object
- Cri::Command
- Nanoc3::CLI::Commands::View
- Defined in:
- lib/nanoc3/cli/commands/view.rb
Instance Method Summary (collapse)
- - (Object) aliases
- - (Object) long_desc
- - (Object) name
- - (Object) option_definitions
- - (Object) run(options, arguments)
- - (Object) short_desc
- - (Object) usage
Instance Method Details
- (Object) aliases
11 12 13 |
# File 'lib/nanoc3/cli/commands/view.rb', line 11 def aliases [] end |
- (Object) long_desc
19 20 21 |
# File 'lib/nanoc3/cli/commands/view.rb', line 19 def long_desc 'Start the static web server. Unless specified, the web server will run on port 3000 and listen on all IP addresses. Running the autocompiler requires \'adsf\' and \'rack\'.' end |
- (Object) name
7 8 9 |
# File 'lib/nanoc3/cli/commands/view.rb', line 7 def name 'view' end |
- (Object) option_definitions
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/nanoc3/cli/commands/view.rb', line 27 def option_definitions [ # --handler { :long => 'handler', :short => 'H', :argument => :required, :desc => 'specify the handler to use (webrick/mongrel/...)' }, # --host { :long => 'host', :short => 'o', :argument => :required, :desc => 'specify the host to listen on (default: 0.0.0.0)' }, # --port { :long => 'port', :short => 'p', :argument => :required, :desc => 'specify the port to listen on (default: 3000)' } ] end |
- (Object) run(options, arguments)
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 |
# File 'lib/nanoc3/cli/commands/view.rb', line 47 def run(, arguments) require 'rack' require 'adsf' # Make sure we are in a nanoc site directory @base.require_site # Set options = { :Port => ([:port] || 3000).to_i, :Host => ([:host] || '0.0.0.0') } # Guess which handler we should use unless handler = Rack::Handler.get([:handler]) begin handler = Rack::Handler::Mongrel rescue LoadError => e handler = Rack::Handler::WEBrick end end # Build app site = @base.site app = Rack::Builder.new do use Rack::CommonLogger use Rack::ShowExceptions use Rack::Lint use Rack::Head use Adsf::Rack::IndexFileFinder, :root => site.config[:output_dir] run Rack::File.new(site.config[:output_dir]) end.to_app # Run autocompiler handler.run(app, ) end |
- (Object) short_desc
15 16 17 |
# File 'lib/nanoc3/cli/commands/view.rb', line 15 def short_desc 'start the web server that serves static files' end |
- (Object) usage
23 24 25 |
# File 'lib/nanoc3/cli/commands/view.rb', line 23 def usage "nanoc3 view [options]" end |