Sha256: ef6597e3ec6c88dfd64358610d3f49a44b2cb410af60b612c8aaa98436a7d9ab
Contents?: true
Size: 1.37 KB
Versions: 3
Compression:
Stored size: 1.37 KB
Contents
class FireflyServer class Configuration attr_reader(*%w[ exit_signals watch_paths ignore_paths file_change_callbacks ]) attr_accessor(*%w[ start_server stop_server pid_file restart_attempt_throttle_threshold restart_attempt_throttle_sleep ]) 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 %w[ exit_signals watch_paths ignore_paths file_change_callbacks ].each do |accessor| define_method("#{accessor}=") { |values| instance_variable_set("@#{accessor}", Array(values)) } end def on_change(&block) file_change_callbacks << block if block self end 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 end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
firefly_server-0.1.5 | lib/firefly_server/configuration.rb |
firefly_server-0.1.4 | lib/firefly_server/configuration.rb |
firefly_server-0.1.3 | lib/firefly_server/configuration.rb |