lucarecord 0.7.5 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc67fbc3655278f3be52dd82f3994560fa72f3f043f272d40c1bd478a04e6126
4
- data.tar.gz: aaff85cd17e1066344c915326b8626d312ae4add22263e198084979d624750f3
3
+ metadata.gz: 43e4eb24c71ea14be0af8bcaa20ff15806b3f13fde5d9b0766f4554c725354e0
4
+ data.tar.gz: 76a9001610ac76dcb2904c500bce4283ce57612e6f7ac0d42da76f818eadf05a
5
5
  SHA512:
6
- metadata.gz: e801b4ea786880fc442bbdf8c995abf1828f2a3e6ed705b8983178687da605d738dbaed3832c08bb718c7c5f23d4a540f43a55e4bd3cd51a395727ec08755e28
7
- data.tar.gz: 9367c58a1b4ae9563f91f603f82dfdd9c674b2931cde3677e9d6ac4bc22eb3563e5bc6bf7a9fb4550473d19e319c78f0abe8c77cc1ff8b798848577b4c0fbcb0
6
+ metadata.gz: 493c82233012f4db8e001a04c65d8b010979835e61d04d6f6c0659de6b0557fef8085efa433748f63fdb02548943020a6574caaca24a2663d58eee8e5cad5235
7
+ data.tar.gz: 458ebf81b4639ec305e6b99cd0ebbfe3617d46538487a9cf781cdb32f3ca483b02b9c90de746457ddfc26d80e26a4169e688796beb0367b788df532d465d36e7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## LucaRecord 0.8.1
2
+
3
+ * Merge config in parent directory, when the parent is git repo root.
4
+ * initial mTLS support for SMTP.
5
+ * change deprecated nushell option `--ignore-errors` -> `--optional`.
6
+
7
+ ## LucaRecord 0.8.0
8
+
9
+ * Expand SMTP options aligning with mail gem.
10
+
1
11
  ## LucaRecord 0.7.5
2
12
 
3
13
  * `LucaSupport::Code.parse_current() / take_current()` now accepts Date object.
@@ -297,25 +297,7 @@ module LucaRecord # :nodoc:
297
297
  config = {
298
298
  'decimal_separator' => '.',
299
299
  'thousands_separator' => ','
300
- }
301
- begin
302
- config.merge!(YAML.safe_load(
303
- File.read(Pathname(CONST.configdir) / 'config.yml'),
304
- permitted_classes: [Date]
305
- ))
306
- rescue Errno::ENOENT
307
- STDERR.puts "INFO: config.yml not found. Continue with default settings."
308
- end
309
- if ext_conf
310
- begin
311
- config.merge!(YAML.safe_load(
312
- File.read(Pathname(CONST.configdir) / ext_conf),
313
- permitted_classes: [Date]
314
- ))
315
- rescue Errno::ENOENT
316
- STDERR.puts "WARN: #{ext_conf} not found. Extended options are not effective."
317
- end
318
- end
300
+ }.merge!(load_config(CONST.configdir, ext_conf: ext_conf))
319
301
  config['decimal_num'] ||= config['country'] == 'jp' ? 0 : 2
320
302
  CONST.set_config(config)
321
303
  end
@@ -341,6 +323,62 @@ module LucaRecord # :nodoc:
341
323
  digest
342
324
  end
343
325
 
326
+ def load_config(path = nil, ext_conf: nil)
327
+ dir, file = if (filepath = Pathname(path)).file?
328
+ [filepath.dirname, filepath]
329
+ elsif filepath.directory?
330
+ [filepath, filepath / 'config.yml']
331
+ else
332
+ nil
333
+ end
334
+ return {} if dir.nil?
335
+
336
+ {}.tap do |config|
337
+ begin
338
+ if ! dir.join('.git').exist? \
339
+ && (parent = dir.parent).join('.git/objects').directory? \
340
+ && (parent_config = parent.join('config.yml')).file?
341
+ config.merge!(YAML.safe_load(
342
+ parent_config.read,
343
+ permitted_classes: [Date]
344
+ ))
345
+ end
346
+ end
347
+ begin
348
+ part = YAML.safe_load(
349
+ file.read,
350
+ permitted_classes: [Date]
351
+ )
352
+ config.merge!(part) do |_k, v_self, v_new|
353
+ if v_self.is_a? Hash
354
+ v_self.merge(v_new)
355
+ else
356
+ v_new
357
+ end
358
+ end
359
+ rescue Errno::ENOENT
360
+ STDERR.puts "INFO: #{file} not found. Continue with default settings."
361
+ end
362
+ if ext_conf
363
+ begin
364
+ part = YAML.safe_load(
365
+ (Pathname(CONST.configdir) / ext_conf).read,
366
+ permitted_classes: [Date]
367
+ )
368
+ config.merge!(part) do |_k, v_self, v_new|
369
+ if v_self.is_a? Hash
370
+ v_self.merge(v_new)
371
+ else
372
+ v_new
373
+ end
374
+ rescue Errno::ENOENT
375
+ STDERR.puts "WARN: #{ext_conf} not found. Extended options are not effective."
376
+ end
377
+ end
378
+ end
379
+ end
380
+ end
381
+
344
382
  private
