Class: Hootenanny::FeedStore::FileFeedStore

Inherits:
Object
  • Object
show all
Defined in:
lib/hootenanny/feed_store/file_feed_store.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ FileFeedStore

Returns a new instance of FileFeedStore.



9
10
11
# File 'lib/hootenanny/feed_store/file_feed_store.rb', line 9

def initialize(options = {})
  self.feed_file = options.fetch(:location)
end

Instance Method Details

#fetch(options = {}) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/hootenanny/feed_store/file_feed_store.rb', line 13

def fetch(options = {})
  self.url  = options.fetch(:url)
  feed_file = self.feed_file << options[:path] << url_file_glob

  Hootenanny::Feed.infer(feed_file.read,
                         type: feed_file.type)
end

#store(options = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/hootenanny/feed_store/file_feed_store.rb', line 21

def store(options = {})
  self.url  = options.fetch(:url)
  feed      = options.fetch(:feed)
  feed_type = feed.type

  feed_file = self.feed_file << options[:path] << "#{url}.#{feed_type}"

  feed_file.write(feed)
end