libis-tools 1.0.19 → 1.1.1

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: 901262cdfc7d422163928efb4db49faa4290bc55369cd3168b78135b17073af6
4
- data.tar.gz: 46b7f6db6f546f0a30134d231c1b9310e3efae766e603dd64226a9228db264c1
3
+ metadata.gz: 9cdf44886fdc0890073e44ad0a507e3dd37db77523defc39f3584192e8bce70a
4
+ data.tar.gz: 8c0037d5ea9907a99b006c7273e39ef5f3d5b51e81618963bc4a82728c28c13e
5
5
  SHA512:
6
- metadata.gz: daefd95f9d07e81b2d56125172b162c857b20f9d6bb051455d65f20417fa3c8de05245466ab87cafcb6399b90207c93059a3816ed6f2a895c2192bc8b39526dc
7
- data.tar.gz: 8140a9f88ea5dee720cbd623042b61cec46927d4ce5c5a5db5598b2002da629b9b24851c46763b3afd546acea897c28041bc00ed44e8b1c8be463e7662df02ef
6
+ metadata.gz: a69b2e77fab73af0fadbef38afa6a53f2d462689f82b3299ee8447b4a0d799cb2f2503ce8eea2cb1bbede8686a31e5b5c320526769fb30d6719adfb56839a696
7
+ data.tar.gz: 749f31e690dfbd7bba4d205005dd157113da3632aa1c445a4a7d62f3a6a79430dcf9793df4b0ba3f8e1e2de5147a785ca0665c2c7446206bbcf926d10e904e98
@@ -48,9 +48,8 @@ module Libis
48
48
  # * :err (Array<String>)- the stderr output of the command
49
49
  # * :timeout(Boolean) - if true, the command did not return in time
50
50
  # * :pid(Integer) - the command's processID
51
- def self.run(*cmd)
51
+ def self.run(*cmd, **spawn_opts)
52
52
 
