libis-tools 1.0.9 → 1.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -13
- data/lib/libis/tools/csv.rb +2 -2
- data/lib/libis/tools/deep_struct.rb +4 -4
- data/lib/libis/tools/extend/empty.rb +28 -3
- data/lib/libis/tools/extend/string.rb +1 -12
- data/lib/libis/tools/mets_file.rb +7 -3
- data/lib/libis/tools/mets_objects.rb +1 -1
- data/lib/libis/tools/version.rb +1 -1
- data/libis-tools.gemspec +2 -2
- data/spec/config_file_spec.rb +1 -0
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f007ed770338a6d5f537e3388cc72409e4e35deab2c337f8f4a80a76db200371
|
4
|
+
data.tar.gz: c57cd7d2cb65c0cf6cc03a2e7973ee2d24e279f5e975da5580b4569f50c833b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4a87f3ffdb3319e748fa9d60f47971f250fb2ff841ea63f0c7795afbacbee452943958b366b1462f866a406f07a39b5556258778b7913db236e8889a2f2a7ea
|
7
|
+
data.tar.gz: 1058f448308c579de12b41183d185846278ec9c798cf97cece7f5a324039fcd7886f12960a8023e833eadac073f33245d0fbb3e022d00267f5eaa7f633f34c5d
|
data/.travis.yml
CHANGED
@@ -3,30 +3,20 @@ language: ruby
|
|
3
3
|
cache: bundler
|
4
4
|
sudo: false
|
5
5
|
rvm:
|
6
|
-
- 2.3
|
7
6
|
- 2.4
|
8
7
|
- 2.5
|
9
8
|
- 2.6
|
9
|
+
- 2.7
|
10
|
+
- 3.0
|
10
11
|
- ruby-head
|
11
12
|
# - jruby-9.1
|
12
13
|
- jruby-9.2
|
13
14
|
- jruby-head
|
14
15
|
jdk:
|
15
|
-
- openjdk10
|
16
16
|
- openjdk11
|
17
17
|
matrix:
|
18
|
-
exclude:
|
19
|
-
- rvm: 2.3
|
20
|
-
jdk: openjdk10
|
21
|
-
- rvm: 2.4
|
22
|
-
jdk: openjdk10
|
23
|
-
- rvm: 2.5
|
24
|
-
jdk: openjdk10
|
25
|
-
- rvm: 2.6
|
26
|
-
jdk: openjdk10
|
27
|
-
- rvm: ruby-head
|
28
|
-
jdk: openjdk10
|
29
18
|
allow_failures:
|
19
|
+
- rvm: 3.0
|
30
20
|
- rvm: ruby-head
|
31
21
|
- rvm: jruby-head
|
32
22
|
branches:
|
data/lib/libis/tools/csv.rb
CHANGED
@@ -20,7 +20,7 @@ module Libis
|
|
20
20
|
optional_headers = options.delete(:optional)
|
21
21
|
options[:headers] = true
|
22
22
|
options[:return_headers] = true
|
23
|
-
csv = CSV.open(file_name, mode, options)
|
23
|
+
csv = ::CSV.open(file_name, mode, **options)
|
24
24
|
line = csv.shift
|
25
25
|
found_headers = required_headers & line.headers
|
26
26
|
return csv if found_headers.size == required_headers.size
|
@@ -29,7 +29,7 @@ module Libis
|
|
29
29
|
options[:headers] = (required_headers + optional_headers)[0...line.size]
|
30
30
|
raise RuntimeError, 'CSV does not contain enough columns' if required_headers.size > line.size
|
31
31
|
options[:return_headers] = true
|
32
|
-
csv = CSV.open(file_name, mode, options)
|
32
|
+
csv = ::CSV.open(file_name, mode, **options)
|
33
33
|
csv.shift
|
34
34
|
csv
|
35
35
|
end
|
@@ -28,8 +28,8 @@ module Libis
|
|
28
28
|
return self unless hash.respond_to?(:to_hash)
|
29
29
|
hash.to_hash.inject(self.dup) do |ds, (key, value)|
|
30
30
|
ds[key] = DeepDup.new(
|
31
|
-
recurse_over_arrays: @recurse_over_arrays,
|
32
|
-
preserve_original_keys: @preserve_original_keys
|
31
|
+
recurse_over_arrays: @options[:recurse_over_arrays],
|
32
|
+
preserve_original_keys: @options[:preserve_original_keys]
|
33
33
|
).call(value)
|
34
34
|
ds
|
35
35
|
end
|
@@ -39,8 +39,8 @@ module Libis
|
|
39
39
|
return self unless hash.respond_to?(:to_hash)
|
40
40
|
hash.to_hash.inject(self) do |ds, (key, value)|
|
41
41
|
ds[key] = DeepDup.new(
|
42
|
-
recurse_over_arrays: @recurse_over_arrays,
|
43
|
-
preserve_original_keys: @preserve_original_keys
|
42
|
+
recurse_over_arrays: @options[:recurse_over_arrays],
|
43
|
+
preserve_original_keys: @options[:preserve_original_keys]
|
44
44
|
).call(value)
|
45
45
|
ds
|
46
46
|
end
|
@@ -1,7 +1,32 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
class NilClass
|
3
|
-
# Allows nil.empty?
|
4
4
|
def empty?
|
5
5
|
true
|
6
6
|
end
|
7
|
-
end
|
7
|
+
end
|
8
|
+
|
9
|
+
class TrueClass
|
10
|
+
def empty?
|
11
|
+
false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class FalseClass
|
16
|
+
def empty?
|
17
|
+
false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class String
|
22
|
+
BLANK_REGEX = /\A[[:space:]]^\z/.freeze
|
23
|
+
def blank?
|
24
|
+
empty? || BLANK_REGEX.match?(self)
|
25
|
+
end unless method_defined? :blank?
|
26
|
+
end
|
27
|
+
|
28
|
+
class Object
|
29
|
+
def blank?
|
30
|
+
respond_to?(:empty?) ? !!empty? : !self
|
31
|
+
end
|
32
|
+
end
|
@@ -37,10 +37,6 @@ class String
|
|
37
37
|
downcase
|
38
38
|
end unless method_defined? :underscore
|
39
39
|
|
40
|
-
# Check if string is empty
|
41
|
-
def blank?
|
42
|
-
self == ''
|
43
|
-
end unless method_defined? :blank?
|
44
40
|
|
45
41
|
# Create sortable object from string. Supports better natural sorting.
|
46
42
|
def sort_form
|
@@ -118,11 +114,4 @@ class String
|
|
118
114
|
|
119
115
|
end
|
120
116
|
|
121
|
-
|
122
|
-
class NilClass
|
123
|
-
|
124
|
-
# Allow nil.blank? so that blank? can be applied without errors.
|
125
|
-
def blank?
|
126
|
-
true
|
127
|
-
end
|
128
|
-
end
|
117
|
+
require_relative 'empty'
|
@@ -91,14 +91,18 @@ module Libis
|
|
91
91
|
end
|
92
92
|
|
93
93
|
dmd_sec = xml_doc.root.xpath('mets:dmdSec', NS).inject({}) do |hash_dmd, dmd|
|
94
|
-
|
95
|
-
|
94
|
+
id = dmd[:ID]
|
95
|
+
id = id.slice(0..(id.index('-dmd') + 3))
|
96
|
+
hash_dmd[id] = dmd.xpath('.//dc:record', NS).first.children.inject({}) do |h, c|
|
97
|
+
h[c.name] = c.content if c.name != 'text'
|
96
98
|
h
|
97
99
|
end
|
98
100
|
hash_dmd
|
99
101
|
end
|
100
102
|
amd_sec = xml_doc.root.xpath('mets:amdSec', NS).inject({}) do |hash_amd, amd|
|
101
|
-
|
103
|
+
id = amd[:ID]
|
104
|
+
id = id.slice(0..(id.index('-amd') + 3))
|
105
|
+
hash_amd[id] = [:tech, :rights, :source, :digiprov].inject({}) do |hash_sec, sec|
|
102
106
|
md = amd.xpath("mets:#{sec}MD", NS).first
|
103
107
|
return hash_sec unless md
|
104
108
|
# hash_sec[sec] = md.xpath('mets:mdWrap/dnx:dnx/dnx:section', NS).inject({}) do |hash_md, dnx_sec|
|
@@ -289,7 +289,7 @@ module Libis
|
|
289
289
|
compositionLevel: composition_level,
|
290
290
|
# fileLocationType: 'FILE',
|
291
291
|
fileLocation: location,
|
292
|
-
fileOriginalName:
|
292
|
+
fileOriginalName: original || target_names,
|
293
293
|
fileOriginalPath: target_path,
|
294
294
|
# fileOriginalID: URI.encode(location),
|
295
295
|
# fileExtension: ::File.extname(orig_name),
|
data/lib/libis/tools/version.rb
CHANGED
data/libis-tools.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
28
28
|
|
29
29
|
spec.require_paths = ['lib']
|
30
|
-
spec.has_rdoc = 'yard'
|
30
|
+
# spec.has_rdoc = 'yard'
|
31
31
|
|
32
32
|
spec.add_development_dependency 'bundler', '> 1.6'
|
33
33
|
spec.add_development_dependency 'rake', '~> 13.0'
|
@@ -39,7 +39,7 @@ Gem::Specification.new do |spec|
|
|
39
39
|
spec.add_runtime_dependency 'nokogiri', '~> 1.6'
|
40
40
|
spec.add_runtime_dependency 'gyoku', '~> 1.3'
|
41
41
|
spec.add_runtime_dependency 'nori', '~> 2.6'
|
42
|
-
spec.add_runtime_dependency 'recursive-open-struct', '
|
42
|
+
spec.add_runtime_dependency 'recursive-open-struct', '>= 1.1.3'
|
43
43
|
spec.add_runtime_dependency 'parslet', '~> 1.7'
|
44
44
|
spec.add_runtime_dependency 'simple_xlsx_reader', '~> 1.0'
|
45
45
|
spec.add_runtime_dependency 'logging', '~> 2.0'
|
data/spec/config_file_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libis-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kris Dekeyser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -140,16 +140,16 @@ dependencies:
|
|
140
140
|
name: recursive-open-struct
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- - "
|
143
|
+
- - ">="
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
145
|
+
version: 1.1.3
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- - "
|
150
|
+
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
152
|
+
version: 1.1.3
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: parslet
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -386,8 +386,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
386
386
|
- !ruby/object:Gem::Version
|
387
387
|
version: '0'
|
388
388
|
requirements: []
|
389
|
-
|
390
|
-
rubygems_version: 2.7.8
|
389
|
+
rubygems_version: 3.2.15
|
391
390
|
signing_key:
|
392
391
|
specification_version: 4
|
393
392
|
summary: LIBIS toolbox.
|