Sha256: 2551f1797463616ef2f963a28f36bfc8db2b75f77e98573941d5a6cb6a227ede

Contents?: true

Size: 873 Bytes

Versions: 20

Compression:

Stored size: 873 Bytes

Contents

#!/usr/bin/env ruby

require 'rss'
require 'tins'
require 'open-uri'
require 'term/ansicolor'


class String
  include Term::ANSIColor

  def wrap(cols: Tins::Terminal.cols)
    split(?\n).each do |line|
      line.size > cols and line.gsub!(/(.{1,#{cols}})(\s+|$)/, "\\1\n")
      line.strip!
    end * ?\n
  end
end

IO.popen(ENV.fetch('PAGER', `which less`.chomp << ' -r'), 'w') do |pager|
  url = ARGV.shift
  open(url) do |rss|
    feed = RSS::Parser.parse(rss)
    pager.puts "Feed: #{feed.channel.title}",
      ?– * Tins::Terminal.cols
    feed.items.sort_by { |item| -item.date.to_f }.each do |item|
      pager.puts(
        "Title: #{item.title.bright_blue}",
        "Link: #{item.link.red}",
        "Date: #{item.date.strftime('%FT%T%z')}",
        "",
        item.description.wrap.chomp.white,
        ?– * Tins::Terminal.cols
      )
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
utils-0.22.1 bin/rssr
utils-0.22.0 bin/rssr
utils-0.21.2 bin/rssr
utils-0.21.1 bin/rssr
utils-0.21.0 bin/rssr
utils-0.20.0 bin/rssr
utils-0.19.0 bin/rssr
utils-0.18.1 bin/rssr
utils-0.18.0 bin/rssr
utils-0.17.0 bin/rssr
utils-0.16.0 bin/rssr
utils-0.15.1 bin/rssr
utils-0.15.0 bin/rssr
utils-0.14.0 bin/rssr
utils-0.13.0 bin/rssr
utils-0.12.0 bin/rssr
utils-0.11.0 bin/rssr
utils-0.10.1 bin/rssr
utils-0.10.0 bin/rssr
utils-0.9.0 bin/rssr