Class: Gigbot::Commands::Update

Inherits:
Object
  • Object
show all
Defined in:
lib/gigbot/commands/update.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.run(options = {}) ⇒ Object



8
9
10
# File 'lib/gigbot/commands/update.rb', line 8

def self.run(options={})
  new.run(options)
end

Instance Method Details

#run(options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/gigbot/commands/update.rb', line 12

def run(options={})
  FileUtils.mkdir_p Gigbot::DATA_PATH
  Gigbot::Source.each do |source|
    begin
      source.import
      puts [
        "✓".colorize(color: :green),
        "(#{source.imported.length})".ljust(7, ' ').colorize(color: :yellow),
        source.title,
      ].join(' ')
    rescue StandardError => e
      if options[:verbose]
        puts e
        puts e.backtrace
      end
      puts [
        "X".colorize(color: :red),
        "".ljust(7, ' '),
        source.title,
      ].join(' ')
    end
  end
end