Class: Rssly::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/rssly/cli.rb

Overview

The rssly CLI

Instance Method Summary collapse

Instance Method Details

#fetch(*feed_urls) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/rssly/cli.rb', line 28

def fetch(*feed_urls)
  Rssly::CONFIG[:summary_ratio] = options[:summary_ratio]
  Rssly::CONFIG[:discover_feeds] = options[:discover]
  Rssly::CONFIG[:verbose] = options[:verbose]

  feeds = feed_urls.map { |url| Rssly::Feed.new url: url }
  collection = Rssly::Collection.create_from_feeds(*feeds)
  serializer = case options[:format]
               when 'text' then Rssly::Serializers::Text
               when 'html' then Rssly::Serializers::HTML
               when 'json' then Rssly::Serializers::JSON
               else fail "Serializer #{options[:format]} not found."
               end

  $stdout.puts serializer.new(collection).perform
end