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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 723534e02fafa057740113e05c2a05a57dca3f4f
4
- data.tar.gz: 51a0cbf659f1686797df1e77bbf4ca7bd2edb8c0
3
+ metadata.gz: a32f86bc2140f39a18bd20b0c53bcbb45a9f34e9
4
+ data.tar.gz: 00d35b0e2087df6c1d6bd9fdaaf55d9a9c149a5f
5
5
  SHA512:
6
- metadata.gz: 15920883e030fc4c6ffae98dc92358bff41af91a702b482a38e879abfff20be560fe47719e1261f5ac6692f722ab48afa225734e6d04f2078b2f337ae21eb11f
7
- data.tar.gz: 0824a84729c1ef1da495bd62d497757d1e5090695a839d823b8ad545dc9ad3d9ca09caed27d3089393607ab51c86a3a04d65beedd92c739b6464d3a60207bdbc
6
+ metadata.gz: c5e27d470fb3803f3a28e782aff7566eab6b839e357115191989fa8514b0f926bc620edf286dd05d1d6c68b5748071b012df96157d9713e25ee79bf3eebc8834
7
+ data.tar.gz: 430e84bb49d454e3e844b820dbd6549112c5c76b3968e5ecd77fb7cd3d46679c7b59e9fb5185fc46b586aa1aef102c54f1dd0a1c0abd9a4c72384674ab667490
data/README.md CHANGED
@@ -1,8 +1,19 @@
1
1
  # Eatr
2
2
 
3
- Configuration-based XML and CSV document parsing and transformation library.
4
- Define structs in YAML configuration files and parse documents to create and
5
- populate the structs.
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
 
@@ -66,7 +66,7 @@ module Eatr
66
66
 
67
67
  def to_struct
68
68
  @struct_klass ||= begin
69
- Object.const_get("Struct::#{constant_name}")
69
+ Object.const_get("Struct::#{constant_name}", false)
70
70
  rescue NameError
71
71
  Struct.new(constant_name, *field_names)
72
72
  end
@@ -1,3 +1,3 @@
1
1
  module Eatr
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -21,7 +21,13 @@ module Eatr
21
21
  def parse(xml_document_path)
22
22
  @namespaces = {}
23
23
 
24
- doc = Nokogiri::XML(File.open(xml_document_path)) do |config|
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.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-06 00:00:00.000000000 Z
11
+ date: 2017-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri