Class: Omnom::Source::Atom

Inherits:
Base
  • Object
show all
Defined in:
lib/omnom/source/atom.rb

Direct Known Subclasses

Github::Blog, Github::Default

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

Methods included from ParserMethods

#html_to_text

Constructor Details

This class inherits a constructor from Omnom::Source::Base

Instance Method Details

#after_initializeObject



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_nameObject



57
58
59
# File 'lib/omnom/source/atom.rb', line 57

def author_name
  @node.find('author > name').text
end

#author_urlObject



61
62
63
# File 'lib/omnom/source/atom.rb', line 61

def author_url
  @node.drill([:find, 'author > uri'], :text)
end

#descriptionObject



37
38
39
# File 'lib/omnom/source/atom.rb', line 37

def description
  @node.>('content').first.text
end

#get_raw_postsObject



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

#guidObject



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_atObject



49
50
51
# File 'lib/omnom/source/atom.rb', line 49

def published_at
  @node.>('published').first.time
end

#tagsObject



65
66
67
# File 'lib/omnom/source/atom.rb', line 65

def tags
  nil
end

#thumbnail_urlObject



53
54
55
# File 'lib/omnom/source/atom.rb', line 53

def thumbnail_url
  @node.drill([:>, 'thumbnail'], :first, [:url, 'url'])
end

#titleObject



33
34
35
# File 'lib/omnom/source/atom.rb', line 33

def title
  @node.>('title').first.text
end

#urlObject



45
46
47
# File 'lib/omnom/source/atom.rb', line 45

def url
  @node.>('link').first.attr('href')
end