ratom 0.6.6 → 0.6.7
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/History.txt
CHANGED
data/VERSION.yml
CHANGED
data/lib/atom/xml/parser.rb
CHANGED
@@ -29,6 +29,10 @@ unless defined?(ActiveSupport)
|
|
29
29
|
end
|
30
30
|
|
31
31
|
module Atom
|
32
|
+
def self.to_attrname(element_name)
|
33
|
+
element_name.to_s.sub(/:/, '_').gsub('-', '_').to_sym
|
34
|
+
end
|
35
|
+
|
32
36
|
class LoadError < StandardError
|
33
37
|
attr_reader :response
|
34
38
|
def initialize(response)
|
@@ -117,7 +121,7 @@ module Atom
|
|
117
121
|
end
|
118
122
|
|
119
123
|
def accessor_name(name)
|
120
|
-
|
124
|
+
Atom.to_attrname(name)
|
121
125
|
end
|
122
126
|
|
123
127
|
def Parseable.included(o)
|
@@ -233,7 +237,7 @@ module Atom
|
|
233
237
|
options.merge!(names.pop) if names.last.is_a?(Hash)
|
234
238
|
|
235
239
|
names.each do |name|
|
236
|
-
attr_accessor
|
240
|
+
attr_accessor Atom.to_attrname(name)
|
237
241
|
ns, local_name = name.to_s[/(.*):(.*)/,1], $2 || name
|
238
242
|
self.known_namespaces << self.extensions_namespaces[ns] if ns
|
239
243
|
self.ordered_element_specs << self.element_specs[local_name.to_s] = ParseSpec.new(name, options)
|
@@ -245,7 +249,7 @@ module Atom
|
|
245
249
|
options.merge!(names.pop) if names.last.is_a?(Hash)
|
246
250
|
|
247
251
|
names.each do |name|
|
248
|
-
name_sym =
|
252
|
+
name_sym = Atom.to_attrname(name)
|
249
253
|
attr_writer name_sym
|
250
254
|
define_method name_sym do
|
251
255
|
ivar = :"@#{name_sym}"
|
@@ -349,7 +353,7 @@ module Atom
|
|
349
353
|
|
350
354
|
def initialize(name, options = {})
|
351
355
|
@name = name.to_s
|
352
|
-
@attribute =
|
356
|
+
@attribute = Atom.to_attrname(name)
|
353
357
|
@options = options
|
354
358
|
end
|
355
359
|
|
data/spec/atom_spec.rb
CHANGED
@@ -1066,6 +1066,10 @@ describe Atom do
|
|
1066
1066
|
@feed['http://example.org/example', 'title'].should == ['Extension Title']
|
1067
1067
|
end
|
1068
1068
|
|
1069
|
+
it "should find simple extension with dashes in the name" do
|
1070
|
+
@entry["http://example.org/example", 'simple-with-dash'].should == ['Simple with dash Value']
|
1071
|
+
end
|
1072
|
+
|
1069
1073
|
it_should_behave_like 'simple_single_entry.atom attributes'
|
1070
1074
|
|
1071
1075
|
it "should load simple extension 3 xml for entry" do
|
@@ -1082,7 +1086,8 @@ describe Atom do
|
|
1082
1086
|
it "should return namespace elements as a hash" do
|
1083
1087
|
@example_elements.should == {
|
1084
1088
|
'simple1' => ['Simple1 Entry Value'],
|
1085
|
-
'simple2' => ['Simple2', 'Simple2a']
|
1089
|
+
'simple2' => ['Simple2', 'Simple2a'],
|
1090
|
+
'simple-with-dash' => ["Simple with dash Value"]
|
1086
1091
|
}
|
1087
1092
|
|
1088
1093
|
@example2_elements.should == {
|
@@ -1115,6 +1120,7 @@ describe Atom do
|
|
1115
1120
|
before(:all) do
|
1116
1121
|
Atom::Entry.add_extension_namespace :ns_alias, "http://custom.namespace"
|
1117
1122
|
Atom::Entry.elements "ns_alias:property", :class => Atom::Extensions::Property
|
1123
|
+
Atom::Entry.elements "ns_alias:property-with-dash", :class => Atom::Extensions::Property
|
1118
1124
|
@entry = Atom::Entry.load_entry(File.open('spec/fixtures/entry_with_custom_extensions.atom'))
|
1119
1125
|
end
|
1120
1126
|
|
@@ -22,6 +22,7 @@
|
|
22
22
|
<ex:simple1>Simple1 Entry Value</ex:simple1>
|
23
23
|
<ex:simple2>Simple2</ex:simple2>
|
24
24
|
<ex:simple2>Simple2a</ex:simple2>
|
25
|
+
<ex:simple-with-dash>Simple with dash Value</ex:simple-with-dash>
|
25
26
|
<ex2:simple1>Simple Entry Value (NS2)</ex2:simple1>
|
26
27
|
<ex3:simple3><ContinuityOfCareRecord xmlns="urn:astm-org:CCR">Simple Entry Value (NS2)</ContinuityOfCareRecord></ex3:simple3>
|
27
28
|
<category term="atom" scheme="http://example.org" label="Atom" ex:attribute="extension" />
|