eatr 0.1.1 → 0.1.2
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 +4 -4
- data/README.md +14 -3
- data/lib/eatr/schema.rb +1 -1
- data/lib/eatr/version.rb +1 -1
- data/lib/eatr/xml/document.rb +7 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a32f86bc2140f39a18bd20b0c53bcbb45a9f34e9
|
4
|
+
data.tar.gz: 00d35b0e2087df6c1d6bd9fdaaf55d9a9c149a5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5e27d470fb3803f3a28e782aff7566eab6b839e357115191989fa8514b0f926bc620edf286dd05d1d6c68b5748071b012df96157d9713e25ee79bf3eebc8834
|
7
|
+
data.tar.gz: 430e84bb49d454e3e844b820dbd6549112c5c76b3968e5ecd77fb7cd3d46679c7b59e9fb5185fc46b586aa1aef102c54f1dd0a1c0abd9a4c72384674ab667490
|
data/README.md
CHANGED
@@ -1,8 +1,19 @@
|
|
1
1
|
# Eatr
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
Parsing a collection of XML documents often results in code that is a mixture
|
4
|
+
of XPaths and nested loops, which are difficult to understand at a glance and
|
5
|
+
maintain. Additionally, there's often a need for common transformations such
|
6
|
+
as parsing a timestamp or truncating a string. [Separating data from the
|
7
|
+
code](http://wiki.c2.com/?SeparationOfDataAndCode) is beneficial since the data
|
8
|
+
file can be parsed by multiple languages or used by a [collection of
|
9
|
+
tools](#helpful-tools). For example, this library provides a helper class for
|
10
|
+
creating SQL `CREATE TABLE` statements.
|
11
|
+
|
12
|
+
Eatr is a simple framework that allows you to describe the struct you want
|
13
|
+
populated by a document in a YAML configuration file. For each field, you
|
14
|
+
specify where it's value can be found in teh document using either XPath in the
|
15
|
+
case of XML documents or header name in CSVs. For an example of this, [see
|
16
|
+
below in the Parsing Documents section](#parsing-documents).
|
6
17
|
|
7
18
|
## Table of Contents
|
8
19
|
|
data/lib/eatr/schema.rb
CHANGED
data/lib/eatr/version.rb
CHANGED
data/lib/eatr/xml/document.rb
CHANGED
@@ -21,7 +21,13 @@ module Eatr
|
|
21
21
|
def parse(xml_document_path)
|
22
22
|
@namespaces = {}
|
23
23
|
|
24
|
-
|
24
|
+
if File.exists?(xml_document_path)
|
25
|
+
file = File.open(xml_document_path)
|
26
|
+
else
|
27
|
+
file = StringIO.new(xml_document_path)
|
28
|
+
end
|
29
|
+
|
30
|
+
doc = Nokogiri::XML(file) do |config|
|
25
31
|
config.strict.nonet
|
26
32
|
end
|
27
33
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eatr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greggory Rothmeier
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|