53
- spawn_opts = Hash === cmd.last ? cmd.pop.dup : {}
54
53
  opts = {
55
54
  :stdin_data => spawn_opts.delete(:stdin_data) || '',
56
55
  :binmode => spawn_opts.delete(:binmode) || false,
@@ -35,16 +35,16 @@ module Libis
35
35
 
36
36
  # For each configuration parameter, the value can be accessed via the class or the Singleton instance.
37
37
  # The class diverts to the instance automatically.
38
- def method_missing(name, *args, &block)
39
- result = instance.send(name, *args, &block)
38
+ def method_missing(name, *args, **kwargs, &block)
39
+ result = instance.send(name, *args, **kwargs, &block)
40
40
  self === result ? self : result
41
41
  end
42
42
 
43
43
  end
44
44
 
45
45
  # Instance method that allows to access the configuration parameters by method.
46
- def method_missing(name, *args, &block)
47
- result = config.send(name, *args, &block)
46
+ def method_missing(name, *args, **kwargs, &block)
47
+ result = config.send(name, *args, **kwargs, &block)
48
48
  self === config ? self : result
49
49
  end
50
50
 
@@ -7,7 +7,7 @@ module Libis
7
7
  # @param [String] file_name
8
8
  # @param [Hash] options
9
9
  # @return [CSV] Open CSV object
10
- def self.open(file_name, options = {})
10
+ def self.open(file_name, **options)
11
11
  options = {
12
12
  mode: 'rb:UTF-8',
13
13
  required: %w'',
@@ -33,7 +33,7 @@ module Roo
33
33
  end
34
34
 
35
35
  header_line.upto(last_row) do |line|
36
- yield(Hash[headers.map { |k, v| [k, cell(line, v)] }])
36
+ yield(headers.each_with_object({}) { |(k, v), hash| hash[k] = cell(line, v) })
37
37
  end
38
38
  end
39
39
  end
@@ -89,15 +89,4 @@ module Roo
89
89
 
90
90
  end
91
91
 
92
- class CSV
93
- def each_row(options, &block)
94
- if uri?(filename)
95
- each_row_using_tempdir(options, &block)
96
- elsif is_stream?(filename_or_stream)
97
- ::CSV.new(filename_or_stream, **options).each(&block)
98
- else
99
- ::CSV.foreach(filename, **options, &block)
100
- end
101
- end
102
- end
103
92
  end
@@ -1,8 +1,8 @@
1
- # Symbol monkey patch to allow map(&:method) to take arguments. Allows: [2,3].map(&:+.(10)) # => [12,13]
1
+ # Symbol monkey patch to allow map(&:method) to take arguments. Allows: [2,3].map(&:+.with(10)) # => [12,13]
2
2
  # See: https://stackoverflow.com/questions/23695653/can-you-supply-arguments-to-the-mapmethod-syntax-in-ruby
3
3
  # for more information,
4
4
  class Symbol
5
- def call(*args, &block)
5
+ def with(*args, &block)
6
6
  ->(caller, *rest) { caller.public_send(self, *rest, *args, &block) }
7
7
  end
8
8
  end
@@ -64,45 +64,46 @@ module Libis
64
64
  #
65
65
  # @param [String] msg the message.
66
66
  # @param [Array] args optional extra arguments.
67
- # @!method(debug(msg, *args))
68
- def debug(msg, *args)
69
- self.message :DEBUG, msg, *args
67
+ # @param [Hash] kwargs optional keyword arguments
68
+ # @!method(debug(msg, *args, **kwargs))
69
+ def debug(msg, *args, **kwargs)
70
+ self.message :DEBUG, msg, *args, **kwargs
70
71
  end
71
72
 
72
73
  # Send an info message to the logger.
73
74
  #
74
75
  # (see #debug)
75
76
  # @param (see #debug)
76
- # @!method(info(msg, *args))
77
- def info(msg, *args)
78
- self.message :INFO, msg, *args
77
+ # @!method(info(msg, *args, **kwargs))
78
+ def info(msg, *args, **kwargs)
79
+ self.message :INFO, msg, *args, **kwargs
79
80
  end
80
81
 
81
82
  # Send a warning message to the logger.
82
83
  #
83
84
  # (see #debug)
84
85
  # @param (see #debug)
85
- # @!method(warn(msg, *args))
86
- def warn(msg, *args)
87
- self.message :WARN, msg, *args
86
+ # @!method(warn(msg, *args, **kwargs))
87
+ def warn(msg, *args, **kwargs)
88
+ self.message :WARN, msg, *args, **kwargs
88
89
  end
89
90
 
90
91
  # Send an error message to the logger.
91
92
  #
92
93
  # (see #debug)
93
94
  # @param (see #debug)
94
- # @!method(error(msg, *args))
95
- def error(msg, *args)
96
- self.message :ERROR, msg, *args
95
+ # @!method(error(msg, *args, **kwargs))
96
+ def error(msg, *args, **kwargs)
97
+ self.message :ERROR, msg, *args, **kwargs
97
98
  end
98
99
 
99
100
  # Send a fatal message to the logger.
100
101
  #
101
102
  # (see #debug)
102
103
  # @param (see #debug)
103
- # @!method(fatal_error(msg, *args))
104
- def fatal_error(msg, *args)
105
- self.message :FATAL, msg, *args
104
+ # @!method(fatal_error(msg, *args, **kwargs))
105
+ def fatal_error(msg, *args, **kwargs)
106
+ self.message :FATAL, msg, *args, **kwargs
106
107
  end
107
108
 
108
109
  # The method that performs the code logging action.
@@ -117,8 +118,9 @@ module Libis
117
118
  # @param [{::Logger::Severity}] severity
118
119
  # @param [String] msg message string
119
120
  # @param [Object] args optional list of extra arguments
120
- # @!method(message(severity, msg, *args))
121
- def message(severity, msg, *args)
121
+ # @oaram [Hash] kwargs optional list of extra keyword arguments
122
+ # @!method(message(severity, msg, *args, **kwargs))
123
+ def message(severity, msg, *args, **kwargs)
122
124
  message_text = (msg % args rescue "#{msg}#{args.empty? ? '' : " - #{args}"}")
123
125
  self.logger.add(::Logging.level_num(severity), message_text)
124
126
  end
@@ -42,10 +42,11 @@ module Libis
42
42
  # * constraint - Array, Range, RegEx or single value. Default is nil meaning no constraint.
43
43
  # * frozen - Boolean. Default is false; if true the parameter value cannot be changed from the default value.
44
44
  # * options - Any Hash. It's up to the applcation to interprete and use this info.
45
- # datatype can be omitted if the type can be derived from the
46
- def initialize(*args)
45
+ # datatype can be omitted if the type can be derived from the default value
46
+ def initialize(*args, **options)
47
47
  super(*args)
48
48
  self[:options] ||= {}
49
+ self[:options].merge!(options)
49
50
  self[:datatype] ||= guess_datatype
50
51
  end
51
52
 
@@ -90,7 +91,9 @@ module Libis
90
91
  # Convience method to create a new {Parameter} from a Hash.
91
92
  # @param [Hash] h Hash with parameter definition properties
92
93
  def self.from_hash(h)
93
- h.each { |k, v| self[k.to_s.to_sym] = v }
94
+ p = new
95
+ h.each { |k, v| p[k.to_s.to_sym] = v }
96
+ p
94
97
  end
95
98
 
96
99
  # Dumps the parameter properties into a Hash.
@@ -297,8 +300,8 @@ module Libis
297
300
  # hash is added to the retrievable properties of the parameter. Likewise any property defined, that is not in the list of
298
301
  # known properties is added to the options hash. In this aspect the ::Libis::Tools::Parameter class behaves much like an
299
302
  # OpenStruct even though it is implemented as a Struct.
300
- def parameter(options = {})
301
- return self.parameter_defs[options] unless options.is_a? Hash
303
+ def parameter(name = nil, **options)
304
+ return self.parameter_defs[name.to_s.to_sym] unless name.to_s.empty?
302
305
  return nil if options.keys.empty?
303
306
  param_def = options.shift
304
307
  name = param_def.first.to_s.to_sym
@@ -1,5 +1,5 @@
1
1
  module Libis
2
2
  module Tools
3
- VERSION = '1.0.19'
3
+ VERSION = '1.1.1'
4
4
  end
5
5
  end
@@ -71,7 +71,7 @@ module Libis
71
71
  # @return [XmlDocument] new instance
72
72
  def self.from_hash(hash, options = {})
73
73
  doc = XmlDocument.new
74
- doc.document = Nokogiri::XML(Gyoku.xml(hash, options))
74
+ doc.document = Nokogiri::XML(Gyoku.xml(hash, **options))
75
75
  doc.document.encoding = 'utf-8'
76
76
  doc
77
77
  end
@@ -92,7 +92,7 @@ module Libis
92
92
  # @return [String] a string
93
93
  def to_xml(options = {})
94
94
  options = {indent: 2, encoding: 'utf-8', save_with: Nokogiri::XML::Node::SaveOptions::DEFAULT_XML}.merge(options)
95
- @document.to_xml(options)
95
+ @document.to_xml(**options)
96
96
  end
97
97
 
98
98
  # Export the XML Document to a Hash.
@@ -122,7 +122,7 @@ module Libis
122
122
  # @param [Hash] options
123
123
  # @return [Hash]
124
124
  def to_hash(options = {})
125
- Nori.new(options).parse(to_xml)
125
+ Nori.new(**options).parse(to_xml)
126
126
  end
127
127
 
128
128
  # Check if the document validates against a given XML schema file.
@@ -212,7 +212,7 @@ module Libis
212
212
  def build(at_node = nil, options = {}, &block)
213
213
  options = {encoding: 'utf-8' }.merge options
214
214
  if at_node
215
- Nokogiri::XML::Builder.new(options,at_node, &block)
215
+ Nokogiri::XML::Builder.new(options, at_node, &block)
216
216
  else
217
217
  xml = Nokogiri::XML::Builder.new(options, &block)
218
218
  @document = xml.doc
@@ -285,9 +285,7 @@ module Libis
285
285
  # - a Hash containing tag-value pairs for each attribute; the special key ':namespaces'
286
286
  # contains a Hash of namespace definitions as in {#add_namespaces}
287
287
  # @return [Nokogiri::XML::Node] the new node
288
- def add_node(*args)
289
- attributes = {}
290
- attributes = args.pop if args.last.is_a? Hash
288
+ def add_node(*args, **attributes)
291
289
  name, value, parent = *args
292
290
 
293
291
  return nil if name.nil?
@@ -306,9 +304,9 @@ module Libis
306
304
  return node if attributes.empty?
307
305
 
308
306
  namespaces = attributes.delete :namespaces
309
- add_namespaces(node, namespaces) if namespaces
307
+ add_namespaces(node, **namespaces) if namespaces
310
308
 
311
- add_attributes(node, attributes) if attributes
309
+ add_attributes(node, **attributes) if attributes
312
310
 
313
311
  node
314
312
 
@@ -332,12 +330,12 @@ module Libis
332
330
  # @param [Nokogiri::XML::Node] node node to add the attributes to
333
331
  # @param [Hash] attributes a Hash with tag - value pairs for each attribute
334
332
  # @return [Nokogiri::XML::Node] the node
335
- def add_attributes(node, attributes)
336
- XmlDocument.add_attributes node, attributes
333
+ def add_attributes(node, **attributes)
334
+ XmlDocument.add_attributes node, **attributes
337
335
  end
338
336
 
339
337
  # (see #add_attributes)
340
- def self.add_attributes(node, attributes)
338
+ def self.add_attributes(node, **attributes)
341
339
 
342
340
  attributes.each do |name, value|
343
341
  node.set_attribute name.to_s, value
@@ -371,12 +369,12 @@ module Libis
371
369
  # @param [Hash] namespaces a Hash with prefix - URI pairs for each namespace definition that should be added. The
372
370
  # special key +:node_ns+ is reserved for specifying the prefix for the node itself. To set the default
373
371
  # namespace, use the prefix +nil+
374
- def add_namespaces(node, namespaces)
375
- XmlDocument.add_namespaces node, namespaces
372
+ def add_namespaces(node, **namespaces)
373
+ XmlDocument.add_namespaces node, **namespaces
376
374
  end
377
375
 
378
376
  # (see #add_namespaces)
379
- def self.add_namespaces(node, namespaces)
377
+ def self.add_namespaces(node, **namespaces)
380
378
 
381
379
  node_ns = namespaces.delete :node_ns
382
380
  default_ns = namespaces.delete nil
data/libis-tools.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.authors = ['Kris Dekeyser']
18
18
  spec.email = ['kris.dekeyser@libis.be']
19
- spec.homepage = 'https://github.com/Kris-LIBIS/LIBIS_Tools'
19
+ spec.homepage = 'https://github.com/libis/LIBIS_Tools'
20
20
  spec.license = 'MIT'
21
21
 
22
22
  spec.platform = Gem::Platform::JAVA if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
@@ -29,18 +29,17 @@ Gem::Specification.new do |spec|
29
29
  spec.require_paths = ['lib']
30
30
  # spec.has_rdoc = 'yard'
31
31
 
32
- spec.add_development_dependency 'bundler', '> 1.6'
32
+ spec.add_development_dependency 'bundler', '> 2.2'
33
33
  spec.add_development_dependency 'rake', '~> 13.0'
34
34
  spec.add_development_dependency 'rspec', '~> 3.1'
35
- spec.add_development_dependency 'term-ansicolor', '~> 1.6'
36
- spec.add_development_dependency 'equivalent-xml', '~> 0.5'
37
- spec.add_development_dependency 'awesome_print', '~> 1.6'
35
+ spec.add_development_dependency 'term-ansicolor', '~> 1.7'
36
+ spec.add_development_dependency 'equivalent-xml', '~> 0.6'
37
+ spec.add_development_dependency 'awesome_print', '~> 1.9'
38
38
 
39
- spec.add_runtime_dependency 'nokogiri', '~> 1.6'
40
- spec.add_runtime_dependency 'gyoku', '~> 1.3'
39
+ spec.add_runtime_dependency 'nokogiri', '~> 1.15'
40
+ spec.add_runtime_dependency 'gyoku', '~> 1.4'
41
41
  spec.add_runtime_dependency 'nori', '~> 2.6'
42
42
  spec.add_runtime_dependency 'recursive-open-struct', '>= 1.1.3'
43
- spec.add_runtime_dependency 'parslet', '~> 1.7'
44
43
  spec.add_runtime_dependency 'simple_xlsx_reader', '~> 1.0'
45
44
  spec.add_runtime_dependency 'logging', '~> 2.0'
46
45
  spec.add_runtime_dependency 'concurrent-ruby', '~> 1.0'
@@ -10,9 +10,9 @@ describe 'Libis::Tools::Spreadsheet' do
10
10
  let(:ss) {
11
11
  Libis::Tools::Spreadsheet.new(
12
12
  File.join(path, file_name),
13
- { required: required_headers,
14
- optional: optional_headers
15
- }.merge(options)
13
+ required: required_headers,
14
+ optional: optional_headers,
15
+ **options
16
16
  )
17
17
  }
18
18
 
@@ -37,7 +37,7 @@ describe 'TempFile' do
37
37
 
38
38
  it 'created' do
39
39
  f = Libis::Tools::TempFile.file
40
- expect(File.exists?(f.path)).to be_truthy
40
+ expect(File.exist?(f.path)).to be_truthy
41
41
  f.close
42
42
  f.delete
43
43
  end
@@ -61,14 +61,14 @@ describe 'TempFile' do
61
61
  f = Libis::Tools::TempFile.file
62
62
  f.close
63
63
  f.unlink
64
- expect(File.exists?(f.path)).to be_falsey
64
+ expect(File.exist?(f.path)).to be_falsey
65
65
  end
66
66
 
67
67
  it 'can be deleted' do
68
68
  f = Libis::Tools::TempFile.file
69
69
  f.close
70
70
  f.delete
71
- expect(File.exists?(f.path)).to be_falsey
71
+ expect(File.exist?(f.path)).to be_falsey
72
72
  end
73
73
 
74
74
  end
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.19
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kris Dekeyser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-06 00:00:00.000000000 Z
11
+ date: 2024-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.6'
19
+ version: '2.2'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.6'
26
+ version: '2.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,70 +58,70 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.6'
61
+ version: '1.7'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.6'
68
+ version: '1.7'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: equivalent-xml
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.5'
75
+ version: '0.6'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.5'
82
+ version: '0.6'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: awesome_print
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.6'
89
+ version: '1.9'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '1.6'
96
+ version: '1.9'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: nokogiri
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '1.6'
103
+ version: '1.15'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '1.6'
110
+ version: '1.15'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: gyoku
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '1.3'
117
+ version: '1.4'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '1.3'
124
+ version: '1.4'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: nori
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -150,20 +150,6 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: 1.1.3
153
- - !ruby/object:Gem::Dependency
154
- name: parslet
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - "~>"
158
- - !ruby/object:Gem::Version
159
- version: '1.7'
160
- type: :runtime
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - "~>"
165
- - !ruby/object:Gem::Version
166
- version: '1.7'
167
153
  - !ruby/object:Gem::Dependency
168
154
  name: simple_xlsx_reader
169
155
  requirement: !ruby/object:Gem::Requirement
@@ -367,7 +353,7 @@ files:
367
353
  - test/test_helper.rb
368
354
  - test/webservices/test_ca_item_info.rb
369
355
  - test/webservices/test_ca_search.rb
370
- homepage: https://github.com/Kris-LIBIS/LIBIS_Tools
356
+ homepage: https://github.com/libis/LIBIS_Tools
371
357
  licenses:
372
358
  - MIT
373
359
  metadata: {}
@@ -386,7 +372,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
386
372
  - !ruby/object:Gem::Version
387
373
  version: '0'
388
374
  requirements: []
389
- rubygems_version: 3.3.7
375
+ rubygems_version: 3.4.10
390
376
  signing_key:
391
377
  specification_version: 4
392
378
  summary: LIBIS toolbox.