class FireflyServer::Configuration

Public Class Methods

new(params = {}) click to toggle source
# File lib/firefly_server/configuration.rb, line 17
def initialize(params = {})
  # defaults
  self.restart_attempt_throttle_threshold = 3
  self.restart_attempt_throttle_sleep = 3
  self.exit_signals = %w[ SIGINT ]
  # watcher defaults
  self.watch_paths = []
  self.ignore_paths = []
  self.file_change_callbacks = []
  # override defaults
  params.each do |key, value|
    send("#{key}=", value)
  end
end

Public Instance Methods

on_change(&block) click to toggle source
# File lib/firefly_server/configuration.rb, line 36
def on_change(&block)
  file_change_callbacks << block if block
  self
end
validate!() click to toggle source
# File lib/firefly_server/configuration.rb, line 41
def validate!
  # validate require options set
  %w[ start_server stop_server pid_file ].each do |attribute|
    if !send(attribute)
      raise(ArgumentError, "#{attribute} option must be provided")
    end
  end
  if watch_paths.empty?
    raise(ArgumentError, "watch_paths option must be provided")
  end
  self
end