libis-tools 1.0.9 → 1.0.12
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 +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: 810ac9ed3a3b03f0ae8cc0d1deea5b1c6a0f70b0d34bce8eb752fba9da5583f9
|
4
|
+
data.tar.gz: 5b51eb0c78b0928e1183f53bd270ec148f35b47f42a066432705a657279ccfa9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0a53c49318401d632db7a3e20a70a1378a50ce101c2e8f26ac0216aee3ffcb28c81287663b6daccb3693d2a962337c472f36254e6ea065aed2135e65cfbf876
|
7
|
+
data.tar.gz: 207d258c97de31f803d71dd0f39c6cc37b00fbcfe0120bf37a36c3669c3ac43d4d1253b2c1cfed0004a24ed8215e03e9990af4853389c40958f6c5300497068f
|
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_RE = /\A[[:space:]]^\z/.freeze
|
23
|
+
def blank?
|
24
|
+
empty? || BLANK_RE.match?(self)
|
25
|
+
end
|
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'
|
@@ -92,7 +92,7 @@ module Libis
|
|
92
92
|
|
93
93
|
dmd_sec = xml_doc.root.xpath('mets:dmdSec', NS).inject({}) do |hash_dmd, dmd|
|
94
94
|
hash_dmd[dmd[:ID]] = dmd.xpath('.//dc:record', NS).first.children.inject({}) do |h, c|
|
95
|
-
h[c.name] = c.content
|
95
|
+
h[c.name] = c.content if c.name != 'text'
|
96
96
|
h
|
97
97
|
end
|
98
98
|
hash_dmd
|
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.12
|
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-25 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.
|