Class: Tapas::FeedSource

Inherits:
Object
  • Object
show all
Defined in:
lib/tapas/feed_source.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ FeedSource



7
8
9
# File 'lib/tapas/feed_source.rb', line 7

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'lib/tapas/feed_source.rb', line 5

def config
  @config
end

Instance Method Details

#feedObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/tapas/feed_source.rb', line 11

def feed
  if config.feed_file
    File.read(config.feed_file)
  elsif config.feed_url
    open(config.feed_url, http_basic_authentication: [config.username, config.password]).read
  end
rescue OpenURI::HTTPError => e
  raise Tapas::UnauthorizedError if e.message == "401 Unauthorized"
  raise
end