Sha256: 53c9486ef516451d00754881f36fc48bb8d3774bc80bacccef8015cbb00c16ac
Contents?: true
Size: 777 Bytes
Versions: 2
Compression:
Stored size: 777 Bytes
Contents
#!/usr/bin/env ruby require 'optparse' require 'webrick' options = {} OptionParser.new do |opts| opts.banner = "breakneck: a quick way to serve static html sites immediately" opts.on("--port [PORT]", "Start on a different port (default: 3333)") do |port| options[:port] = port.to_i end opts.on("--open", "Open in the default browser") do options[:open] = true end end.parse! options[:port] ||= 3333 options[:open] ||= false server = WEBrick::HTTPServer.new( :Port => options[:port], :DocumentRoot => Dir.pwd ) thread = Thread.new do server.start end if options[:open] host_string = "http://localhost:#{options[:port]}/" system("open #{host_string} || firefox #{host_string}") end trap("INT") do server.shutdown end thread.join
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
breakneck-1.1.0 | bin/breakneck |
breakneck-1.0.0 | bin/breakneck |