Class: Listen::Forwarder
- Inherits:
-
Object
- Object
- Listen::Forwarder
- Defined in:
- lib/listen/cli.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
-
#initialize(options) ⇒ Forwarder
constructor
A new instance of Forwarder.
- #start ⇒ Object
Constructor Details
#initialize(options) ⇒ Forwarder
Returns a new instance of Forwarder.
39 40 41 42 43 |
# File 'lib/listen/cli.rb', line 39 def initialize() @options = @logger = ::Logger.new(STDOUT, level: ::Logger::INFO) @logger.formatter = proc { |_, _, _, msg| "#{msg}\n" } end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
37 38 39 |
# File 'lib/listen/cli.rb', line 37 def logger @logger end |
Instance Method Details
#start ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/listen/cli.rb', line 45 def start logger.info 'Starting listen...' directory = @options[:directory] relative = @options[:relative] callback = proc do |modified, added, removed| if @options[:verbose] logger.info "+ #{added}" unless added.empty? logger.info "- #{removed}" unless removed.empty? logger.info "> #{modified}" unless modified.empty? end end listener = Listen.to(*directory, relative: relative, &callback) listener.start sleep 0.5 while listener.processing? end |