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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c057b018c6fd9fa648ba532ebbf0919d7f04c399057aa2a73b61b346076dece9
4
- data.tar.gz: 9ae7380f4b60de143a6949990a69cb7249f4d81ea06912194c329c5df1b5bcf6
3
+ metadata.gz: f007ed770338a6d5f537e3388cc72409e4e35deab2c337f8f4a80a76db200371
4
+ data.tar.gz: c57cd7d2cb65c0cf6cc03a2e7973ee2d24e279f5e975da5580b4569f50c833b3
5
5
  SHA512:
6
- metadata.gz: c00fa670055c8cc156b3a7b5810f4e927c8386dba41ae4dd5b55bb602124fd962df415a4b0f1c640941685d2d1d3a7bb8222978f199bb55856ba095287015865
7
- data.tar.gz: 60d16f403a7473bea8f0de32793a53f72779db587ba82911628ff974b9f62d5fed2eacf3532dad4ff177383e2f47d1c7e9aae8714a66aa1c5b82f011d3142cb4
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:
@@ -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
- # Extension for NilClass
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
- # Extension class
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
- hash_dmd[dmd[:ID]] = dmd.xpath('.//dc:record', NS).first.children.inject({}) do |h, c|
95
- h[c.name] = c.content
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
- hash_amd[amd[:ID]] = [:tech, :rights, :source, :digiprov].inject({}) do |hash_sec, sec|
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: CGI.escape(original || target_name).gsub('+', '%20'),
292
+ fileOriginalName: original || target_names,
293
293
  fileOriginalPath: target_path,
294
294
  # fileOriginalID: URI.encode(location),
295
295
  # fileExtension: ::File.extname(orig_name),
@@ -1,5 +1,5 @@
1
1
  module Libis
2
2
  module Tools
3
- VERSION = '1.0.9'
3
+ VERSION = '1.0.15'
4
4
  end
5
5
  end
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', '~> 1.0'
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'
@@ -45,6 +45,7 @@ describe ::Libis::Tools::ConfigFile do
45
45
 
46
46
  it 'allows to change hash in array' do
47
47
  subject << hash
48
+ # subject = ::Libis::Tools::ConfigFile.new(hash)
48
49
  # noinspection RubyResolve
49
50
  subject.c[0][0].a[0].v = 1
50
51
  hash[:c][0][0][:a][0][:v] = 1
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.9
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: 2020-05-25 00:00:00.000000000 Z
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: '1.0'
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: '1.0'
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
- rubyforge_project:
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.