hippo_xml_parser 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +35 -0
- data/.rspec +3 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/hippo_xml_parser.gemspec +25 -0
- data/lib/hippo_xml_parser.rb +16 -0
- data/lib/hippo_xml_parser/article.rb +47 -0
- data/lib/hippo_xml_parser/body.rb +11 -0
- data/lib/hippo_xml_parser/crawler.rb +44 -0
- data/lib/hippo_xml_parser/document.rb +41 -0
- data/lib/hippo_xml_parser/node.rb +4 -0
- data/lib/hippo_xml_parser/property.rb +18 -0
- data/lib/hippo_xml_parser/version.rb +3 -0
- data/spec/fixtures/example.xml +230 -0
- data/spec/hippo_xml_parser_spec.rb +30 -0
- data/spec/spec_helper.rb +9 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a3fe744427333e08f51b9ea0db75633266a7a4fd
|
4
|
+
data.tar.gz: 4d5b6ab0280f4579a1aee3c79d72b4a826e6da3f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5c0e9460d92b9e6f03df0d9f819c4b2a7697a9577770a8d2db7c7ffeb1b4882e0f99f405987e2e0aadb195cb10ac22dc052264ed01a19384798c2bf4ac73bbc7
|
7
|
+
data.tar.gz: 8c48c1e31248e6dc18ec4445c18444112701ec5eb703908e09e5c80991c72e21bd5eb8fa5a62be64820a4f6a0fe4b7e291b2f3c3b0d794e97861c1b007e57cb5
|
data/.gitignore
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
Gemfile.lock
|
12
|
+
|
13
|
+
## Specific to RubyMotion:
|
14
|
+
.dat*
|
15
|
+
.repl_history
|
16
|
+
build/
|
17
|
+
|
18
|
+
## Documentation cache and generated files:
|
19
|
+
/.yardoc/
|
20
|
+
/_yardoc/
|
21
|
+
/doc/
|
22
|
+
/rdoc/
|
23
|
+
|
24
|
+
## Environment normalisation:
|
25
|
+
/.bundle/
|
26
|
+
/lib/bundler/man/
|
27
|
+
|
28
|
+
# for a library or gem, you might want to ignore these files since the code is
|
29
|
+
# intended to run in multiple environments; otherwise, check them in:
|
30
|
+
# Gemfile.lock
|
31
|
+
# .ruby-version
|
32
|
+
# .ruby-gemset
|
33
|
+
|
34
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
35
|
+
.rvmrc
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Money Advice Service
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Jared Fraser
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# HippoXmlParser
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'hippo_xml_parser'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install hippo_xml_parser
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/hippo_xml_parser/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hippo_xml_parser/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "hippo_xml_parser"
|
8
|
+
spec.version = HippoXmlParser::VERSION
|
9
|
+
spec.authors = ["Jared Fraser"]
|
10
|
+
spec.email = ["dev@jsf.io"]
|
11
|
+
spec.summary = %q{Parser for Hippo XML exports}
|
12
|
+
spec.description = %q{}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "nokogiri"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'time'
|
3
|
+
|
4
|
+
require 'hippo_xml_parser/crawler'
|
5
|
+
require 'hippo_xml_parser/document'
|
6
|
+
require 'hippo_xml_parser/node'
|
7
|
+
require 'hippo_xml_parser/property'
|
8
|
+
require 'hippo_xml_parser/article'
|
9
|
+
require 'hippo_xml_parser/body'
|
10
|
+
require 'hippo_xml_parser/version'
|
11
|
+
|
12
|
+
module HippoXmlParser
|
13
|
+
def self.parse(doc)
|
14
|
+
Crawler.new(Nokogiri::XML(doc)).all
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module HippoXmlParser
|
2
|
+
class Article < Document
|
3
|
+
def body
|
4
|
+
Body.new(find_node('contentauthoringwebsite:body').doc).to_s
|
5
|
+
end
|
6
|
+
|
7
|
+
def created_at
|
8
|
+
Time.parse(fetch('hippostdpubwf:creationDate'))
|
9
|
+
end
|
10
|
+
|
11
|
+
def created_by
|
12
|
+
fetch('hippostdpubwf:createdBy')
|
13
|
+
end
|
14
|
+
|
15
|
+
def updated_at
|
16
|
+
Time.parse(fetch('hippostdpubwf:lastModificationDate'))
|
17
|
+
end
|
18
|
+
|
19
|
+
def updated_by
|
20
|
+
fetch('hippostdpubwf:lastModifiedBy')
|
21
|
+
end
|
22
|
+
|
23
|
+
def state
|
24
|
+
fetch('hippostd:state')
|
25
|
+
end
|
26
|
+
|
27
|
+
def title
|
28
|
+
fetch('contentauthoringwebsite:title')
|
29
|
+
end
|
30
|
+
|
31
|
+
def preview
|
32
|
+
fetch('contentauthoringwebsite:preview')
|
33
|
+
end
|
34
|
+
|
35
|
+
def id
|
36
|
+
doc['sv:name']
|
37
|
+
end
|
38
|
+
|
39
|
+
def locale
|
40
|
+
fetch('hippotranslation:locale')
|
41
|
+
end
|
42
|
+
|
43
|
+
def inspect
|
44
|
+
"#<Article id=#{id} state=#{state} length=#{body.length}>"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module HippoXmlParser
|
2
|
+
class Crawler
|
3
|
+
TYPES = [
|
4
|
+
'contentauthoringwebsite:Guide',
|
5
|
+
'contentauthoringwebsite:ActionPlan',
|
6
|
+
'contentauthoringwebsite:ToolPage',
|
7
|
+
'contentauthoringwebsite:StaticPage',
|
8
|
+
'contentauthoringwebsite:News'
|
9
|
+
]
|
10
|
+
|
11
|
+
attr_reader :types
|
12
|
+
|
13
|
+
def initialize(doc, types=TYPES)
|
14
|
+
@doc = doc
|
15
|
+
@types = types
|
16
|
+
end
|
17
|
+
|
18
|
+
def nodes(doc)
|
19
|
+
doc.children.select {|e| e.name == "node" }
|
20
|
+
end
|
21
|
+
|
22
|
+
def type?(el, names)
|
23
|
+
el.children.map do |e|
|
24
|
+
if e.name == "property" && e["sv:name"] == "jcr:primaryType"
|
25
|
+
|
26
|
+
e if e.children.select {|x| x.name == "value" && Array(names).include?(x.children.to_s) }.any?
|
27
|
+
end
|
28
|
+
end.flatten.compact.first
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
def crawl(doc)
|
33
|
+
if type?(doc, types)
|
34
|
+
Article.new(doc)
|
35
|
+
else
|
36
|
+
doc.children.map {|e| crawl(e) }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def all
|
41
|
+
crawl( nodes(@doc).first ).flatten
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module HippoXmlParser
|
2
|
+
class Document
|
3
|
+
attr_reader :doc, :namespace, :name
|
4
|
+
def initialize(doc)
|
5
|
+
@namespace, @name = doc["sv:name"].split(':')
|
6
|
+
@doc = doc
|
7
|
+
end
|
8
|
+
|
9
|
+
def [](key)
|
10
|
+
doc[key]
|
11
|
+
end
|
12
|
+
|
13
|
+
def type
|
14
|
+
el.children.map do |e|
|
15
|
+
if e.name == "property" && e["sv:name"] == "jcr:primaryType"
|
16
|
+
e if e.children.select {|x| x.name == "value" && x.children.to_s == name }.any?
|
17
|
+
end
|
18
|
+
end.flatten.compact.first
|
19
|
+
end
|
20
|
+
|
21
|
+
def properties
|
22
|
+
@_properties ||= doc.children.map {|e| Property.new(e) if e.name == "property" }.compact.flatten
|
23
|
+
end
|
24
|
+
|
25
|
+
def nodes
|
26
|
+
@_nodes ||= doc.children.map {|e| Node.new(e) if e.name == "node" }.compact.flatten
|
27
|
+
end
|
28
|
+
|
29
|
+
def find_node(name)
|
30
|
+
nodes.find {|e| e['sv:name'] == name }
|
31
|
+
end
|
32
|
+
|
33
|
+
def find_property(name)
|
34
|
+
properties.find {|e| e['sv:name'] == name }
|
35
|
+
end
|
36
|
+
|
37
|
+
def fetch(name)
|
38
|
+
find_property(name).value
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module HippoXmlParser
|
2
|
+
class Property
|
3
|
+
attr_accessor :namespace, :name, :value, :doc
|
4
|
+
def initialize(doc)
|
5
|
+
@doc = doc
|
6
|
+
@namespace, @name = doc["sv:name"].split(':')
|
7
|
+
@value = doc.children.detect {|x| x.name == "value" }.children.to_s rescue nil
|
8
|
+
end
|
9
|
+
|
10
|
+
def [](key)
|
11
|
+
doc[key]
|
12
|
+
end
|
13
|
+
|
14
|
+
def inspect
|
15
|
+
"#<Property name=#{name.inspect} value=#{value.inspect}>"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,230 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<sv:node xmlns:hippostd="http://www.onehippo.org/jcr/hippostd/nt/2.0" xmlns:hippotranslation="http://www.onehippo.org/jcr/hippotranslation/nt/1.0" xmlns:hippo="http://www.onehippo.org/jcr/hippo/nt/2.0.4" xmlns:hippogallerypicker="http://www.hippoecm.org/hippogallerypicker/nt/2.0" xmlns:contentauthoringwebsite="http://www.onehippo.org/contentauthoringwebsite/nt/1.0" xmlns:sv="http://www.jcp.org/jcr/sv/1.0" sv:name="contentauthoringwebsite">
|
3
|
+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
|
4
|
+
<sv:value>hippostd:folder</sv:value>
|
5
|
+
</sv:property>
|
6
|
+
<sv:property sv:name="jcr:mixinTypes" sv:type="Name" sv:multiple="true">
|
7
|
+
<sv:value>hippo:harddocument</sv:value>
|
8
|
+
<sv:value>hippotranslation:translated</sv:value>
|
9
|
+
</sv:property>
|
10
|
+
<sv:property sv:name="jcr:uuid" sv:type="String">
|
11
|
+
<sv:value>996bcac5-86cf-49b5-a7a3-16a74863e814</sv:value>
|
12
|
+
</sv:property>
|
13
|
+
<sv:property sv:name="hippo:related___pathreference" sv:type="String"/>
|
14
|
+
<sv:property sv:name="hippostd:foldertype" sv:type="String" sv:multiple="true">
|
15
|
+
<sv:value>new-translated-folder</sv:value>
|
16
|
+
<sv:value>new-document</sv:value>
|
17
|
+
</sv:property>
|
18
|
+
<sv:property sv:name="hippotranslation:id" sv:type="String">
|
19
|
+
<sv:value>996bcac5-86cf-49b5-a7a3-16a74863e814</sv:value>
|
20
|
+
</sv:property>
|
21
|
+
<sv:property sv:name="hippotranslation:locale" sv:type="String">
|
22
|
+
<sv:value>en</sv:value>
|
23
|
+
</sv:property>
|
24
|
+
<sv:node sv:name="borrowing">
|
25
|
+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
|
26
|
+
<sv:value>hippostd:folder</sv:value>
|
27
|
+
</sv:property>
|
28
|
+
<sv:property sv:name="jcr:mixinTypes" sv:type="Name" sv:multiple="true">
|
29
|
+
<sv:value>hippo:harddocument</sv:value>
|
30
|
+
<sv:value>hippotranslation:translated</sv:value>
|
31
|
+
<sv:value>hippo:translated</sv:value>
|
32
|
+
</sv:property>
|
33
|
+
<sv:property sv:name="jcr:uuid" sv:type="String">
|
34
|
+
<sv:value>5acf6c2f-6491-4953-b27a-8b9e33922bf6</sv:value>
|
35
|
+
</sv:property>
|
36
|
+
<sv:property sv:name="hippo:related___pathreference" sv:type="String"/>
|
37
|
+
<sv:property sv:name="hippostd:foldertype" sv:type="String" sv:multiple="true">
|
38
|
+
<sv:value>new-translated-folder</sv:value>
|
39
|
+
<sv:value>new-document</sv:value>
|
40
|
+
</sv:property>
|
41
|
+
<sv:property sv:name="hippotranslation:id" sv:type="String">
|
42
|
+
<sv:value>618acf7d-8c56-4a93-a1f2-7730de607306</sv:value>
|
43
|
+
</sv:property>
|
44
|
+
<sv:property sv:name="hippotranslation:locale" sv:type="String">
|
45
|
+
<sv:value>en</sv:value>
|
46
|
+
</sv:property>
|
47
|
+
<sv:node sv:name="before-you-borrow-money">
|
48
|
+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
|
49
|
+
<sv:value>hippostd:folder</sv:value>
|
50
|
+
</sv:property>
|
51
|
+
<sv:property sv:name="jcr:mixinTypes" sv:type="Name" sv:multiple="true">
|
52
|
+
<sv:value>hippo:harddocument</sv:value>
|
53
|
+
<sv:value>hippotranslation:translated</sv:value>
|
54
|
+
<sv:value>hippo:translated</sv:value>
|
55
|
+
</sv:property>
|
56
|
+
<sv:property sv:name="jcr:uuid" sv:type="String">
|
57
|
+
<sv:value>388d85ba-4abf-479c-b731-cfa5d4dc68cc</sv:value>
|
58
|
+
</sv:property>
|
59
|
+
<sv:property sv:name="hippo:related___pathreference" sv:type="String"/>
|
60
|
+
<sv:property sv:name="hippostd:foldertype" sv:type="String" sv:multiple="true">
|
61
|
+
<sv:value>new-translated-folder</sv:value>
|
62
|
+
<sv:value>new-document</sv:value>
|
63
|
+
</sv:property>
|
64
|
+
<sv:property sv:name="hippotranslation:id" sv:type="String">
|
65
|
+
<sv:value>3f4e6bf0-fa28-44ec-92e5-00240e6843ee</sv:value>
|
66
|
+
</sv:property>
|
67
|
+
<sv:property sv:name="hippotranslation:locale" sv:type="String">
|
68
|
+
<sv:value>en</sv:value>
|
69
|
+
</sv:property>
|
70
|
+
<sv:node sv:name="hippotranslation:translations">
|
71
|
+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
|
72
|
+
<sv:value>hippotranslation:translations</sv:value>
|
73
|
+
</sv:property>
|
74
|
+
</sv:node>
|
75
|
+
<sv:node sv:name="hippo:translation">
|
76
|
+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
|
77
|
+
<sv:value>hippo:translation</sv:value>
|
78
|
+
</sv:property>
|
79
|
+
<sv:property sv:name="hippo:language" sv:type="String">
|
80
|
+
<sv:value/>
|
81
|
+
</sv:property>
|
82
|
+
<sv:property sv:name="hippo:message" sv:type="String">
|
83
|
+
<sv:value>Before you borrow money</sv:value>
|
84
|
+
</sv:property>
|
85
|
+
</sv:node>
|
86
|
+
<sv:node sv:name="do-you-need-to-borrow-money">
|
87
|
+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
|
88
|
+
<sv:value>hippo:handle</sv:value>
|
89
|
+
</sv:property>
|
90
|
+
<sv:property sv:name="jcr:mixinTypes" sv:type="Name" sv:multiple="true">
|
91
|
+
<sv:value>hippo:hardhandle</sv:value>
|
92
|
+
<sv:value>hippo:translated</sv:value>
|
93
|
+
</sv:property>
|
94
|
+
<sv:property sv:name="jcr:uuid" sv:type="String">
|
95
|
+
<sv:value>6744b4f5-a0d5-49ca-bbe0-e65a52c19e68</sv:value>
|
96
|
+
</sv:property>
|
97
|
+
<sv:node sv:name="hippo:translation">
|
98
|
+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
|
99
|
+
<sv:value>hippo:translation</sv:value>
|
100
|
+
</sv:property>
|
101
|
+
<sv:property sv:name="hippo:language" sv:type="String">
|
102
|
+
<sv:value/>
|
103
|
+
</sv:property>
|
104
|
+
<sv:property sv:name="hippo:message" sv:type="String">
|
105
|
+
<sv:value>B001 Do you need to borrow money?</sv:value>
|
106
|
+
</sv:property>
|
107
|
+
</sv:node>
|
108
|
+
<sv:node sv:name="do-you-need-to-borrow-money">
|
109
|
+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
|
110
|
+
<sv:value>contentauthoringwebsite:Guide</sv:value>
|
111
|
+
</sv:property>
|
112
|
+
<sv:property sv:name="jcr:mixinTypes" sv:type="Name" sv:multiple="true">
|
113
|
+
<sv:value>hippo:harddocument</sv:value>
|
114
|
+
<sv:value>hippotranslation:translated</sv:value>
|
115
|
+
</sv:property>
|
116
|
+
<sv:property sv:name="jcr:uuid" sv:type="String">
|
117
|
+
<sv:value>86291390-27c1-46fa-a9de-de843c957548</sv:value>
|
118
|
+
</sv:property>
|
119
|
+
<sv:property sv:name="contentauthoringwebsite:preview" sv:type="String">
|
120
|
+
<sv:value>Planning a big purchase or need some extra cash? Borrowing might seem like the obvious solution but there could be a better option</sv:value>
|
121
|
+
</sv:property>
|
122
|
+
<sv:property sv:name="contentauthoringwebsite:title" sv:type="String">
|
123
|
+
<sv:value>Do you need to borrow money?</sv:value>
|
124
|
+
</sv:property>
|
125
|
+
<sv:property sv:name="hippo:availability" sv:type="String" sv:multiple="true">
|
126
|
+
<sv:value>live</sv:value>
|
127
|
+
<sv:value>preview</sv:value>
|
128
|
+
</sv:property>
|
129
|
+
<sv:property sv:name="hippo:related___pathreference" sv:type="String">
|
130
|
+
<sv:value>contentauthoringwebsite/borrowing/before-you-borrow-money/do-you-need-to-borrow-money</sv:value>
|
131
|
+
</sv:property>
|
132
|
+
<sv:property sv:name="hippostd:holder" sv:type="String">
|
133
|
+
<sv:value>Alex</sv:value>
|
134
|
+
</sv:property>
|
135
|
+
<sv:property sv:name="hippostd:state" sv:type="String">
|
136
|
+
<sv:value>published</sv:value>
|
137
|
+
</sv:property>
|
138
|
+
<sv:property sv:name="hippostd:stateSummary" sv:type="String">
|
139
|
+
<sv:value>live</sv:value>
|
140
|
+
</sv:property>
|
141
|
+
<sv:property sv:name="hippostdpubwf:createdBy" sv:type="String">
|
142
|
+
<sv:value>julian</sv:value>
|
143
|
+
</sv:property>
|
144
|
+
<sv:property sv:name="hippostdpubwf:creationDate" sv:type="Date">
|
145
|
+
<sv:value>2012-05-31T10:14:35.168Z</sv:value>
|
146
|
+
</sv:property>
|
147
|
+
<sv:property sv:name="hippostdpubwf:lastModificationDate" sv:type="Date">
|
148
|
+
<sv:value>2014-05-27T11:16:32.003Z</sv:value>
|
149
|
+
</sv:property>
|
150
|
+
<sv:property sv:name="hippostdpubwf:lastModifiedBy" sv:type="String">
|
151
|
+
<sv:value>jlaney</sv:value>
|
152
|
+
</sv:property>
|
153
|
+
<sv:property sv:name="hippostdpubwf:publicationDate" sv:type="Date">
|
154
|
+
<sv:value>2014-05-27T11:16:35.019Z</sv:value>
|
155
|
+
</sv:property>
|
156
|
+
<sv:property sv:name="hippotaxonomy:keys" sv:type="String" sv:multiple="true">
|
157
|
+
<sv:value>before-you-borrow-money</sv:value>
|
158
|
+
<sv:value>money-worries</sv:value>
|
159
|
+
</sv:property>
|
160
|
+
<sv:property sv:name="hippotranslation:id" sv:type="String">
|
161
|
+
<sv:value>7aa69e4e-1033-4e33-a625-bffadedfda64</sv:value>
|
162
|
+
</sv:property>
|
163
|
+
<sv:property sv:name="hippotranslation:locale" sv:type="String">
|
164
|
+
<sv:value>en</sv:value>
|
165
|
+
</sv:property>
|
166
|
+
<sv:node sv:name="hippotranslation:translations">
|
167
|
+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
|
168
|
+
<sv:value>hippotranslation:translations</sv:value>
|
169
|
+
</sv:property>
|
170
|
+
</sv:node>
|
171
|
+
<sv:node sv:name="contentauthoringwebsite:preview-image">
|
172
|
+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
|
173
|
+
<sv:value>hippogallerypicker:imagelink</sv:value>
|
174
|
+
</sv:property>
|
175
|
+
<sv:property sv:name="hippo:docbase" sv:type="String">
|
176
|
+
<sv:value>06692ff2-ebf8-4466-bc98-f679d8bc2610</sv:value>
|
177
|
+
</sv:property>
|
178
|
+
<sv:property sv:name="hippo:facets" sv:type="String" sv:multiple="true"/>
|
179
|
+
<sv:property sv:name="hippo:modes" sv:type="String" sv:multiple="true"/>
|
180
|
+
<sv:property sv:name="hippo:values" sv:type="String" sv:multiple="true"/>
|
181
|
+
</sv:node>
|
182
|
+
<sv:node sv:name="contentauthoringwebsite:body">
|
183
|
+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
|
184
|
+
<sv:value>hippostd:html</sv:value>
|
185
|
+
</sv:property>
|
186
|
+
<sv:property sv:name="hippostd:content" sv:type="String">
|
187
|
+
<sv:value><html><body><p class="intro"><img src="binaries/content/gallery/contentauthoringwebsite/borrowing/do-you-need-to-borrow-money.jpg/do-you-need-to-borrow-money.jpg/hippogallery:original"/>Before
|
188
|
+
you sign up for a credit card, bank loan or store card, or add to an existing
|
189
|
+
card or loan it makes sense to think about whether you really need to borrow
|
190
|
+
money.</body></html></sv:value>
|
191
|
+
</sv:property>
|
192
|
+
<sv:node sv:name="working-out-a-repayment-plan-for-money-you-are-borrowing">
|
193
|
+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
|
194
|
+
<sv:value>hippo:facetselect</sv:value>
|
195
|
+
</sv:property>
|
196
|
+
<sv:property sv:name="hippo:docbase" sv:type="String">
|
197
|
+
<sv:value>7c0554bc-0d45-4537-8e55-cb898794e4ca</sv:value>
|
198
|
+
</sv:property>
|
199
|
+
<sv:property sv:name="hippo:facets" sv:type="String" sv:multiple="true"/>
|
200
|
+
<sv:property sv:name="hippo:modes" sv:type="String" sv:multiple="true"/>
|
201
|
+
<sv:property sv:name="hippo:values" sv:type="String" sv:multiple="true"/>
|
202
|
+
</sv:node>
|
203
|
+
<sv:node sv:name="deciding-on-the-best-type-of-credit-for-you">
|
204
|
+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
|
205
|
+
<sv:value>hippo:facetselect</sv:value>
|
206
|
+
</sv:property>
|
207
|
+
<sv:property sv:name="hippo:docbase" sv:type="String">
|
208
|
+
<sv:value>be6bfba4-c0d5-4975-ac81-a29a00b72a0c</sv:value>
|
209
|
+
</sv:property>
|
210
|
+
<sv:property sv:name="hippo:facets" sv:type="String" sv:multiple="true"/>
|
211
|
+
<sv:property sv:name="hippo:modes" sv:type="String" sv:multiple="true"/>
|
212
|
+
<sv:property sv:name="hippo:values" sv:type="String" sv:multiple="true"/>
|
213
|
+
</sv:node>
|
214
|
+
</sv:node>
|
215
|
+
<sv:node sv:name="contentauthoringwebsite:nudge">
|
216
|
+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
|
217
|
+
<sv:value>contentauthoringwebsite:Nudge</sv:value>
|
218
|
+
</sv:property>
|
219
|
+
<sv:property sv:name="contentauthoringwebsite:supporting_text" sv:type="String">
|
220
|
+
<sv:value/>
|
221
|
+
</sv:property>
|
222
|
+
<sv:property sv:name="contentauthoringwebsite:text" sv:type="String">
|
223
|
+
<sv:value/>
|
224
|
+
</sv:property>
|
225
|
+
</sv:node>
|
226
|
+
</sv:node>
|
227
|
+
</sv:node>
|
228
|
+
</sv:node>
|
229
|
+
</sv:node>
|
230
|
+
</sv:node>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HippoXmlParser do
|
4
|
+
describe 'parsing' do
|
5
|
+
let(:xml) { File.read('spec/fixtures/example.xml') }
|
6
|
+
let(:parsed) { HippoXmlParser.parse(xml) }
|
7
|
+
let(:body) { %q(<html><body><p class="intro"><img src="binaries/content/gallery/contentauthoringwebsite/borrowing/do-you-need-to-borrow-money.jpg/do-you-need-to-borrow-money.jpg/hippogallery:original"/>Before
|
8
|
+
you sign up for a credit card, bank loan or store card, or add to an existing
|
9
|
+
card or loan it makes sense to think about whether you really need to borrow
|
10
|
+
money.</body></html>) }
|
11
|
+
|
12
|
+
subject { parsed.first }
|
13
|
+
it 'parses the example' do
|
14
|
+
expect(parsed.size).to eql(1)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'has all the right attributes' do
|
18
|
+
expect(subject.id).to eql('do-you-need-to-borrow-money')
|
19
|
+
expect(subject.title).to eql('Do you need to borrow money?')
|
20
|
+
expect(subject.preview).to eql('Planning a big purchase or need some extra cash? Borrowing might seem like the obvious solution but there could be a better option')
|
21
|
+
expect(subject.state).to eql('published')
|
22
|
+
expect(subject.created_at.to_s).to eql('2012-05-31 10:14:35 UTC')
|
23
|
+
expect(subject.created_by).to eql('julian')
|
24
|
+
expect(subject.updated_at.to_s).to eql('2014-05-27 11:16:32 UTC')
|
25
|
+
expect(subject.updated_by).to eql('jlaney')
|
26
|
+
expect(subject.locale).to eql('en')
|
27
|
+
expect(subject.body).to eql(body)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hippo_xml_parser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jared Fraser
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: ''
|
56
|
+
email:
|
57
|
+
- dev@jsf.io
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- hippo_xml_parser.gemspec
|
70
|
+
- lib/hippo_xml_parser.rb
|
71
|
+
- lib/hippo_xml_parser/article.rb
|
72
|
+
- lib/hippo_xml_parser/body.rb
|
73
|
+
- lib/hippo_xml_parser/crawler.rb
|
74
|
+
- lib/hippo_xml_parser/document.rb
|
75
|
+
- lib/hippo_xml_parser/node.rb
|
76
|
+
- lib/hippo_xml_parser/property.rb
|
77
|
+
- lib/hippo_xml_parser/version.rb
|
78
|
+
- spec/fixtures/example.xml
|
79
|
+
- spec/hippo_xml_parser_spec.rb
|
80
|
+
- spec/spec_helper.rb
|
81
|
+
homepage: ''
|
82
|
+
licenses:
|
83
|
+
- MIT
|
84
|
+
metadata: {}
|
85
|
+
post_install_message:
|
86
|
+
rdoc_options: []
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
requirements: []
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 2.2.2
|
102
|
+
signing_key:
|
103
|
+
specification_version: 4
|
104
|
+
summary: Parser for Hippo XML exports
|
105
|
+
test_files:
|
106
|
+
- spec/fixtures/example.xml
|
107
|
+
- spec/hippo_xml_parser_spec.rb
|
108
|
+
- spec/spec_helper.rb
|