kind_dom 0.9.8 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
data/lib/kind_dom/base.rb CHANGED
@@ -32,7 +32,7 @@ module KindDom
32
32
  #
33
33
  class Base
34
34
 
35
- attr_reader :dom
35
+ attr_accessor :dom
36
36
  attr_accessor :find_cache
37
37
 
38
38
  # A new KindDom object may be created from raw XML [string] data, or
@@ -40,6 +40,10 @@ module KindDom
40
40
  #
41
41
  # Caches intermediate found values, before yielding to the optional block.
42
42
  # Disable the cache with opt `:find_cache => false` or set #find_cache to false
43
+ #
44
+ # If you change the XML document through the #dom accessor, then you must
45
+ # disable or manually sweep the cache to avoid stale XPath results.
46
+ #
43
47
  def initialize(xml_in=nil, opts={})
44
48
  unless xml_in.nil?
45
49
  case
@@ -55,6 +59,8 @@ module KindDom
55
59
  end
56
60
  @find_cache = {} if opts[:find_cache].nil? ? true : opts[:find_cache]
57
61
  rescue XML::Parser::ParseError
62
+ ensure
63
+ return self
58
64
  end
59
65
 
60
66
  # Retrieve the contents of the first node or attribute selected by the XPath;
@@ -32,6 +32,10 @@ class KindDomTest < Test::Unit::TestCase
32
32
  assert_equal 'Photos from marsi', @@test_doc.content_for('channel/title')
33
33
  end
34
34
 
35
+ def test_content_for_attribute__success
36
+ assert_equal 'image/jpeg', @@test_doc.content_for('channel/item/media:content/@type')
37
+ end
38
+
35
39
  def test_content_for__success_with_closure
36
40
  assert_equal 'PHOTOS FROM MARSI', @@test_doc.content_for('channel/title') {|content| content.upcase}
37
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kind_dom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.8
4
+ version: 0.9.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mars Hall
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-08-20 00:00:00 -07:00
12
+ date: 2008-09-25 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -26,9 +26,9 @@ dependencies:
26
26
  version_requirement:
27
27
  version_requirements: !ruby/object:Gem::Requirement
28
28
  requirements:
29
- - - ">="
29
+ - - "="
30
30
  - !ruby/object:Gem::Version
31
- version: 0.5.2.0
31
+ version: 0.5.4
32
32
  version:
33
33
  description:
34
34
  email: mars@scoutlabs.com