xmlcellent 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +20 -0
- data/LICENSE.txt +20 -0
- data/README.mdown +86 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/lib/xmlcellent.rb +4 -0
- data/lib/xmlcellent/format.rb +13 -0
- data/lib/xmlcellent/parser.rb +66 -0
- data/test/helper.rb +17 -0
- data/test/test_xmlcellent.rb +143 -0
- data/vendor/cache/git-1.2.5.gem +0 -0
- data/vendor/cache/jeweler-1.6.4.gem +0 -0
- data/vendor/cache/nokogiri-1.5.0.gem +0 -0
- data/vendor/cache/rake-0.9.2.gem +0 -0
- data/vendor/cache/rcov-0.9.10.gem +0 -0
- data/xmlcellent.gemspec +66 -0
- metadata +113 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
gem "nokogiri", "~> 1.5.0"
|
6
|
+
|
7
|
+
# Add dependencies to develop your gem here.
|
8
|
+
# Include everything needed to run rake, tests, features, etc.
|
9
|
+
group :development do
|
10
|
+
gem "bundler", "~> 1.0.0"
|
11
|
+
gem "jeweler", "~> 1.6.4"
|
12
|
+
gem "rcov", ">= 0"
|
13
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
git (1.2.5)
|
5
|
+
jeweler (1.6.4)
|
6
|
+
bundler (~> 1.0)
|
7
|
+
git (>= 1.2.5)
|
8
|
+
rake
|
9
|
+
nokogiri (1.5.0)
|
10
|
+
rake (0.9.2)
|
11
|
+
rcov (0.9.10)
|
12
|
+
|
13
|
+
PLATFORMS
|
14
|
+
ruby
|
15
|
+
|
16
|
+
DEPENDENCIES
|
17
|
+
bundler (~> 1.0.0)
|
18
|
+
jeweler (~> 1.6.4)
|
19
|
+
nokogiri (~> 1.5.0)
|
20
|
+
rcov
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Zach Pendleton
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.mdown
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# Xmlcellent
|
2
|
+
|
3
|
+
_A more excellent way to parse XML into Ruby models and objects_
|
4
|
+
|
5
|
+
## About
|
6
|
+
|
7
|
+
Imagine you have some XML in your application that you need to turn into
|
8
|
+
a collection of models. You could do it the way you've always done it
|
9
|
+
– loop through some XML, creating models as you go – or you
|
10
|
+
could use Xmlcellent and stop worrying. Xmlcellent: it's a more
|
11
|
+
excellent way to turn XML into something you can use.
|
12
|
+
|
13
|
+
## Getting started
|
14
|
+
|
15
|
+
It's simple: include `gem "xmlcellent"` in your Gemfile, and take a
|
16
|
+
look at this:
|
17
|
+
|
18
|
+
# Sample XML
|
19
|
+
<employees>
|
20
|
+
<employee company="Sterling Cooper">
|
21
|
+
<name>Don Draper</name>
|
22
|
+
<description>
|
23
|
+
<paragraph>Lorem ipsum dolor.</paragraph>
|
24
|
+
<paragraph>Sit amet consecteteur.</paragraph>
|
25
|
+
<paragraph>Adipiscing elit donec odio.</paragraph>
|
26
|
+
</description>
|
27
|
+
<hobby skill="excellent">Philandering</hobby>
|
28
|
+
</employee>
|
29
|
+
</employees>
|
30
|
+
|
31
|
+
# Xmlcellent
|
32
|
+
require "xmlcellent"
|
33
|
+
Xmlcellent::Parser.define_format :employees, Employee, {
|
34
|
+
:finder => "//employee"
|
35
|
+
:lexicon => {
|
36
|
+
:name => "name",
|
37
|
+
:description => "description",
|
38
|
+
:hobby => lambda { |obj|
|
39
|
+
obj.xpath("hobby").text + "Skill: #{obj.xpath("hobby/@skill")}"
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
Xmlcellent::Parser.parse(@xml_string)
|
45
|
+
puts Xmlcellent::Parser.results
|
46
|
+
|
47
|
+
## How to use
|
48
|
+
|
49
|
+
The parser does not need to be instantiated; it can be controlled
|
50
|
+
through two class methods: `parse` and `define_format`. `define_format`
|
51
|
+
is used to describe your XML structure to the Parser. It takes three
|
52
|
+
arguments:
|
53
|
+
|
54
|
+
1. A descriptive name as a hash. e.g. `:employees`;
|
55
|
+
2. A model to map to. e.g. `Employee`; and
|
56
|
+
3. A hash with `:finder` and `:lexicon` keys.
|
57
|
+
|
58
|
+
The `:finder` key is the XPath route to the object in the XML, and the
|
59
|
+
`:lexicon` key is a hash with properties of the model as keys and xpath
|
60
|
+
expressions as values. `:lexicon` will also accept a lambda as a value,
|
61
|
+
which is passed the XML representation of the model and should return
|
62
|
+
the value to set it to. This allows for some data manipulation,
|
63
|
+
concatenation, etc. of the XML.
|
64
|
+
|
65
|
+
`define_format` creates a new class method on `Xmlcellent::Parser`
|
66
|
+
named `parse_format_name`, with `format_name` being the name you
|
67
|
+
passed `define_format`. As a convenience, there is also an
|
68
|
+
`Xmlcellent.parse` method that loops through the the parser's defined
|
69
|
+
formats and runs the first format whose `:finder` returns a match
|
70
|
+
on the given XML.
|
71
|
+
|
72
|
+
## Contributing to xmlcellent
|
73
|
+
|
74
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
75
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
76
|
+
* Fork the project
|
77
|
+
* Start a feature/bugfix branch
|
78
|
+
* Commit and push until you are happy with your contribution
|
79
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
80
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
81
|
+
|
82
|
+
## Copyright
|
83
|
+
|
84
|
+
Copyright (c) 2011 Zach Pendleton. See LICENSE.txt for
|
85
|
+
further details.
|
86
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "xmlcellent"
|
18
|
+
gem.homepage = "http://github.com/zachpendleton/xmlcellent"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{A more xmlcellent way to parse XML into models}
|
21
|
+
gem.description = %Q{An XML parser that uses Nokogiri and dynamic methods to transform XML data into a given Ruby model}
|
22
|
+
gem.email = "zachpendleton@gmail.com"
|
23
|
+
gem.authors = ["Zach Pendleton"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
require 'rcov/rcovtask'
|
36
|
+
Rcov::RcovTask.new do |test|
|
37
|
+
test.libs << 'test'
|
38
|
+
test.pattern = 'test/**/test_*.rb'
|
39
|
+
test.verbose = true
|
40
|
+
test.rcov_opts << '--exclude "gems/*"'
|
41
|
+
end
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "xmlcellent #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/lib/xmlcellent.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
module Xmlcellent
|
2
|
+
# Given a hash with a :finder key and a
|
3
|
+
# :lexicon key, this model stores config
|
4
|
+
# information for a parser.
|
5
|
+
class Format
|
6
|
+
attr_reader :finder, :lexicon
|
7
|
+
|
8
|
+
def initialize(config)
|
9
|
+
@finder = config[:finder]
|
10
|
+
@lexicon = config[:lexicon]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require "nokogiri"
|
2
|
+
|
3
|
+
module Xmlcellent
|
4
|
+
# A shortcut method for Xmlcellent::Parser.parse()
|
5
|
+
def self.parse(doc)
|
6
|
+
Parser.parse(doc)
|
7
|
+
end
|
8
|
+
|
9
|
+
# Handles the parsing of XML data using Xmlcellent::Format
|
10
|
+
# objects.
|
11
|
+
class Parser
|
12
|
+
class << self
|
13
|
+
attr_accessor :formats
|
14
|
+
|
15
|
+
# Erases all existing formats
|
16
|
+
def delete_formats!
|
17
|
+
@formats = {}
|
18
|
+
end
|
19
|
+
|
20
|
+
# Given a string of XML, this method loops through the
|
21
|
+
# defined Formats and, if it finds a match, calls that
|
22
|
+
# method to parse the XML into objects.
|
23
|
+
def parse(doc)
|
24
|
+
document = Nokogiri::XML(doc).remove_namespaces!
|
25
|
+
@formats.each do |key, format|
|
26
|
+
if document.xpath(format.finder).length > 0
|
27
|
+
return self.send("parse_#{key}".to_sym, doc)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
raise "Error: Parser not found!"
|
31
|
+
end
|
32
|
+
|
33
|
+
# Creates a format on the Xmlcellent::Parser object to
|
34
|
+
# be used to convert XML to models.
|
35
|
+
def define_format(name, model = nil, config = {})
|
36
|
+
@formats ||= {}
|
37
|
+
raise "Format already exists!" if @formats.has_key? name
|
38
|
+
@formats[name] = Format.new(config)
|
39
|
+
|
40
|
+
# This ugly piece of code is used to dynamically generate
|
41
|
+
# class methods in a way that Ruby 1.8 understands.
|
42
|
+
singleton = class << self; self; end
|
43
|
+
singleton.instance_eval do
|
44
|
+
define_method("parse_#{name.to_s}".to_sym) do |doc|
|
45
|
+
document = doc.class == Nokogiri::XML::Document ?
|
46
|
+
doc :
|
47
|
+
Nokogiri::XML(doc).remove_namespaces!
|
48
|
+
results = []
|
49
|
+
|
50
|
+
document.xpath(@formats[name].finder).each do |obj|
|
51
|
+
m = model.new
|
52
|
+
@formats[name].lexicon.each do |key, path|
|
53
|
+
next if path.nil? # fail silently if given a bad path
|
54
|
+
|
55
|
+
value = path.class == Proc ? path.call(obj) : obj.xpath(path).text
|
56
|
+
m.send("#{key.to_s}=".to_sym, value)
|
57
|
+
end
|
58
|
+
results << m
|
59
|
+
end
|
60
|
+
results
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
require 'xmlcellent'
|
15
|
+
|
16
|
+
class Test::Unit::TestCase
|
17
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class Item
|
4
|
+
attr_accessor :name, :summary, :color, :supplier
|
5
|
+
end
|
6
|
+
|
7
|
+
class TestXmlcellent < Test::Unit::TestCase
|
8
|
+
def setup
|
9
|
+
@xml ||= <<-END
|
10
|
+
<items>
|
11
|
+
<item supplier="Dunder Mifflin">
|
12
|
+
<name>Item one</name>
|
13
|
+
<description color="red">Lorem ipsum dolor</description>
|
14
|
+
<summary>
|
15
|
+
<paragraph>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</paragraph>
|
16
|
+
<paragraph>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</paragraph>
|
17
|
+
<paragraph>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</paragraph>
|
18
|
+
</summary>
|
19
|
+
</item>
|
20
|
+
<item supplier="Plainview Medical">
|
21
|
+
<name>Item two</name>
|
22
|
+
<description color="blue">Lorem ipsum dolor</description>
|
23
|
+
<summary>
|
24
|
+
<paragraph>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</paragraph>
|
25
|
+
<paragraph>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</paragraph>
|
26
|
+
<paragraph>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</paragraph>
|
27
|
+
</summary>
|
28
|
+
</item>
|
29
|
+
<item supplier="Bluth Company">
|
30
|
+
<name>Item three</name>
|
31
|
+
<description color="yellow">Lorem ipsum dolor</description>
|
32
|
+
<summary>
|
33
|
+
<paragraph>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</paragraph>
|
34
|
+
<paragraph>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</paragraph>
|
35
|
+
<paragraph>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</paragraph>
|
36
|
+
</summary>
|
37
|
+
</item>
|
38
|
+
|
39
|
+
END
|
40
|
+
end
|
41
|
+
def test_should_create_a_new_parser_on_call_to_define_parser
|
42
|
+
Xmlcellent::Parser.define_format :test_format
|
43
|
+
assert Xmlcellent::Parser.singleton_methods.include? :parse_test_format
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_define_parser_should_create_a_new_format_object
|
47
|
+
Xmlcellent::Parser.define_format :test_format
|
48
|
+
assert Xmlcellent::Parser.formats[:test_format].class == Xmlcellent::Format
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_define_parser_should_add_new_format_to_formats_variable
|
52
|
+
Xmlcellent::Parser.define_format :test_format
|
53
|
+
assert Xmlcellent::Parser.formats.has_key? :test_format
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_define_parser_should_raise_an_error_on_duplicate_key
|
57
|
+
Xmlcellent::Parser.define_format :test_format
|
58
|
+
assert_raise(RuntimeError) do
|
59
|
+
Xmlcellent::Parser.define_format :test_format
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_should_parse_xml_when_passed_a_string_of_xml
|
64
|
+
Xmlcellent::Parser.define_format :test_format, Item, {
|
65
|
+
:finder => "//item",
|
66
|
+
:lexicon => {
|
67
|
+
:name => "name"
|
68
|
+
}
|
69
|
+
}
|
70
|
+
result = Xmlcellent::Parser.parse_test_format(@xml)
|
71
|
+
assert_equal result.length, 3
|
72
|
+
assert_equal result[0].name, "Item one"
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_should_parse_xml_by_applying_a_lambda
|
76
|
+
Xmlcellent::Parser.define_format :test_format, Item, {
|
77
|
+
:finder => "//item",
|
78
|
+
:lexicon => {
|
79
|
+
:summary => lambda { |obj|
|
80
|
+
obj.xpath("summary/paragraph").inject("") { |c, p| c + p.text }
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}
|
84
|
+
result = Xmlcellent::Parser.parse_test_format(@xml)
|
85
|
+
assert_equal result[0].summary.scan(/Lorem/).length, 3
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_should_parse_xml_by_reading_attributes
|
89
|
+
Xmlcellent::Parser.define_format :test_format, Item, {
|
90
|
+
:finder => "//item",
|
91
|
+
:lexicon => {
|
92
|
+
:color => "description/@color",
|
93
|
+
:supplier => "@supplier"
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
result = Xmlcellent::Parser.parse_test_format(@xml)
|
98
|
+
assert_equal result[0].color, "red"
|
99
|
+
assert_equal result[0].supplier, "Dunder Mifflin"
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_should_delete_all_formats_on_call_to_delete_formats
|
103
|
+
Xmlcellent::Parser.define_format :test_format, Item, {}
|
104
|
+
Xmlcellent::Parser.delete_formats!
|
105
|
+
assert_equal Xmlcellent::Parser.formats.length, 0
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_should_find_proper_format_using_the_finder_attribute
|
109
|
+
Xmlcellent::Parser.define_format :format_one, Item, {
|
110
|
+
:finder => "//item",
|
111
|
+
:lexicon => {
|
112
|
+
:name => "name"
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
Xmlcellent::Parser.define_format :format_two, Item, {
|
117
|
+
:finder => "//thing",
|
118
|
+
:lexicon => {
|
119
|
+
:name => "thing_name"
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
result = Xmlcellent::Parser.parse(@xml)
|
124
|
+
assert_equal result.length, 3
|
125
|
+
assert_equal result[0].name, "Item one"
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_should_call_parser_parse_on_call_to_parse_shortcut
|
129
|
+
Xmlcellent::Parser.define_format :test_format, Item, {
|
130
|
+
:finder => "//item",
|
131
|
+
:lexicon => {
|
132
|
+
:name => "name"
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
result = Xmlcellent.parse(@xml)
|
137
|
+
assert_equal result.length, 3
|
138
|
+
end
|
139
|
+
|
140
|
+
def teardown
|
141
|
+
Xmlcellent::Parser.delete_formats!
|
142
|
+
end
|
143
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/xmlcellent.gemspec
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{xmlcellent}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = [%q{Zach Pendleton}]
|
12
|
+
s.date = %q{2011-08-24}
|
13
|
+
s.description = %q{An XML parser that uses Nokogiri and dynamic methods to transform XML data into a given Ruby model}
|
14
|
+
s.email = %q{zachpendleton@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.mdown"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.mdown",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"lib/xmlcellent.rb",
|
28
|
+
"lib/xmlcellent/format.rb",
|
29
|
+
"lib/xmlcellent/parser.rb",
|
30
|
+
"test/helper.rb",
|
31
|
+
"test/test_xmlcellent.rb",
|
32
|
+
"vendor/cache/git-1.2.5.gem",
|
33
|
+
"vendor/cache/jeweler-1.6.4.gem",
|
34
|
+
"vendor/cache/nokogiri-1.5.0.gem",
|
35
|
+
"vendor/cache/rake-0.9.2.gem",
|
36
|
+
"vendor/cache/rcov-0.9.10.gem",
|
37
|
+
"xmlcellent.gemspec"
|
38
|
+
]
|
39
|
+
s.homepage = %q{http://github.com/zachpendleton/xmlcellent}
|
40
|
+
s.licenses = [%q{MIT}]
|
41
|
+
s.require_paths = [%q{lib}]
|
42
|
+
s.rubygems_version = %q{1.8.7}
|
43
|
+
s.summary = %q{A more xmlcellent way to parse XML into models}
|
44
|
+
|
45
|
+
if s.respond_to? :specification_version then
|
46
|
+
s.specification_version = 3
|
47
|
+
|
48
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
|
+
s.add_runtime_dependency(%q<nokogiri>, ["~> 1.5.0"])
|
50
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
51
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
52
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
53
|
+
else
|
54
|
+
s.add_dependency(%q<nokogiri>, ["~> 1.5.0"])
|
55
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
56
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
57
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
58
|
+
end
|
59
|
+
else
|
60
|
+
s.add_dependency(%q<nokogiri>, ["~> 1.5.0"])
|
61
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
62
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
63
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xmlcellent
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Zach Pendleton
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-08-24 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: nokogiri
|
16
|
+
requirement: &70362671229000 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.5.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70362671229000
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: bundler
|
27
|
+
requirement: &70362671227680 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.0
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70362671227680
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: jeweler
|
38
|
+
requirement: &70362671226540 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.6.4
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70362671226540
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rcov
|
49
|
+
requirement: &70362671225500 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70362671225500
|
58
|
+
description: An XML parser that uses Nokogiri and dynamic methods to transform XML
|
59
|
+
data into a given Ruby model
|
60
|
+
email: zachpendleton@gmail.com
|
61
|
+
executables: []
|
62
|
+
extensions: []
|
63
|
+
extra_rdoc_files:
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.mdown
|
66
|
+
files:
|
67
|
+
- .document
|
68
|
+
- Gemfile
|
69
|
+
- Gemfile.lock
|
70
|
+
- LICENSE.txt
|
71
|
+
- README.mdown
|
72
|
+
- Rakefile
|
73
|
+
- VERSION
|
74
|
+
- lib/xmlcellent.rb
|
75
|
+
- lib/xmlcellent/format.rb
|
76
|
+
- lib/xmlcellent/parser.rb
|
77
|
+
- test/helper.rb
|
78
|
+
- test/test_xmlcellent.rb
|
79
|
+
- vendor/cache/git-1.2.5.gem
|
80
|
+
- vendor/cache/jeweler-1.6.4.gem
|
81
|
+
- vendor/cache/nokogiri-1.5.0.gem
|
82
|
+
- vendor/cache/rake-0.9.2.gem
|
83
|
+
- vendor/cache/rcov-0.9.10.gem
|
84
|
+
- xmlcellent.gemspec
|
85
|
+
homepage: http://github.com/zachpendleton/xmlcellent
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ! '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
segments:
|
99
|
+
- 0
|
100
|
+
hash: 1709074531614176846
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ! '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 1.8.7
|
110
|
+
signing_key:
|
111
|
+
specification_version: 3
|
112
|
+
summary: A more xmlcellent way to parse XML into models
|
113
|
+
test_files: []
|