fide_xml_parser 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -1
- data/lib/fide_xml_parser/json_writer.rb +5 -6
- data/lib/fide_xml_parser/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 706820b647cf190a5e17304d1cb22c7af1921b8e84f4310cc1dee6061de51f57
|
4
|
+
data.tar.gz: d64a2a33a80963bd30a7881393333f6464e1bee3b622e3e48a5831e7e0450b4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4515194fdf260fac89050ad6216069cdeb26a3516f5e6837e597d2af24fcad89bb6829a4a6602d02ddb9f12bb90a7d67b50c61ee35afbc5b6841654e81154f58
|
7
|
+
data.tar.gz: 667235af5570310f71120607ae937102162121a0e4bd2075d86b1cb731b0c6622f6d36c76ce721735164f2e0488a17748c7386352ea5aab26e5d928836c886fe
|
data/CHANGELOG.md
CHANGED
@@ -32,22 +32,22 @@ class JsonWriter
|
|
32
32
|
# To write multiple files, pass an array of filespecs as the `input_filespecs` parameter
|
33
33
|
# json_mode: :pretty for human readable JSON, :compact for compact JSON
|
34
34
|
# Default json_filespec will be constructed from the input file, just replacing 'xml' with 'json'.
|
35
|
-
def write(input_filespec, json_mode
|
35
|
+
def write(input_filespec, json_mode: :pretty, json_filespec: nil)
|
36
36
|
if input_filespec.is_a?(Array)
|
37
37
|
raise Error.new("This method is used only for single files, use write_multiple for multiple files.")
|
38
38
|
end
|
39
39
|
|
40
40
|
validate_input_filespecs(Array[input_filespec])
|
41
|
-
write_private(input_filespec, json_mode, json_filespec)
|
41
|
+
write_private(input_filespec, json_mode: json_mode, json_filespec: json_filespec)
|
42
42
|
end
|
43
43
|
|
44
44
|
|
45
45
|
# Public entry point to write multiple files.
|
46
46
|
# json_mode: :pretty for human readable JSON, :compact for compact JSON
|
47
|
-
def write_multiple(input_filespecs, json_mode
|
47
|
+
def write_multiple(input_filespecs, json_mode: :pretty)
|
48
48
|
validate_input_filespecs(input_filespecs)
|
49
49
|
input_filespecs.each do |input_filespec|
|
50
|
-
write_private(input_filespec, json_mode)
|
50
|
+
write_private(input_filespec, json_mode: json_mode)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -56,12 +56,11 @@ class JsonWriter
|
|
56
56
|
# Separated from the public `write` method in order to validate filespecs only once.
|
57
57
|
# Default json_filespec will be constructed from the input file, just replacing 'xml' with 'json'.
|
58
58
|
private
|
59
|
-
def write_private(input_filespec, json_mode
|
59
|
+
def write_private(input_filespec, json_mode: :pretty, json_filespec: nil)
|
60
60
|
@parser = FideXmlParser::Processor.new
|
61
61
|
parser.key_filter = key_filter
|
62
62
|
parser.record_filter = record_filter
|
63
63
|
records = parser.parse(File.new(input_filespec))
|
64
|
-
|
65
64
|
json_text = (json_mode == :pretty) ? JSON.pretty_generate(records) : records.to_json
|
66
65
|
json_filespec ||= input_filespec.sub(/\.xml$/, '.json')
|
67
66
|
File.write(json_filespec, json_text)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fide_xml_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith Bennett
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
requirements: []
|
154
|
-
rubygems_version: 3.
|
154
|
+
rubygems_version: 3.0.6
|
155
155
|
signing_key:
|
156
156
|
specification_version: 4
|
157
157
|
summary: Parses XML files downloaded from fide.com and writes JSON files.
|