ratom 0.6.9 → 0.6.10
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/VERSION.yml +2 -2
- data/lib/atom.rb +30 -6
- data/lib/atom/xml/parser.rb +11 -3
- data/ratom.gemspec +6 -4
- data/spec/atom_spec.rb +22 -0
- data/spec/fixtures/external_content_single_entry.atom +21 -0
- metadata +6 -14
data/History.txt
CHANGED
data/VERSION.yml
CHANGED
data/lib/atom.rb
CHANGED
@@ -170,13 +170,17 @@ module Atom # :nodoc:
|
|
170
170
|
|
171
171
|
class Content # :nodoc:
|
172
172
|
def self.parse(xml)
|
173
|
-
|
174
|
-
|
175
|
-
Xhtml.new(xml)
|
176
|
-
when "html"
|
177
|
-
Html.new(xml)
|
173
|
+
if xml['src'] && !xml['src'].empty?
|
174
|
+
External.new(xml)
|
178
175
|
else
|
179
|
-
|
176
|
+
case xml['type']
|
177
|
+
when "xhtml"
|
178
|
+
Xhtml.new(xml)
|
179
|
+
when "html"
|
180
|
+
Html.new(xml)
|
181
|
+
else
|
182
|
+
Text.new(xml)
|
183
|
+
end
|
180
184
|
end
|
181
185
|
end
|
182
186
|
|
@@ -212,6 +216,26 @@ module Atom # :nodoc:
|
|
212
216
|
end
|
213
217
|
end
|
214
218
|
|
219
|
+
# External content reference within an Atom document.
|
220
|
+
class External < Base
|
221
|
+
attribute :type, :src
|
222
|
+
|
223
|
+
# this one only works with XML::Reader instances, no strings, since the
|
224
|
+
# content won't be inline.
|
225
|
+
def initialize(o)
|
226
|
+
raise ArgumentError, "Got #{o} which isn't an XML::Reader" unless o.kind_of?(XML::Reader)
|
227
|
+
super("")
|
228
|
+
parse(o, :once => true)
|
229
|
+
end
|
230
|
+
|
231
|
+
def to_xml(nodeonly = true, name = 'content', namespace = nil, namespace_map = Atom::Xml::NamespaceMap.new)
|
232
|
+
node = XML::Node.new("#{namespace_map.prefix(Atom::NAMESPACE, name)}")
|
233
|
+
node['type'] = self.type if self.type
|
234
|
+
node['src'] = self.src if self.src
|
235
|
+
node
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
215
239
|
# Text content within an Atom document.
|
216
240
|
class Text < Base
|
217
241
|
attribute :type, :'xml:lang'
|
data/lib/atom/xml/parser.rb
CHANGED
@@ -10,7 +10,7 @@ require 'time'
|
|
10
10
|
RootCA = '/etc/ssl/certs'
|
11
11
|
|
12
12
|
# Just a couple methods form transforming strings
|
13
|
-
unless
|
13
|
+
unless String.instance_methods.include?(:singularize)
|
14
14
|
class String # :nodoc:
|
15
15
|
def singularize
|
16
16
|
if self =~ /ies$/
|
@@ -19,11 +19,19 @@ unless defined?(ActiveSupport)
|
|
19
19
|
self.sub(/s$/, '')
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
unless String.instance_methods.include?(:demodulize)
|
26
|
+
class String # :nodoc:
|
23
27
|
def demodulize
|
24
28
|
self.sub(/.*::/, '')
|
25
29
|
end
|
26
|
-
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
unless String.instance_methods.include?(:constantize)
|
34
|
+
class String # :nodoc:
|
27
35
|
def constantize
|
28
36
|
Object.module_eval("::#{self}", __FILE__, __LINE__)
|
29
37
|
end
|
data/ratom.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ratom}
|
8
|
-
s.version = "0.6.
|
8
|
+
s.version = "0.6.10"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Peerworks", "Sean Geoghegan"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-10-15}
|
13
13
|
s.description = %q{A fast Atom Syndication and Publication API based on libxml}
|
14
14
|
s.email = %q{seangeo@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -56,6 +56,7 @@ Gem::Specification.new do |s|
|
|
56
56
|
"spec/fixtures/entry_with_custom_extensions.atom",
|
57
57
|
"spec/fixtures/entry_with_simple_extensions.atom",
|
58
58
|
"spec/fixtures/entry_with_single_custom_extension.atom",
|
59
|
+
"spec/fixtures/external_content_single_entry.atom",
|
59
60
|
"spec/fixtures/multiple_entry.atom",
|
60
61
|
"spec/fixtures/simple_single_entry.atom",
|
61
62
|
"spec/fixtures/with_stylesheet.atom",
|
@@ -69,7 +70,7 @@ Gem::Specification.new do |s|
|
|
69
70
|
s.homepage = %q{http://github.com/seangeo/ratom}
|
70
71
|
s.require_paths = ["lib"]
|
71
72
|
s.rubyforge_project = %q{ratom}
|
72
|
-
s.rubygems_version = %q{1.6
|
73
|
+
s.rubygems_version = %q{1.3.6}
|
73
74
|
s.summary = %q{Atom Syndication and Publication API}
|
74
75
|
s.test_files = [
|
75
76
|
"spec/atom/pub_spec.rb",
|
@@ -79,9 +80,10 @@ Gem::Specification.new do |s|
|
|
79
80
|
]
|
80
81
|
|
81
82
|
if s.respond_to? :specification_version then
|
83
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
82
84
|
s.specification_version = 3
|
83
85
|
|
84
|
-
if Gem::Version.new(Gem::
|
86
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
85
87
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
86
88
|
s.add_runtime_dependency(%q<libxml-ruby>, [">= 1.1.2"])
|
87
89
|
else
|
data/spec/atom_spec.rb
CHANGED
@@ -1293,6 +1293,28 @@ describe Atom do
|
|
1293
1293
|
end
|
1294
1294
|
end
|
1295
1295
|
|
1296
|
+
describe Atom::Content::External do
|
1297
|
+
before(:each) do
|
1298
|
+
feed = nil
|
1299
|
+
lambda { feed = Atom::Feed.load_feed(File.open('spec/fixtures/external_content_single_entry.atom')) }.should_not raise_error
|
1300
|
+
entry = feed.entries.first
|
1301
|
+
entry.content.should_not be_nil
|
1302
|
+
@content = entry.content
|
1303
|
+
@content.class.should == Atom::Content::External
|
1304
|
+
end
|
1305
|
+
|
1306
|
+
it "should capture the src" do
|
1307
|
+
@content.type.should == 'application/pdf'
|
1308
|
+
@content.src.should == 'http://example.org/pdfs/robots-run-amok.pdf'
|
1309
|
+
end
|
1310
|
+
|
1311
|
+
it "should include type and src in the serialized xml" do
|
1312
|
+
xml = @content.to_xml
|
1313
|
+
xml['type'].should == 'application/pdf'
|
1314
|
+
xml['src'].should == 'http://example.org/pdfs/robots-run-amok.pdf'
|
1315
|
+
end
|
1316
|
+
end
|
1317
|
+
|
1296
1318
|
describe 'Atom::Category initializer' do
|
1297
1319
|
it "should create a empty category" do
|
1298
1320
|
lambda { Atom::Category.new }.should_not raise_error
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<feed xmlns="http://www.w3.org/2005/Atom">
|
3
|
+
|
4
|
+
<title>Example Feed</title>
|
5
|
+
<link href="http://example.org/"/>
|
6
|
+
<updated>2003-12-13T18:30:02Z</updated>
|
7
|
+
<author>
|
8
|
+
<name>John Doe</name>
|
9
|
+
</author>
|
10
|
+
<id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
|
11
|
+
|
12
|
+
<entry>
|
13
|
+
<title>Atom-Powered Robots Run Amok</title>
|
14
|
+
<link href="http://example.org/2003/12/13/atom03"/>
|
15
|
+
<id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
|
16
|
+
<content type="application/pdf" src="http://example.org/pdfs/robots-run-amok.pdf"/>
|
17
|
+
<updated>2003-12-13T18:30:02Z</updated>
|
18
|
+
<summary>Some text.</summary>
|
19
|
+
</entry>
|
20
|
+
|
21
|
+
</feed>
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ratom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
4
|
+
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
8
|
+
- 10
|
9
|
+
version: 0.6.10
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Peerworks
|
@@ -16,18 +15,16 @@ autorequire:
|
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
17
|
|
19
|
-
date: 2011-
|
18
|
+
date: 2011-10-15 00:00:00 +10:30
|
20
19
|
default_executable:
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|
23
22
|
name: rspec
|
24
23
|
prerelease: false
|
25
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
25
|
requirements:
|
28
26
|
- - ">="
|
29
27
|
- !ruby/object:Gem::Version
|
30
|
-
hash: 3
|
31
28
|
segments:
|
32
29
|
- 0
|
33
30
|
version: "0"
|
@@ -37,11 +34,9 @@ dependencies:
|
|
37
34
|
name: libxml-ruby
|
38
35
|
prerelease: false
|
39
36
|
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
-
none: false
|
41
37
|
requirements:
|
42
38
|
- - ">="
|
43
39
|
- !ruby/object:Gem::Version
|
44
|
-
hash: 23
|
45
40
|
segments:
|
46
41
|
- 1
|
47
42
|
- 1
|
@@ -98,6 +93,7 @@ files:
|
|
98
93
|
- spec/fixtures/entry_with_custom_extensions.atom
|
99
94
|
- spec/fixtures/entry_with_simple_extensions.atom
|
100
95
|
- spec/fixtures/entry_with_single_custom_extension.atom
|
96
|
+
- spec/fixtures/external_content_single_entry.atom
|
101
97
|
- spec/fixtures/multiple_entry.atom
|
102
98
|
- spec/fixtures/simple_single_entry.atom
|
103
99
|
- spec/fixtures/with_stylesheet.atom
|
@@ -117,27 +113,23 @@ rdoc_options: []
|
|
117
113
|
require_paths:
|
118
114
|
- lib
|
119
115
|
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
-
none: false
|
121
116
|
requirements:
|
122
117
|
- - ">="
|
123
118
|
- !ruby/object:Gem::Version
|
124
|
-
hash: 3
|
125
119
|
segments:
|
126
120
|
- 0
|
127
121
|
version: "0"
|
128
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
123
|
requirements:
|
131
124
|
- - ">="
|
132
125
|
- !ruby/object:Gem::Version
|
133
|
-
hash: 3
|
134
126
|
segments:
|
135
127
|
- 0
|
136
128
|
version: "0"
|
137
129
|
requirements: []
|
138
130
|
|
139
131
|
rubyforge_project: ratom
|
140
|
-
rubygems_version: 1.6
|
132
|
+
rubygems_version: 1.3.6
|
141
133
|
signing_key:
|
142
134
|
specification_version: 3
|
143
135
|
summary: Atom Syndication and Publication API
|