345
383
 
346
384
  # define new transaction ID & write data at once
@@ -532,14 +570,5 @@ module LucaRecord # :nodoc:
532
570
  end
533
571
  end
534
572
  end
535
-
536
- def load_config(path = nil)
537
- path = path.to_s
538
- if File.exist?(path)
539
- YAML.safe_load(File.read(path), permitted_classes: [Date])
540
- else
541
- {}
542
- end
543
- end
544
573
  end
545
574
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LucaRecord
4
- VERSION = '0.7.5'
4
+ VERSION = '0.8.1'
5
5
  end
@@ -1,4 +1,6 @@
1
1
  require "mail"
2
+ require 'net/smtp'
3
+ require 'openssl'
2
4
  require "pathname"
3
5
  require "luca_record/io"
4
6
 
@@ -8,7 +10,7 @@ module LucaSupport
8
10
 
9
11
  def initialize(mail=nil, pjdir=nil)
10
12
  @pjdir = pjdir || Dir.pwd
11
- @config = load_config( Pathname(@pjdir) + "config.yml" )
13
+ @config = self.class.load_config(@pjdir)
12
14
  @mail = mail
13
15
  set_message_default
14
16
  @host = set_host
@@ -16,18 +18,26 @@ module LucaSupport
16
18
 
17
19
  def deliver
18
20
  # mail gem accepts hash for 2nd param, not keywords
19
- @mail.delivery_method(:smtp, @host)
21
+ if conn = conn_with_tls
22
+ @mail.delivery_method(:smtp_connection, { connection: conn })
23
+ else
24
+ @mail.delivery_method(:smtp, @host)
25
+ end
20
26
  @mail.deliver
21
27
  end
22
28
 
23
29
  def set_host
24
30
  {
25
- authentication: :plain,
26
31
  address: mail_config("address"),
27
32
  port: mail_config("port"),
28
- doomain: mail_config("domain"),
33
+ domain: mail_config("domain"),
29
34
  user_name: mail_config("user_name"),
30
- password: mail_config("password")
35
+ password: mail_config("password"),
36
+ authentication: mail_config("authentication"),
37
+ enable_starttls: mail_config("enable_starttls"),
38
+ openssl_verify_mode: mail_config("openssl_verify_mode"),
39
+ ssl: mail_config("ssl"),
40
+ tls: mail_config("tls"),
31
41
  }
32
42
  end
33
43
 
@@ -40,5 +50,28 @@ module LucaSupport
40
50
  @mail.from ||= @config.dig("mail", "from")
41
51
  @mail.cc ||= @config.dig("mail", "cc")
42
52
  end
53
+
54
+ private
55
+
56
+ def conn_with_tls
57
+ ca_file = mail_config("ca_file")
58
+ c_cert_path = mail_config("client_cert")
59
+ c_key_path = mail_config("client_key")
60
+ return nil if ca_file.nil? && c_cert_path.nil? && c_key_path.nil?
61
+
62
+ tls_ctx = OpenSSL::SSL::SSLContext.new
63
+ tls_ctx.cert = c_cert_path ?
64
+ OpenSSL::X509::Certificate.new(File.read(c_cert_path)) : nil
65
+ tls_ctx.key = c_key_path ?
66
+ OpenSSL::PKey::RSA.new(File.read(c_key_path)) : nil
67
+ tls_ctx.ca_file = ca_file
68
+ tls_ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER if ca_file || @host[:openssl_verify_mode]
69
+
70
+ conn = Net::SMTP.new(@host[:address], @host[:port])
71
+ conn.enable_tls(tls_ctx)
72
+ conn.start(helo: @host[:domain], user: @host[:user_name], password: @host[:password], authtype: @host[:authentication])
73
+ conn
74
+ end
75
+
43
76
  end
44
77
  end
@@ -58,7 +58,7 @@ module LucaSupport
58
58
  select = if columns.empty?
59
59
  ''
60
60
  else
61
- '| select --ignore-errors ' + columns.map { |col| col.gsub(/[^a-zA-Z0-9_-]/, '') }.join(' ')
61
+ '| select --optional ' + columns.map { |col| col.gsub(/[^a-zA-Z0-9_-]/, '') }.join(' ')
62
62
  end
63
63
  render = case mode
64
64
  when :explore
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lucarecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chuma Takahiro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-11 00:00:00.000000000 Z
11
+ date: 2025-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -78,7 +78,7 @@ files:
78
78
  - lib/luca_support/view.rb
79
79
  homepage: https://github.com/chumaltd/luca/tree/master/lucarecord
80
80
  licenses:
81
- - GPL
81
+ - GPL-3.0-or-later
82
82
  metadata:
83
83
  homepage_uri: https://github.com/chumaltd/luca/tree/master/lucarecord
84
84
  source_code_uri: https://github.com/chumaltd/luca/tree/master/lucarecord
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  - !ruby/object:Gem::Version
99
99
  version: '0'
100
100
  requirements: []
101
- rubygems_version: 3.4.10
101
+ rubygems_version: 3.4.20
102
102
  signing_key:
103
103
  specification_version: 4
104
104
  summary: ERP File operation framework