atomizer 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +5 -0
- data/Gemfile +6 -0
- data/LICENSE +20 -0
- data/README.md +18 -0
- data/Rakefile +11 -0
- data/atomizer.gemspec +21 -0
- data/lib/atomizer.rb +19 -0
- data/lib/atomizer/author.rb +7 -0
- data/lib/atomizer/buildable.rb +9 -0
- data/lib/atomizer/builder.rb +10 -0
- data/lib/atomizer/collection.rb +19 -0
- data/lib/atomizer/content.rb +10 -0
- data/lib/atomizer/contributor.rb +8 -0
- data/lib/atomizer/entry.rb +13 -0
- data/lib/atomizer/feed.rb +97 -0
- data/lib/atomizer/feed_item.rb +84 -0
- data/lib/atomizer/generator.rb +10 -0
- data/lib/atomizer/link.rb +11 -0
- data/lib/atomizer/service.rb +25 -0
- data/lib/atomizer/text.rb +14 -0
- data/lib/atomizer/time.rb +7 -0
- data/lib/atomizer/version.rb +3 -0
- data/lib/atomizer/workspace.rb +20 -0
- data/test/test_helper.rb +3 -0
- data/test/unit/atomizer_atompub_test.rb +17 -0
- data/test/unit/atomizer_builder_test.rb +24 -0
- data/test/unit/atomizer_feed_test.rb +140 -0
- metadata +103 -0
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Mutwin Kraus
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Atomizer
|
2
|
+
--------
|
3
|
+
|
4
|
+
Atomizer is a Ruby library for parsing and generating Atom feeds.
|
5
|
+
|
6
|
+
|
7
|
+
Installation
|
8
|
+
============
|
9
|
+
|
10
|
+
$ gem install atomizer
|
11
|
+
|
12
|
+
|
13
|
+
Copyright
|
14
|
+
=========
|
15
|
+
|
16
|
+
Copyright (c) 2011 Mutwin Kraus
|
17
|
+
|
18
|
+
Atomizer is licensed under the [MIT License](https://github.com/mutle/atomizer/blob/master/LICENSE).
|
data/Rakefile
ADDED
data/atomizer.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "atomizer/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "atomizer"
|
7
|
+
s.version = Atomizer::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Mutwin Kraus"]
|
10
|
+
s.email = ["mutwin.kraus@gmail.com"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{Utilities for atom feed parsing and generation}
|
13
|
+
s.description = %q{Utilities for atom feed parsing and generation}
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.add_dependency "nokogiri"
|
21
|
+
end
|
data/lib/atomizer.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module Atomizer
|
4
|
+
autoload :Author, 'atomizer/author'
|
5
|
+
autoload :Builder, 'atomizer/builder'
|
6
|
+
autoload :Buildable,'atomizer/buildable'
|
7
|
+
autoload :Collection,'atomizer/collection'
|
8
|
+
autoload :Content,'atomizer/content'
|
9
|
+
autoload :Contributor,'atomizer/contributor'
|
10
|
+
autoload :Entry,'atomizer/entry'
|
11
|
+
autoload :Feed,'atomizer/feed'
|
12
|
+
autoload :Generator,'atomizer/generator'
|
13
|
+
autoload :FeedItem, 'atomizer/feed_item'
|
14
|
+
autoload :Link,'atomizer/link'
|
15
|
+
autoload :Service,'atomizer/service'
|
16
|
+
autoload :Text,'atomizer/text'
|
17
|
+
autoload :Time,'atomizer/time'
|
18
|
+
autoload :Workspace,'atomizer/workspace'
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Atomizer
|
2
|
+
class Collection < FeedItem
|
3
|
+
feed_attributes :href, :title, :accepts, :categories
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@accepts = []
|
7
|
+
@categories = []
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_xml(xml)
|
11
|
+
xml.collection :href => href do
|
12
|
+
xml['atom'].title title if title
|
13
|
+
accepts.each do |accept|
|
14
|
+
xml.accept accept
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Atomizer
|
2
|
+
class Entry < FeedItem
|
3
|
+
feed_tag_name "entry"
|
4
|
+
feed_attributes :id, :title, :links, :updated, :published, :authors, :contributors, :content
|
5
|
+
feed_no_collection_group_tag!
|
6
|
+
|
7
|
+
def initialize(*attrs)
|
8
|
+
super(*attrs)
|
9
|
+
@content_type ||= "html"
|
10
|
+
@links ||= []
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module Atomizer
|
2
|
+
class Feed < FeedItem
|
3
|
+
|
4
|
+
feed_attributes :id, :title, :subtitle, :updated, :published, :links, :rights, :generator, :generator_uri, :generator_version, :entries, :authors, :contributors
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def parse(xml)
|
8
|
+
doc = Nokogiri::XML(xml)
|
9
|
+
feed = new
|
10
|
+
feed.id = text(doc, "feed>id")
|
11
|
+
feed.title = text(doc, "feed>title")
|
12
|
+
feed.subtitle = text(doc, "feed>subtitle")
|
13
|
+
feed.updated = parse_time text(doc, "feed>updated")
|
14
|
+
feed.rights = text(doc, "feed>rights")
|
15
|
+
generator = text(doc, "feed>generator")
|
16
|
+
if generator
|
17
|
+
feed.generator = Generator.new(:name => text(doc, "feed>generator"), :uri => attribute_text(doc, "feed>generator", "uri"), :version => attribute_text(doc, "feed>generator", "version"))
|
18
|
+
end
|
19
|
+
feed.links = parse_links(doc.css("feed>link"))
|
20
|
+
|
21
|
+
doc.css("entry").each do |e|
|
22
|
+
entry = Entry.new
|
23
|
+
entry.id = text(e, "id")
|
24
|
+
entry.title = text(e, "title")
|
25
|
+
entry.content = parse_content e.css("content")
|
26
|
+
entry.updated = parse_time(text(e, "updated"))
|
27
|
+
entry.published = parse_time(text(e, "published"))
|
28
|
+
entry.authors = parse_authors e.css("author"), Author
|
29
|
+
entry.contributors = parse_authors e.css("contributor"), Contributor
|
30
|
+
entry.links = parse_links(e.css("link"))
|
31
|
+
feed.entries << entry
|
32
|
+
end
|
33
|
+
|
34
|
+
feed
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def text(element, selector)
|
40
|
+
Text.new(element.css(selector).first.text, element.css(selector).first.attributes)
|
41
|
+
end
|
42
|
+
|
43
|
+
def attribute_text(element, selector, attribute)
|
44
|
+
Text.new(element.css(selector).attr(attribute).text)
|
45
|
+
end
|
46
|
+
|
47
|
+
def parse_time(text)
|
48
|
+
Atomizer::Time.parse(text)
|
49
|
+
end
|
50
|
+
|
51
|
+
def parse_content(content)
|
52
|
+
Content.new(:body => content.inner_html, :type => content.attr("type").to_s, :xml_lang => content.attr("lang").to_s, :xml_base => content.attr("base").to_s)
|
53
|
+
end
|
54
|
+
|
55
|
+
def parse_links(link)
|
56
|
+
links = []
|
57
|
+
if link
|
58
|
+
link.each do |l|
|
59
|
+
rel = l.attr("rel").to_s
|
60
|
+
type = l.attr("type").to_s
|
61
|
+
hreflang = l.attr("hreflang").to_s
|
62
|
+
href = l.attr("href").to_s
|
63
|
+
length = l.attr("length").to_s
|
64
|
+
links << Atomizer::Link.new(:rel => rel, :type => type, :hreflang => hreflang, :href => href, :length => length)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
links
|
68
|
+
end
|
69
|
+
|
70
|
+
def parse_authors(author, author_class)
|
71
|
+
authors = []
|
72
|
+
if author
|
73
|
+
author.each do |a|
|
74
|
+
name = a.css("name").text
|
75
|
+
uri = a.css("uri").text
|
76
|
+
email = a.css("email").text
|
77
|
+
authors << author_class.new(:name => name, :uri => uri, :email => email)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
authors
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def initialize
|
85
|
+
@authors = []
|
86
|
+
@contributors = []
|
87
|
+
@entries = []
|
88
|
+
@links = []
|
89
|
+
end
|
90
|
+
|
91
|
+
def to_xml(xml, root_element=true)
|
92
|
+
xml.feed :xmlns => "http://www.w3.org/2005/Atom" do
|
93
|
+
super(xml, false)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
module Atomizer
|
2
|
+
class FeedItem
|
3
|
+
include Buildable
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def feed_tag_name(tag_name=nil)
|
8
|
+
@feed_tag_name = tag_name.to_s if tag_name
|
9
|
+
@feed_tag_name
|
10
|
+
end
|
11
|
+
|
12
|
+
def feed_attributes(*attrs)
|
13
|
+
@attributes ||= []
|
14
|
+
if attrs && attrs.size > 0
|
15
|
+
@attributes.push(*attrs)
|
16
|
+
attrs.each do |a|
|
17
|
+
attr_accessor a
|
18
|
+
end
|
19
|
+
end
|
20
|
+
@attributes
|
21
|
+
end
|
22
|
+
|
23
|
+
def feed_no_collection_group_tag!
|
24
|
+
@feed_no_collection_group_tag = true
|
25
|
+
end
|
26
|
+
|
27
|
+
def feed_no_collection_group_tag
|
28
|
+
@feed_no_collection_group_tag || false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def initialize(options={})
|
33
|
+
self.class.feed_attributes.each do |a|
|
34
|
+
if v = (options[a.to_sym] || options[a.to_s])
|
35
|
+
meth = "#{a}="
|
36
|
+
send(meth, v) if respond_to?(meth) && v && v != ""
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def to_xml(xml, root_element=true)
|
42
|
+
if root_element
|
43
|
+
xml.send(self.class.feed_tag_name) do |child_xml|
|
44
|
+
feed_attributes_to_xml(child_xml)
|
45
|
+
end
|
46
|
+
else
|
47
|
+
feed_attributes_to_xml(xml)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def feed_attributes_to_xml(xml)
|
54
|
+
self.class.feed_attributes.each do |a|
|
55
|
+
v = send(a) if respond_to?(a)
|
56
|
+
next if !v || v == ""
|
57
|
+
a = "#{a}_" if a.to_s == "id"
|
58
|
+
if v.is_a?(Array)
|
59
|
+
next if v.size == 0
|
60
|
+
if v.first.class.feed_no_collection_group_tag
|
61
|
+
v.each do |obj|
|
62
|
+
obj.to_xml xml
|
63
|
+
end
|
64
|
+
else
|
65
|
+
xml.send(a.to_s) do |child_xml|
|
66
|
+
v.each do |obj|
|
67
|
+
obj.to_xml child_xml
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
elsif v.respond_to?(:to_xml)
|
72
|
+
v.to_xml(xml)
|
73
|
+
elsif v.respond_to?(:attributes)
|
74
|
+
xml.send(a.to_s, v.attributes) do
|
75
|
+
xml.text v
|
76
|
+
end
|
77
|
+
else
|
78
|
+
xml.send(a.to_s, v.to_s)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Atomizer
|
2
|
+
class Service < FeedItem
|
3
|
+
feed_tag_name "service"
|
4
|
+
feed_attributes :workspaces
|
5
|
+
|
6
|
+
def initialize(*attrs)
|
7
|
+
super(*attrs)
|
8
|
+
@workspaces ||= []
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_xml(xml)
|
12
|
+
xml.service :xmlns => "http://www.w3.org/2007/app", :"xmlns:atom" => "http://www.w3.org/2005/Atom" do
|
13
|
+
workspaces.each do |workspace|
|
14
|
+
workspace.to_xml xml
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def setup_workspace(collection=nil)
|
20
|
+
workspace = Workspace.new
|
21
|
+
workspace.collections << collection if collection
|
22
|
+
self.workspaces << workspace
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Atomizer
|
2
|
+
class Workspace < FeedItem
|
3
|
+
feed_tag_name "workspace"
|
4
|
+
feed_attributes :collections, :title
|
5
|
+
|
6
|
+
def initialize(*attrs)
|
7
|
+
super(*attrs)
|
8
|
+
@collections ||= []
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_xml(xml)
|
12
|
+
xml.workspace do
|
13
|
+
xml['atom'].title title if title
|
14
|
+
collections.each do |collection|
|
15
|
+
collection.to_xml xml
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'atomizer'
|
3
|
+
|
4
|
+
class AtomizerAtompubTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_service_document
|
7
|
+
service = Atomizer::Service.new
|
8
|
+
workspace = Atomizer::Workspace.new
|
9
|
+
collection = Atomizer::Collection.new
|
10
|
+
workspace.collections << collection
|
11
|
+
service.workspaces << workspace
|
12
|
+
assert service.to_atom.include?("<service")
|
13
|
+
assert service.to_atom.include?("<workspace")
|
14
|
+
assert service.to_atom.include?("<collection")
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'atomizer'
|
3
|
+
|
4
|
+
class AtomizerBuilderTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
@feed = Atomizer::Feed.new
|
9
|
+
@builder = Atomizer::Builder.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_create_empty_feed
|
13
|
+
assert @builder.to_atom(@feed).include?("<feed")
|
14
|
+
assert @feed.to_atom.include?("<feed")
|
15
|
+
assert !@feed.to_atom.include?("<entry")
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_create_feed_entry
|
19
|
+
@feed.entries << Atomizer::Entry.new(:title => "Foo")
|
20
|
+
assert @builder.to_atom(@feed).include?("<title>Foo</title>")
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,140 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'atomizer'
|
3
|
+
|
4
|
+
class AtomizerFeedTest < Test::Unit::TestCase
|
5
|
+
# example from http://www.atomenabled.org/developers/syndication/atom-format-spec.php
|
6
|
+
EXAMPLE_ATOM = <<-XML
|
7
|
+
<?xml version="1.0" encoding="utf-8"?>
|
8
|
+
<feed xmlns="http://www.w3.org/2005/Atom">
|
9
|
+
<title type="text">dive into mark</title>
|
10
|
+
<subtitle type="html">
|
11
|
+
A <em>lot</em> of effort
|
12
|
+
went into making this effortless
|
13
|
+
</subtitle>
|
14
|
+
<updated>2005-07-31T12:29:29Z</updated>
|
15
|
+
<id>tag:example.org,2003:3</id>
|
16
|
+
<link rel="alternate" type="text/html"
|
17
|
+
hreflang="en" href="http://example.org/"/>
|
18
|
+
<link rel="self" type="application/atom+xml"
|
19
|
+
href="http://example.org/feed.atom"/>
|
20
|
+
<rights>Copyright (c) 2003, Mark Pilgrim</rights>
|
21
|
+
<generator uri="http://www.example.com/" version="1.0">
|
22
|
+
Example Toolkit
|
23
|
+
</generator>
|
24
|
+
<entry>
|
25
|
+
<title>Atom draft-07 snapshot</title>
|
26
|
+
<link rel="alternate" type="text/html"
|
27
|
+
href="http://example.org/2005/04/02/atom"/>
|
28
|
+
<link rel="enclosure" type="audio/mpeg" length="1337"
|
29
|
+
href="http://example.org/audio/ph34r_my_podcast.mp3"/>
|
30
|
+
<id>tag:example.org,2003:3.2397</id>
|
31
|
+
<updated>2005-07-31T12:29:29Z</updated>
|
32
|
+
<published>2003-12-13T08:29:29-04:00</published>
|
33
|
+
<author>
|
34
|
+
<name>Mark Pilgrim</name>
|
35
|
+
<uri>http://example.org/</uri>
|
36
|
+
<email>f8dy@example.com</email>
|
37
|
+
</author>
|
38
|
+
<contributor>
|
39
|
+
<name>Sam Ruby</name>
|
40
|
+
</contributor>
|
41
|
+
<contributor>
|
42
|
+
<name>Joe Gregorio</name>
|
43
|
+
</contributor>
|
44
|
+
<content type="xhtml" xml:lang="en"
|
45
|
+
xml:base="http://diveintomark.org/">
|
46
|
+
<div xmlns="http://www.w3.org/1999/xhtml">
|
47
|
+
<p><i>[Update: The Atom draft is finished.]</i></p>
|
48
|
+
</div>
|
49
|
+
</content>
|
50
|
+
</entry>
|
51
|
+
</feed>
|
52
|
+
XML
|
53
|
+
|
54
|
+
def setup
|
55
|
+
super
|
56
|
+
@feed = Atomizer::Feed.parse EXAMPLE_ATOM
|
57
|
+
@entry = @feed.entries.first
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_parse_feed_id
|
61
|
+
assert_equal "tag:example.org,2003:3", @feed.id
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_parse_feed_title
|
65
|
+
assert_equal "dive into mark", @feed.title
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_parse_feed_subtitle
|
69
|
+
assert @feed.subtitle.include? "effort"
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_parse_feed_updated
|
73
|
+
assert_equal 2005, @feed.updated.year
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_parse_feed_links
|
77
|
+
assert_equal 2, @feed.links.size
|
78
|
+
assert_equal "http://example.org/", @feed.links[0].href
|
79
|
+
assert_equal "alternate", @feed.links[0].rel
|
80
|
+
assert_equal "application/atom+xml", @feed.links[1].type
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_parse_feed_rights
|
84
|
+
assert @feed.rights.include? "Copyright"
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_parse_feed_generator
|
88
|
+
assert @feed.generator.name.include? "Example Toolkit"
|
89
|
+
assert_equal "http://www.example.com/", @feed.generator.uri
|
90
|
+
assert_equal "1.0", @feed.generator.version
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_parse_feed_entries
|
94
|
+
assert_equal 1, @feed.entries.size
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_parse_feed_entry_id
|
98
|
+
assert_equal "tag:example.org,2003:3.2397", @entry.id
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_parse_feed_entry_title
|
102
|
+
assert_equal "Atom draft-07 snapshot", @entry.title
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_parse_feed_entry_links
|
106
|
+
assert_equal 2, @entry.links.size
|
107
|
+
assert_equal "http://example.org/2005/04/02/atom", @entry.links[0].href
|
108
|
+
assert_equal "alternate", @entry.links[0].rel
|
109
|
+
assert_equal "audio/mpeg", @entry.links[1].type
|
110
|
+
assert_equal "1337", @entry.links[1].length
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_parse_feed_entry_content
|
114
|
+
assert @entry.content.body.include? "Update: The Atom draft is finished."
|
115
|
+
assert_equal "xhtml", @entry.content.type
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_parse_feed_dates
|
119
|
+
assert_equal 2005, @entry.updated.year
|
120
|
+
assert_equal 2003, @entry.published.year
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_parse_feed_author
|
124
|
+
assert_equal "Mark Pilgrim", @entry.authors.first.name
|
125
|
+
assert_equal "http://example.org/", @entry.authors.first.uri
|
126
|
+
assert_equal "f8dy@example.com", @entry.authors.first.email
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_parse_feed_contributor
|
130
|
+
assert_equal 2, @entry.contributors.size
|
131
|
+
assert_equal "Sam Ruby", @entry.contributors[0].name
|
132
|
+
assert_nil @entry.contributors[0].uri
|
133
|
+
assert_nil @entry.contributors[0].email
|
134
|
+
assert_equal "Joe Gregorio", @entry.contributors[1].name
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_generate_feed
|
138
|
+
assert @feed.to_atom.include?("<entry")
|
139
|
+
end
|
140
|
+
end
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: atomizer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Mutwin Kraus
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-03-01 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: nokogiri
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :runtime
|
31
|
+
version_requirements: *id001
|
32
|
+
description: Utilities for atom feed parsing and generation
|
33
|
+
email:
|
34
|
+
- mutwin.kraus@gmail.com
|
35
|
+
executables: []
|
36
|
+
|
37
|
+
extensions: []
|
38
|
+
|
39
|
+
extra_rdoc_files: []
|
40
|
+
|
41
|
+
files:
|
42
|
+
- .gitignore
|
43
|
+
- Gemfile
|
44
|
+
- LICENSE
|
45
|
+
- README.md
|
46
|
+
- Rakefile
|
47
|
+
- atomizer.gemspec
|
48
|
+
- lib/atomizer.rb
|
49
|
+
- lib/atomizer/author.rb
|
50
|
+
- lib/atomizer/buildable.rb
|
51
|
+
- lib/atomizer/builder.rb
|
52
|
+
- lib/atomizer/collection.rb
|
53
|
+
- lib/atomizer/content.rb
|
54
|
+
- lib/atomizer/contributor.rb
|
55
|
+
- lib/atomizer/entry.rb
|
56
|
+
- lib/atomizer/feed.rb
|
57
|
+
- lib/atomizer/feed_item.rb
|
58
|
+
- lib/atomizer/generator.rb
|
59
|
+
- lib/atomizer/link.rb
|
60
|
+
- lib/atomizer/service.rb
|
61
|
+
- lib/atomizer/text.rb
|
62
|
+
- lib/atomizer/time.rb
|
63
|
+
- lib/atomizer/version.rb
|
64
|
+
- lib/atomizer/workspace.rb
|
65
|
+
- test/test_helper.rb
|
66
|
+
- test/unit/atomizer_atompub_test.rb
|
67
|
+
- test/unit/atomizer_builder_test.rb
|
68
|
+
- test/unit/atomizer_feed_test.rb
|
69
|
+
has_rdoc: true
|
70
|
+
homepage: ""
|
71
|
+
licenses: []
|
72
|
+
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
segments:
|
83
|
+
- 0
|
84
|
+
version: "0"
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
segments:
|
90
|
+
- 0
|
91
|
+
version: "0"
|
92
|
+
requirements: []
|
93
|
+
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 1.3.6
|
96
|
+
signing_key:
|
97
|
+
specification_version: 3
|
98
|
+
summary: Utilities for atom feed parsing and generation
|
99
|
+
test_files:
|
100
|
+
- test/test_helper.rb
|
101
|
+
- test/unit/atomizer_atompub_test.rb
|
102
|
+
- test/unit/atomizer_builder_test.rb
|
103
|
+
- test/unit/atomizer_feed_test.rb
|