ratom 0.6.6 → 0.6.7

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,11 @@
1
+ == 0.6.7
2
+
3
+ * Handle dashes in extension names.
4
+
5
+ == 0.6.6
6
+
7
+ * Added support for absoluting relative uris using xml:base. [Greg Campbell]
8
+
1
9
  == 0.6.5
2
10
 
3
11
  * Fixed missing version.rb, now loads version.yml. [Greg Campbell]
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- :patch: 6
2
+ :patch: 7
3
3
  :major: 0
4
4
  :build:
5
5
  :minor: 6
@@ -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
- name.to_s.sub(/:/, '_').to_sym
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 name.to_s.sub(/:/, '_').to_sym
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 = name.to_s.sub(/:/, '_').to_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 = name.to_s.sub(/:/, '_')
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
 
@@ -4,4 +4,5 @@
4
4
  <link rel='self' type='application/atom+xml' href='https://custom.namespace/id/1'/>
5
5
  <custom:property name='foo' value='bar'/>
6
6
  <custom:property name='baz' value='bat'/>
7
+ <custom:property-with-dash name="blag" value="blurgh" />
7
8
  </entry>
@@ -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" />
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 6
8
- - 6
9
- version: 0.6.6
8
+ - 7
9
+ version: 0.6.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Peerworks