libis-tools 1.0.7 → 1.0.14
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/hash.rb +32 -0
- data/lib/libis/tools/extend/string.rb +1 -12
- data/lib/libis/tools/mets_file.rb +7 -3
- data/lib/libis/tools/version.rb +1 -1
- data/libis-tools.gemspec +3 -3
- data/spec/config_file_spec.rb +1 -0
- metadata +9 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7320e8d4c2cd30ffb3d0028c81532e12f62c86525c77759f22815824bf26f8b0
|
4
|
+
data.tar.gz: 8854f225cef51a1cc522cdabf94a21b2238dcb7308330cad5c521d36e7029e35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3c431b86d57a39fffe0a59ea1936270dfab74f8f3a68ba61d0aa18f2e140282df3bd083988ada739f5600e7abeec8cf863004785779388e0a632694917eb062
|
7
|
+
data.tar.gz: 03472cf090c393e25c234ef2caae5789e65245347f9b9434c8a39b45b68caa496abccf4415f852dee5c394fbb6714c5889172a487751972c0123144c74d6828d
|
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
|
@@ -158,4 +158,36 @@ class Hash
|
|
158
158
|
r
|
159
159
|
end unless method_defined? :key_symbols_to_strings
|
160
160
|
|
161
|
+
def transform_keys
|
162
|
+
result = {}
|
163
|
+
each_key do |key|
|
164
|
+
result[yield(key)] = self[key]
|
165
|
+
end
|
166
|
+
result
|
167
|
+
end unless method_defined? :transform_keys
|
168
|
+
|
169
|
+
def transform_keys!
|
170
|
+
keys.each do |key|
|
171
|
+
self[yield(key)] = delete(key)
|
172
|
+
end
|
173
|
+
self
|
174
|
+
end unless method_defined? :transform_keys!
|
175
|
+
|
176
|
+
def transform_values
|
177
|
+
return enum_for(:transform_values) { size } unless block_given?
|
178
|
+
return {} if empty?
|
179
|
+
result = self.class.new
|
180
|
+
each do |key, value|
|
181
|
+
result[key] = yield(value)
|
182
|
+
end
|
183
|
+
result
|
184
|
+
end unless method_defined? :transform_values
|
185
|
+
|
186
|
+
def transform_values!
|
187
|
+
return enum_for(:transform_values!) { size } unless block_given?
|
188
|
+
each do |key, value|
|
189
|
+
self[key] = yield(value)
|
190
|
+
end
|
191
|
+
end unless method_defined? :transform_values!
|
192
|
+
|
161
193
|
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|
|
data/lib/libis/tools/version.rb
CHANGED
data/libis-tools.gemspec
CHANGED
@@ -27,10 +27,10 @@ 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
|
-
spec.add_development_dependency 'rake', '~>
|
33
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
34
34
|
spec.add_development_dependency 'rspec', '~> 3.1'
|
35
35
|
spec.add_development_dependency 'term-ansicolor', '~> 1.6'
|
36
36
|
spec.add_development_dependency 'equivalent-xml', '~> 0.5'
|
@@ -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.14
|
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-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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.
|