class Madness::Commands::Server
Public Instance Methods
run()
click to toggle source
# File lib/madness/commands/server.rb, line 25 def run override_config args build_toc if config.toc open_browser if config.open launch_server end
Private Instance Methods
build_toc()
click to toggle source
# File lib/madness/commands/server.rb, line 42 def build_toc say "g`▌` generating #{config.toc}" Madness::TableOfContents.new.build(config.toc) end
launch_server()
click to toggle source
# File lib/madness/commands/server.rb, line 34 def launch_server raise ConfigurationError, "Invalid path: #{config.path}" unless File.directory? config.path show_status Madness::Server.prepare Madness::Server.run! end
open_browser()
click to toggle source
# File lib/madness/commands/server.rb, line 47 def open_browser browser = Browser.new config.bind, config.port browser.open do |error| say "r`#{error}`" if error end end
override_config(args)
click to toggle source
# File lib/madness/commands/server.rb, line 54 def override_config(args) config.path = args['PATH'] if args['PATH'] config.port = args['--port'].to_i if args['--port'] config.bind = args['--bind'] if args['--bind'] config.auth = args['--auth'] if args['--auth'] config.auth_zone = args['--auth-zone'] if args['--auth-zone'] config.open = true if args['--open'] config.theme = File.expand_path(args['--theme'], config.path) if args['--theme'] end
show_status()
click to toggle source
# File lib/madness/commands/server.rb, line 64 def show_status say 'g`▌` starting server' say "g`▌ env` : #{Madness::Server.environment}" say "g`▌ listen` : #{config.bind}:#{config.port}" say "g`▌ path` : #{File.realpath(config.path)}" say "g`▌ config` : #{config.filename}" if config.file_exist? say "g`▌ theme` : #{config.theme}" if config.theme say '' end