relaton-cli 0.1.8 → 0.1.9
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/lib/relaton/cli/relaton_file.rb +13 -8
- data/lib/relaton/cli/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7864959606a5a5ea10e2b4dbb7fe2e922662779bdc7b7e56041434269533624e
|
4
|
+
data.tar.gz: a2f45e732d3f90328f5dfabcb2bc74ddf4d3f3d869cf26a57a36bd467089db67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b686cd2eb16b7b6ffd89cb16d3a1405803b52a080c0f185655f77e4ab6ce88dc9985fcd3f3dbb82da27fac50c932f341a567d5a6eb2860dba24d271595a11fb
|
7
|
+
data.tar.gz: 22775ba4fd0f900d1618c9b731188c5a50a59ba07e760c9c453ed87bbfc8bb574ed044d9c77da7b6216475f01968a0549403fb9a1a2950587fb575ef74af1029
|
@@ -136,14 +136,18 @@ module Relaton
|
|
136
136
|
|
137
137
|
def split_and_write_to_files
|
138
138
|
output_dir = outdir || build_dirname(source)
|
139
|
-
write_to_collection_file(relaton_collection.to_yaml, output_dir)
|
140
139
|
|
141
140
|
relaton_collection.items.each do |content|
|
142
141
|
name = build_filename(nil, content.docidentifier)
|
143
|
-
write_to_file(content.
|
142
|
+
write_to_file(content.send(output_type), output_dir, name)
|
144
143
|
end
|
145
144
|
end
|
146
145
|
|
146
|
+
def output_type
|
147
|
+
output_format = options[:extension] || "rxl"
|
148
|
+
(output_format == "rxl" ? "to_xml" : "to_#{output_format}").to_sym
|
149
|
+
end
|
150
|
+
|
147
151
|
def bibdata_instance(document, file)
|
148
152
|
document = clean_nokogiri_document(document)
|
149
153
|
bibdata = Relaton::Bibdata.from_xml(document.root)
|
@@ -192,10 +196,6 @@ module Relaton
|
|
192
196
|
File.open(file_with_dir, "w:utf-8") { |file| file.write(content) }
|
193
197
|
end
|
194
198
|
|
195
|
-
def write_to_collection_file(content, directory)
|
196
|
-
write_to_file(content, directory, build_filename(source, nil, "yaml"))
|
197
|
-
end
|
198
|
-
|
199
199
|
def build_dirname(filename)
|
200
200
|
basename = File.basename(filename)&.gsub(/.(xml|rxl)/, "")
|
201
201
|
directory_name = sanitize_string(basename)
|
@@ -210,8 +210,13 @@ module Relaton
|
|
210
210
|
end
|
211
211
|
|
212
212
|
def sanitize_string(string)
|
213
|
-
|
214
|
-
|
213
|
+
clean_string = replace_bad_characters(string.downcase)
|
214
|
+
clean_string.gsub(/^\s+/, "").gsub(/\s+$/, "").gsub(/\s+/, "-")
|
215
|
+
end
|
216
|
+
|
217
|
+
def replace_bad_characters(string)
|
218
|
+
bad_chars = ["/", "\\", "?", "%", "*", ":", "|", '"', "<", ">", ".", " "]
|
219
|
+
bad_chars.inject(string.downcase) { |res, char| res.gsub(char, "-") }
|
215
220
|
end
|
216
221
|
end
|
217
222
|
end
|
data/lib/relaton/cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|