Class: ReadabilityImporter::Command

Inherits:
Thor
  • Object
show all
Defined in:
lib/readability_importer/command.rb

Instance Method Summary collapse

Instance Method Details

#importObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/readability_importer/command.rb', line 33

def import
  importer = Importer.new(options[:email_address], {
    :verbose => options[:verbose],
    :from => options[:from],
    :max_concurrency => options[:concurrency],

    :on_importing => proc do |urls|
      puts "Importing #{urls.size} url(s)..."
    end,
    :on_imported => proc do |urls|
      puts urls.map{|u| "Imported #{u}"}
    end,
    :on_failed => proc do |urls|
      puts urls.map{|u| "Failed #{u}"}
    end
  })
  Loader.loaders.each do |(name, klass)|
    if options[name]
      loader = klass.new(options[name])
      urls = loader.load
      puts "Start importing #{urls.size} url(s)."
      importer.import(urls)
    end
  end
end

#versionObject



60
61
62
# File 'lib/readability_importer/command.rb', line 60

def version
  puts VERSION
end