geoffgarside-demolisher 0.1.0 → 0.2.0

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
data/demolisher.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{demolisher}
5
- s.version = "0.1.0"
5
+ s.version = "0.2.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Geoff Garside"]
9
- s.date = %q{2009-06-05}
9
+ s.date = %q{2009-06-07}
10
10
  s.email = %q{geoff@geoffgarside.co.uk}
11
11
  s.extra_rdoc_files = [
12
12
  "LICENSE",
data/lib/demolisher.rb CHANGED
@@ -4,7 +4,10 @@ module Demolisher
4
4
  # Demolish an XML file or XML::Parser object.
5
5
  def self.demolish(file_or_xml_parser)
6
6
  file_or_xml_parser = XML::Parser.file(file_or_xml_parser) if file_or_xml_parser.kind_of?(String)
7
- Node.new(file_or_xml_parser.parse, true)
7
+ node = Node.new(file_or_xml_parser.parse, true)
8
+
9
+ yield node if block_given?
10
+ node
8
11
  end
9
12
  class Node
10
13
  # Creates a new Node object. If the node is not the root node then
@@ -4,11 +4,12 @@ class DemolisherTest < Test::Unit::TestCase
4
4
  context "Demolished XML file" do
5
5
  setup do
6
6
  @people = Array.new
7
- xml = Demolisher.demolish(File.dirname(__FILE__) +'/test.xml')
8
- xml.addressbook do
9
- xml.person do
10
- @people << {:firstname => xml.firstname.to_s, :lastname => xml.lastname.to_s,
11
- :active => xml.active?, :email => xml.contact.email.to_s}
7
+ Demolisher.demolish(File.dirname(__FILE__) +'/test.xml') do |xml|
8
+ xml.addressbook do
9
+ xml.person do
10
+ @people << {:firstname => xml.firstname.to_s, :lastname => xml.lastname.to_s,
11
+ :active => xml.active?, :email => xml.contact.email.to_s}
12
+ end
12
13
  end
13
14
  end
14
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geoffgarside-demolisher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geoff Garside
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-05 00:00:00 -07:00
12
+ date: 2009-06-07 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency