Class: SmallCage::Commands::Auto
- Defined in:
- lib/smallcage/commands/auto.rb
Overview
‘smc auto’ command
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(opts) ⇒ Auto
constructor
A new instance of Auto.
Methods inherited from Base
Constructor Details
#initialize(opts) ⇒ Auto
Returns a new instance of Auto.
6 7 8 9 10 11 12 |
# File 'lib/smallcage/commands/auto.rb', line 6 def initialize(opts) super(opts) @target = Pathname.new(opts[:path]) @port = opts[:port] @sleep = 1 @timestamps = {} end |
Instance Method Details
#execute ⇒ Object
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 |
# File 'lib/smallcage/commands/auto.rb', line 29 def execute require 'smallcage/http_server' start_http_server unless @port.nil? init_sig_handler @loader = SmallCage::Loader.new(@target) first_loop = true @update_loop = true while @update_loop if first_loop first_loop = false if @opts[:fast] puts 'Searching modified files since last update...' count, total = update_modified_files if total == 0 notify puts 'All files are updated. Redy to edit!' elsif total != count notify notify puts "Error (#{count}/#{total}) Redy to edit!" else notify puts "Updated (#{count}/#{total}) Redy to edit!" end puts_line else update_target notify puts_line end else count, total = update_modified_files if total > 0 if total == count notify else notify notify puts "Error (#{count} / #{total})" end puts_line end end sleep @sleep end end |