dba 2.0.0 → 2.1.0

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: 7a165d5ff98a815002bea9e1d54744639aba99bb1e678d66afe8743ffcb2fe30
4
- data.tar.gz: dadb161b89dde586047a0a8b6aded72be9499db6c48a27c2e9c57c7172a9c1a9
3
+ metadata.gz: 6d8a51736a883e5fa3608fd0429dbf3a819f2903a2da62d1df26d234952c899d
4
+ data.tar.gz: bcdb786558aab8e9235324eeb06e073bff126c73abd680213f030d8560cc5306
5
5
  SHA512:
6
- metadata.gz: 5f8033d0911e384525fb846228840d4ff5c7527df5c5e0d64fedc6fc158e6e809b5d88ab57483592954e8313961cd23696ae030efe97b7f06a342bfbd40c8c7e
7
- data.tar.gz: 461b1d4e5eb81151aa5350c2f09362da3d6a31a42c959edb48a5dbd97206a239c3f6b4ad8e166e4185df2e6569f63445443af30a41d1064f9679c8dae7aa2a0f
6
+ metadata.gz: 5fefa4be5caa1d897e9a3e330b6535351f5f503cc4b351e37cf8a7ef8b30f93555491bf5c09836c8b43f13c503d3783bb7e9173a2a4c2ca696bc8b5b1c903379
7
+ data.tar.gz: c6aea9949fe0b38718bee070cc3772b57b1ecb060b89c6fd497baa27dc30a0b2ed0edbc9b51157d8373ca057fbd85cb0a858f7f7665b3ba94bb99bcee095cc83
data/CHANGES.md CHANGED
@@ -1,3 +1,12 @@
1
+ # 2.1.0
2
+
3
+ * Fixed arity check for commands with optional arguments
4
+
5
+ * Added support for .jsonl extension to dump and load commands
6
+
7
+ * Added support for .ndjson extension to dump and load commands
8
+
9
+
1
10
  # 2.0.0
2
11
 
3
12
  * **Required ruby version is now 2.5.0**
data/dba.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'dba'
3
- s.version = '2.0.0'
3
+ s.version = '2.1.0'
4
4
  s.license = 'GPL-3.0'
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.authors = ['Tim Craft']
data/lib/dba/command.rb CHANGED
@@ -1,4 +1,16 @@
1
1
  class DBA::Command
2
+ def self.arity_check(args)
3
+ parameters = instance_method(:call).parameters
4
+
5
+ required, optional = parameters.partition { |(type, name)| type == :req }
6
+
7
+ expected = optional.empty? ? required.size : (required.size .. required.size + optional.size)
8
+
9
+ unless expected === args.size
10
+ raise DBA::Error, "incorrect number of arguments (given #{args.size}, expected #{expected})"
11
+ end
12
+ end
13
+
2
14
  def initialize(database)
3
15
  self.database = database
4
16
  end
data/lib/dba/database.rb CHANGED
@@ -64,12 +64,16 @@ module DBA::Database
64
64
  File.exist?('.env')
65
65
  end
66
66
 
67
+ def database_config_path
68
+ File.join('config', 'database.yml')
69
+ end
70
+
67
71
  def database_config?
68
- File.exist?('config/database.yml')
72
+ File.exist?(database_config_path)
69
73
  end
70
74
 
71
75
  def database_config
72
- YAML.load(ERB.new(File.read('config/database.yml')).result)
76
+ YAML.load(ERB.new(File.read(database_config_path)).result)
73
77
  end
74
78
 
75
79
  def development_database_args
data/lib/dba/dump.rb CHANGED
@@ -3,7 +3,9 @@
3
3
  class DBA::Dump < DBA::Command
4
4
  ADAPTERS = {
5
5
  'csv' => :CSV,
6
+ 'jsonl' => :LDJSON,
6
7
  'ldjson' => :LDJSON,
8
+ 'ndjson' => :LDJSON,
7
9
  'yml' => :YAML,
8
10
  'yaml' => :YAML
9
11
  }
data/lib/dba/load.rb CHANGED
@@ -3,7 +3,9 @@
3
3
  class DBA::Load < DBA::Command
4
4
  ADAPTERS = {
5
5
  '.csv' => :CSV,
6
+ '.jsonl' => :LDJSON,
6
7
  '.ldjson' => :LDJSON,
8
+ '.ndjson' => :LDJSON,
7
9
  '.yml' => :YAML,
8
10
  '.yaml' => :YAML
9
11
  }
@@ -26,7 +28,7 @@ class DBA::Load < DBA::Command
26
28
 
27
29
  def file_list(path)
28
30
  if File.directory?(path)
29
- Dir.glob(File.join(path, '*.{csv,ldjson,yml,yaml}'))
31
+ Dir.glob(File.join(path, '*.{csv,jsonl,ldjson,ndjson,yml,yaml}'))
30
32
  else
31
33
  [path]
32
34
  end
data/lib/dba/shell.rb CHANGED
@@ -16,11 +16,7 @@ module DBA::Shell
16
16
 
17
17
  command = DBA.const_get(command)
18
18
 
19
- arity = command.instance_method(:call).arity
20
-
21
- if arity >= 0 && args.size != arity
22
- raise DBA::Error, "incorrect number of args (given #{args.size}, expected #{arity})"
23
- end
19
+ command.arity_check(args)
24
20
 
25
21
  database = DBA::Database.connect
26
22
 
data/lib/dba.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2019-2021 TIMCRAFT
1
+ # Copyright (c) 2019-2022 TIMCRAFT
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU General Public License as published by
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dba
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Craft
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-06 00:00:00.000000000 Z
11
+ date: 2022-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  - !ruby/object:Gem::Version
115
115
  version: '0'
116
116
  requirements: []
117
- rubygems_version: 3.1.4
117
+ rubygems_version: 3.3.7
118
118
  signing_key:
119
119
  specification_version: 4
120
120
  summary: See description