Class: Mako::Subscribe

Inherits:
Object
  • Object
show all
Defined in:
lib/mako/commands/subscribe.rb

Class Method Summary collapse

Class Method Details

.perform(args) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/mako/commands/subscribe.rb', line 5

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

.write_to_subscriptions(feed_urls) ⇒ Object



15
16
17
18
# File 'lib/mako/commands/subscribe.rb', line 15

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