Class: Xify

Inherits:
Object
  • Object
show all
Defined in:
lib/xify.rb

Class Method Summary collapse

Class Method Details

.run(args) ⇒ Object



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
# File 'lib/xify.rb', line 8

def self.run(args)
  working_dir = "#{ENV['HOME']}/.xify"
  Dir.mkdir working_dir rescue Errno::EEXIST

  config_file = args.shift || "#{working_dir}/config.yml"
  puts "Loading config from #{config_file}"
  config = YAML::load_file config_file

  config.keys.each do |c|
    config[c].map! do |handler|
      next unless handler['enabled']
      Object.const_get(handler['class']).new(handler)
    end.compact!
  end

  puts 'Looking for updates'
  config['inputs'].each do |i|
    i.updates do |u|
      config['outputs'].each do |o|
        begin
          o.process u
        rescue => e
          $stderr.puts e.message
        end
      end
    end
  end
end