Class: Epi::Daemon::Responders::Config

Inherits:
Epi::Daemon::Responder show all
Defined in:
lib/epi/daemon/responders/config.rb

Instance Attribute Summary collapse

Attributes inherited from Epi::Daemon::Responder

#receiver

Instance Method Summary collapse

Methods inherited from Epi::Daemon::Responder

#done, #initialize, #logger, #puts, run

Constructor Details

This class inherits a constructor from Epi::Daemon::Responder

Instance Attribute Details

#add_pathsObject

Returns the value of attribute add_paths.



6
7
8
# File 'lib/epi/daemon/responders/config.rb', line 6

def add_paths
  @add_paths
end

#remove_pathsObject

Returns the value of attribute remove_paths.



6
7
8
# File 'lib/epi/daemon/responders/config.rb', line 6

def remove_paths
  @remove_paths
end

Instance Method Details

#runObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/epi/daemon/responders/config.rb', line 8

def run
  result = []
  configs = Data.configuration_paths
  add_paths.each do |path|
    path = path.to_s
    if configs.include?(path)
      logger.warn "Tried to re-add config path: #{path}"
      result << "Config path already loaded: #{path}"
    else
      logger.info "Adding config path: #{path}"
      configs << path
      result << "Added config path: #{path}"
    end
  end if add_paths
  remove_paths.each do |path|
    path = path.to_s
    if configs.include?(path)
      logger.info "Removing config path: #{path}"
      # TODO: clean up any junk the config file may have left
      configs.delete path
      result << "Removed config path: #{path}"
    else
      logger.warn "Tried to remove unknown config path: #{path}"
      result << "Config path not loaded: #{path}"
    end
  end if remove_paths
  Data.save
  Jobs.beat!
  result.join ' '
end