Class: NewsFetcher::Commands::Discover

Inherits:
NewsFetcher::Command show all
Defined in:
lib/newsfetcher/commands/discover.rb

Instance Attribute Summary

Attributes inherited from NewsFetcher::Command

#dir, #log_level, #max_threads

Instance Method Summary collapse

Instance Method Details

#run(args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/newsfetcher/commands/discover.rb', line 7

def run(args)
  super
  args.map { |a| Addressable::URI.parse(a) }.each do |uri|
    fetcher = Fetcher.get(uri)
    if fetcher.success?
      fetcher.find_feeds.each do |feed|
        feed.each do |key, value|
          puts "%10s: %s" % [key, value]
        end
        puts
      end
    else
      warn "#{uri}: HTTP error #{fetcher.response_status} (#{fetcher.response_reason})"
    end
  end
end