Class: Hawkins::Commands::LiveServe
- Inherits:
-
Jekyll::Command
- Object
- Jekyll::Command
- Hawkins::Commands::LiveServe
- Defined in:
- lib/hawkins/servlet.rb,
lib/hawkins/liveserve.rb
Defined Under Namespace
Classes: BodyProcessor, ReloadServlet, SkipAnalyzer
Constant Summary collapse
- COMMAND_OPTIONS =
{ "swf" => ["--swf", "Use Flash for WebSockets support"], "ignore" => ["--ignore GLOB1[,GLOB2[,...]]", "Files not to reload"], "min_delay" => ["--min-delay [SECONDS]", "Minimum reload delay"], "max_delay" => ["--max-delay [SECONDS]", "Maximum reload delay"], "reload_port" => ["--reload-port [PORT]", Integer, "Port for LiveReload to listen on"], }.merge(Jekyll::Commands::Serve.singleton_class::COMMAND_OPTIONS).freeze
- LIVERELOAD_PORT =
35729
Class Attribute Summary collapse
-
.is_running ⇒ Object
readonly
Returns the value of attribute is_running.
-
.mutex ⇒ Object
readonly
Returns the value of attribute mutex.
-
.running_cond ⇒ Object
readonly
Returns the value of attribute running_cond.
Class Method Summary collapse
Class Attribute Details
.is_running ⇒ Object (readonly)
Returns the value of attribute is_running.
23 24 25 |
# File 'lib/hawkins/liveserve.rb', line 23 def is_running @is_running end |
.mutex ⇒ Object (readonly)
Returns the value of attribute mutex.
23 24 25 |
# File 'lib/hawkins/liveserve.rb', line 23 def mutex @mutex end |
.running_cond ⇒ Object (readonly)
Returns the value of attribute running_cond.
23 24 25 |
# File 'lib/hawkins/liveserve.rb', line 23 def running_cond @running_cond end |
Class Method Details
.init_with_program(prog) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/hawkins/liveserve.rb', line 27 def init_with_program(prog) prog.command(:liveserve) do |cmd| cmd.description "Serve your site locally with LiveReload" cmd.syntax "liveserve [options]" cmd.alias :liveserver cmd.alias :l (cmd) COMMAND_OPTIONS.each do |key, val| cmd.option(key, *val) end cmd.action do |_, opts| opts["reload_port"] ||= LIVERELOAD_PORT opts["serving"] = true opts["watch"] = true unless opts.key?("watch") start(opts) end end end |
.process(opts) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/hawkins/liveserve.rb', line 57 def process(opts) opts = (opts) destination = opts["destination"] setup(destination) @reload_reactor.start(opts) @server = WEBrick::HTTPServer.new(webrick_opts(opts)).tap { |o| o.unmount("") } @server.mount("#{opts['baseurl']}/__livereload", WEBrick::HTTPServlet::FileHandler, LIVERELOAD_DIR) @server.mount(opts["baseurl"], ReloadServlet, destination, file_handler_opts) Jekyll.logger.info "Server address:", server_address(@server, opts) launch_browser(@server, opts) if opts["open_url"] boot_or_detach(@server, opts) end |
.shutdown ⇒ Object
74 75 76 |
# File 'lib/hawkins/liveserve.rb', line 74 def shutdown @server.shutdown if @is_running end |