Sha256: 7c706ea471bacb9611e120c4b887c0eeba3db3754c65e1f1908c66ed1bd5ca68

Contents?: true

Size: 581 Bytes

Versions: 3

Compression:

Stored size: 581 Bytes

Contents

# frozen_string_literal: true

module Mako
  class Subscribe
    def self.perform(args)
      if args.empty?
        Mako.errors.add_error 'No feeds to find'
        return
      end
      feeds = Mako::FeedFinder.new(uris: args).find
      write_to_subscriptions(feeds)
      Mako.logger.info "Subscribed to the following feeds: #{feeds}"
    end

    def self.write_to_subscriptions(feed_urls)
      path = File.expand_path(Dir.glob('subscriptions.*').first, Dir.pwd)
      Mako::SubscriptionListWriter.new(feeds: feed_urls, destination: path).append_and_write
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mako_rss-0.2.5 lib/mako/commands/subscribe.rb
mako_rss-0.2.3 lib/mako/commands/subscribe.rb
mako_rss-0.2.2 lib/mako/commands/subscribe.rb