relaton-cli 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 602dc6b5405f7e9ad64b82a2db8d7c01e1f3de2aa95324a48cb1bef1f5d83394
4
- data.tar.gz: 3d59d3c875327a1444f6d95be1d83f9b44e1edb78a40c3e3d1ae62096611f2b3
3
+ metadata.gz: 7864959606a5a5ea10e2b4dbb7fe2e922662779bdc7b7e56041434269533624e
4
+ data.tar.gz: a2f45e732d3f90328f5dfabcb2bc74ddf4d3f3d869cf26a57a36bd467089db67
5
5
  SHA512:
6
- metadata.gz: e0b7c3d7b95e26db2bb8392860e2ccaef744caa588885c285cb2ab472ecadda6d08d1393dd0f093f33d918f705351a1092f8b869940a8ee8aa50267446886849
7
- data.tar.gz: 7c91b43960fbd34ee9500524fad1b355f3681960c623dd1af95f637736f577d516107330de97c4b97bf7785fc50b747c198c7f67ca4003fce8309760aa6a207a
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.to_xml, output_dir, name)
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
- string.downcase.gsub("/", " ").gsub(/^\s+/, "").gsub(/\s+$/, "").
214
- gsub(/\s+/, "-")
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
@@ -1,5 +1,5 @@
1
1
  module Relaton
2
2
  module Cli
3
- VERSION = "0.1.8".freeze
3
+ VERSION = "0.1.9".freeze
4
4
  end
5
5
  end
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.8
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-02-24 00:00:00.000000000 Z
11
+ date: 2019-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake