Class: Nimbu::Command::Server
- Includes:
- Term::ANSIColor
- Defined in:
- lib/nimbu/command/server.rb
Overview
running a local server to speed up designing Nimbu themes
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#index ⇒ Object
server.
Methods inherited from Base
#app, #initialize, namespace, #nimbu
Methods included from Helpers
#action, #ask, #confirm, #confirm_billing, #confirm_command, #create_git_remote, #deprecate, disable_error_capture, #display, #display_header, #display_object, #display_row, #display_table, enable_error_capture, #error, #error_with_failure, extended, extended_into, #fail, #format_bytes, #format_date, #format_with_bang, #get_terminal_environment, #git, #has_git?, #home_directory, #hprint, #hputs, included, included_into, #json_decode, #json_encode, #longest, #output, #output_with_arrow, #output_with_bang, #quantify, #redisplay, #retry_on_exception, #run_command, #running_on_a_mac?, #running_on_windows?, #set_buffer, #shell, #status, #string_distance, #time_ago, #truncate, #with_tty
Constructor Details
This class inherits a constructor from Nimbu::Command::Base
Instance Method Details
#index ⇒ Object
server
list available commands or display help for a specific command
16 17 18 19 20 21 22 23 24 25 26 27 28 29 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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/nimbu/command/server.rb', line 16 def index # Check if config file is present? if !Nimbu::Auth.read_configuration || !Nimbu::Auth.read_credentials print red(bold("ERROR")), ": this directory does not seem to contain any Nimbu theme or your credentials are not set. \n ==> Run \"", bold { "nimbu init"}, "\" to initialize this directory." else no_haml = args.include?("--no-haml") no_compass = args.include?("--no-compass") if !(File.exists?(File.join(Dir.pwd,'haml')) && File.directory?(File.join(Dir.pwd,'haml'))) no_haml = true puts red("\n !! WARNING: no ./haml directory detected => starting without HAML support !!") end puts white("\nStarting up Nimbu Server" + (no_compass ? "" : " + Compass Watcher") + (no_haml ? "" : " + HAML Compiler") + "...") puts green( " _ ___ __ \n" + " / | / (_)____ ___ / /_ __ __\n" + " / |/ / // __ `__ \\/ __ \\/ / / /\n" + " / /| / // / / / / / /_/ / /_/ / \n" + " /_/ |_/_//_/ /_/ /_/_.___/\\__,_/ \n") rd1, wr1 = IO::pipe rd2, wr2 = IO::pipe rd3, wr3 = IO::pipe server_pid = Process.fork do $stdout.reopen(wr1) rd1.close puts "Starting..." = { :Port => 4567, :DocumentRoot => Dir.pwd } Rack::Handler::Thin.run Nimbu::Server::Base, do |server| [:INT, :TERM].each { |sig| trap(sig) { server.respond_to?(:stop!) ? server.stop! : server.stop } } end end haml_pid = Process.fork do $stdout.reopen(wr2) rd2.close puts "Starting..." HamlWatcher.watch end unless no_haml compass_pid = Process.fork do $stdout.reopen(wr3) rd3.close puts "Starting..." Compass::Exec::SubCommandUI.new(["watch","."]).run! end unless no_compass watch_server_pid = Process.fork do trap('INT') { exit } wr1.close rd1.each do |line| print cyan("SERVER: ") + white(line) + "" end end watch_haml_pid = Process.fork do trap('INT') { exit } wr2.close rd2.each do |line| print magenta("HAML: ") + white(line) + "" end end unless no_haml watch_compass_pid = Process.fork do trap('INT') { exit } wr3.close rd3.each do |line| print yellow("COMPASS: ") + white(line) + "" end end unless no_compass [:INT, :TERM].each do |sig| trap(sig) do puts yellow("\n== Waiting for all processes to finish...") Process.waitall puts green("== Nimbu has ended its work " + bold("(crowd applauds!)\n")) end end Process.waitall end end |