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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b272e715eada957c71274b805c3cc13ddef2201f6d1eaa6ae23b9f19c9da6396
4
- data.tar.gz: 320cedbee54192c465006a77f4e98e2d415e3ab15dfd250e1101774bc8d0c686
3
+ metadata.gz: 7320e8d4c2cd30ffb3d0028c81532e12f62c86525c77759f22815824bf26f8b0
4
+ data.tar.gz: 8854f225cef51a1cc522cdabf94a21b2238dcb7308330cad5c521d36e7029e35
5
5
  SHA512:
6
- metadata.gz: 8bfdde16320124ab7ca2fddfcc7dc17ed019bade21f118bd81a0f0179d7b1258ed4890419e277d7ba8517c73b6e6216cd06adf71b5a80316930b33a47d27e120
7
- data.tar.gz: 22f5c05ddfe99203e30a7aae5e66010e42f9e6342bc605a21c49da288a860d39ce6f56825e62b11c15dad8497d965fe350771d47a6d684badcd6cda48c54d830
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:
@@ -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
@@ -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
- # 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|
@@ -1,5 +1,5 @@
1
1
  module Libis
2
2
  module Tools
3
- VERSION = '1.0.7'
3
+ VERSION = '1.0.14'
4
4
  end
5
5
  end
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', '~> 10.3'
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', '~> 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.7
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: 2020-05-14 00:00:00.000000000 Z
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: '10.3'
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: '10.3'
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: '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.