Class: SmallCage::Commands::Auto

Inherits:
Base
  • Object
show all
Defined in:
lib/smallcage/commands/auto.rb

Overview

‘smc auto’ command

Instance Method Summary collapse

Methods inherited from Base

execute, #quiet?

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

#executeObject



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
# File 'lib/smallcage/commands/auto.rb', line 30

def execute
  puts_banner

  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]
        load_initial_timestamps
        update_modified_files
      else
        update_target
      end
    else
      update_modified_files
    end
    sleep @sleep
  end
end