Class: Omnom::Source::Atom
- Inherits:
-
Base
- Object
- Base
- Omnom::Source::Atom
show all
- Defined in:
- lib/omnom/source/atom.rb
Instance Attribute Summary
Attributes inherited from Base
#config, #feed_key, #key, #options, #settings, #source_id
Instance Method Summary
collapse
Methods inherited from Base
config, configure, cron, every, feed_url, full_key, guid_namespace, icon, icon_from_url, inherited, #initialize, key, required_config, required_options, #update, url
#html_to_text
Instance Method Details
#after_initialize ⇒ Object
6
7
8
|
# File 'lib/omnom/source/atom.rb', line 6
def after_initialize
@settings[:icon] = self.class.icon_from_url(@options[:url]) if @settings[:icon].blank?
end
|
#author_name ⇒ Object
57
58
59
|
# File 'lib/omnom/source/atom.rb', line 57
def author_name
@node.find('author > name').text
end
|
#author_url ⇒ Object
61
62
63
|
# File 'lib/omnom/source/atom.rb', line 61
def author_url
@node.drill([:find, 'author > uri'], :text)
end
|
#description ⇒ Object
37
38
39
|
# File 'lib/omnom/source/atom.rb', line 37
def description
@node.>('content').first.text
end
|
#get_raw_posts ⇒ Object
10
11
12
13
14
15
16
|
# File 'lib/omnom/source/atom.rb', line 10
def get_raw_posts
if @page.blank?
Reporting.warn_once "Omnom.#{self.class}.get_raw_posts", "Unable to get page for Atom feed in #{self.class}"
return nil
end
@page.search('feed > entry')
end
|
#guid ⇒ Object
41
42
43
|
# File 'lib/omnom/source/atom.rb', line 41
def guid
@node.>('id').first.text
end
|
#post_attributes(node) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/omnom/source/atom.rb', line 18
def post_attributes(node)
@node = node
{
title: title,
description: description,
guid: guid,
url: url,
published_at: published_at,
thumbnail_url: thumbnail_url,
author_name: author_name,
author_url: author_url,
tags: tags
}
end
|
#published_at ⇒ Object
49
50
51
|
# File 'lib/omnom/source/atom.rb', line 49
def published_at
@node.>('published').first.time
end
|
65
66
67
|
# File 'lib/omnom/source/atom.rb', line 65
def tags
nil
end
|
#thumbnail_url ⇒ Object
53
54
55
|
# File 'lib/omnom/source/atom.rb', line 53
def thumbnail_url
@node.drill([:>, 'thumbnail'], :first, [:url, 'url'])
end
|
#title ⇒ Object
33
34
35
|
# File 'lib/omnom/source/atom.rb', line 33
def title
@node.>('title').first.text
end
|
#url ⇒ Object
45
46
47
|
# File 'lib/omnom/source/atom.rb', line 45
def url
@node.>('link').first.attr('href')
end
|