ratom 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/lib/atom/version.rb +1 -1
- data/lib/atom.rb +29 -16
- data/spec/atom_spec.rb +42 -0
- metadata +3 -3
data/History.txt
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
== 0.3.4 2008-04-21
|
2
|
+
|
3
|
+
* Remove useless variable warning. (Sam Roberts)
|
4
|
+
* Support initialization of Atom::Source from Hash and block.
|
5
|
+
* Support initialization of Atom::Generator from Hash and block.
|
6
|
+
|
1
7
|
== 0.3.3 2008-04-09
|
2
8
|
|
3
9
|
* Better serialization of namespaced elements. ratom will now generate prefixes for namespaces and write them as
|
data/lib/atom/version.rb
CHANGED
data/lib/atom.rb
CHANGED
@@ -40,10 +40,6 @@ module Atom # :nodoc:
|
|
40
40
|
@simple_extensions = {}
|
41
41
|
end
|
42
42
|
|
43
|
-
if @simple_extension_attributes.nil?
|
44
|
-
@simple_extension_attributes = {}
|
45
|
-
end
|
46
|
-
|
47
43
|
key = "{#{ns},#{localname}}"
|
48
44
|
(@simple_extensions[key] or @simple_extensions[key] = ValueProxy.new)
|
49
45
|
end
|
@@ -65,16 +61,25 @@ module Atom # :nodoc:
|
|
65
61
|
class Generator
|
66
62
|
include Xml::Parseable
|
67
63
|
|
68
|
-
|
64
|
+
attr_accessor :name
|
69
65
|
attribute :uri, :version
|
70
66
|
|
71
67
|
# Initialize a new Generator.
|
72
68
|
#
|
73
69
|
# +xml+:: An XML::Reader object.
|
74
70
|
#
|
75
|
-
def initialize(
|
76
|
-
|
77
|
-
|
71
|
+
def initialize(o = nil)
|
72
|
+
case o
|
73
|
+
when XML::Reader
|
74
|
+
@name = o.read_string.strip
|
75
|
+
parse(o, :once => true)
|
76
|
+
when Hash
|
77
|
+
o.each do |k, v|
|
78
|
+
self.send("#{k.to_s}=", v)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
yield(self) if block_given?
|
78
83
|
end
|
79
84
|
end
|
80
85
|
|
@@ -257,7 +262,6 @@ module Atom # :nodoc:
|
|
257
262
|
|
258
263
|
div = XML::Node.new('div')
|
259
264
|
div['xmlns'] = XHTML
|
260
|
-
div
|
261
265
|
|
262
266
|
p = XML::Parser.string(to_s)
|
263
267
|
content = p.parse.root.copy(true)
|
@@ -283,15 +287,24 @@ module Atom # :nodoc:
|
|
283
287
|
elements :authors, :contributors, :class => Person
|
284
288
|
elements :links
|
285
289
|
|
286
|
-
def initialize(
|
287
|
-
unless current_node_is?(xml, 'source', NAMESPACE)
|
288
|
-
raise ArgumentError, "Invalid node for atom:source - #{xml.name}(#{xml.namespace})"
|
289
|
-
end
|
290
|
-
|
290
|
+
def initialize(o = nil)
|
291
291
|
@authors, @contributors, @links = [], [], Links.new
|
292
|
+
|
293
|
+
case o
|
294
|
+
when XML::Reader
|
295
|
+
unless current_node_is?(o, 'source', NAMESPACE)
|
296
|
+
raise ArgumentError, "Invalid node for atom:source - #{o.name}(#{o.namespace})"
|
297
|
+
end
|
298
|
+
|
299
|
+
o.read
|
300
|
+
parse(o)
|
301
|
+
when Hash
|
302
|
+
o.each do |k, v|
|
303
|
+
self.send("#{k.to_s}=", v)
|
304
|
+
end
|
305
|
+
end
|
292
306
|
|
293
|
-
|
294
|
-
parse(xml)
|
307
|
+
yield(self) if block_given?
|
295
308
|
end
|
296
309
|
end
|
297
310
|
|
data/spec/atom_spec.rb
CHANGED
@@ -1133,4 +1133,46 @@ describe Atom do
|
|
1133
1133
|
category.term.should == 'term'
|
1134
1134
|
end
|
1135
1135
|
end
|
1136
|
+
|
1137
|
+
describe Atom::Source do
|
1138
|
+
it "should create an empty source" do
|
1139
|
+
lambda { Atom::Source.new }.should_not raise_error
|
1140
|
+
end
|
1141
|
+
|
1142
|
+
it "should create from a hash" do
|
1143
|
+
source = Atom::Source.new(:title => 'title', :id => 'sourceid')
|
1144
|
+
source.title.should == 'title'
|
1145
|
+
source.id.should == 'sourceid'
|
1146
|
+
end
|
1147
|
+
|
1148
|
+
it "should create from a block" do
|
1149
|
+
source = Atom::Source.new do |source|
|
1150
|
+
source.title = 'title'
|
1151
|
+
source.id = 'sourceid'
|
1152
|
+
end
|
1153
|
+
source.title.should == 'title'
|
1154
|
+
source.id.should == 'sourceid'
|
1155
|
+
end
|
1156
|
+
end
|
1157
|
+
|
1158
|
+
describe Atom::Generator do
|
1159
|
+
it "should create an empty generator" do
|
1160
|
+
lambda { Atom::Generator.new }.should_not raise_error
|
1161
|
+
end
|
1162
|
+
|
1163
|
+
it "should create from a hash" do
|
1164
|
+
source = Atom::Generator.new(:name => 'generator', :uri => 'http://generator')
|
1165
|
+
source.name.should == 'generator'
|
1166
|
+
source.uri.should == 'http://generator'
|
1167
|
+
end
|
1168
|
+
|
1169
|
+
it "should create from a block" do
|
1170
|
+
source = Atom::Generator.new do |source|
|
1171
|
+
source.name = 'generator'
|
1172
|
+
source.uri = 'http://generator'
|
1173
|
+
end
|
1174
|
+
source.name.should == 'generator'
|
1175
|
+
source.uri.should == 'http://generator'
|
1176
|
+
end
|
1177
|
+
end
|
1136
1178
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ratom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peerworks
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-04-
|
12
|
+
date: 2008-04-21 00:00:00 +09:30
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
requirements: []
|
110
110
|
|
111
111
|
rubyforge_project: ratom
|
112
|
-
rubygems_version: 1.1.
|
112
|
+
rubygems_version: 1.1.1
|
113
113
|
signing_key:
|
114
114
|
specification_version: 2
|
115
115
|
summary: Atom Syndication and Publication API
|