dba 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +9 -0
- data/dba.gemspec +1 -1
- data/lib/dba/command.rb +12 -0
- data/lib/dba/database.rb +6 -2
- data/lib/dba/dump.rb +2 -0
- data/lib/dba/load.rb +3 -1
- data/lib/dba/shell.rb +1 -5
- data/lib/dba.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d8a51736a883e5fa3608fd0429dbf3a819f2903a2da62d1df26d234952c899d
|
4
|
+
data.tar.gz: bcdb786558aab8e9235324eeb06e073bff126c73abd680213f030d8560cc5306
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
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?(
|
72
|
+
File.exist?(database_config_path)
|
69
73
|
end
|
70
74
|
|
71
75
|
def database_config
|
72
|
-
YAML.load(ERB.new(File.read(
|
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
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
|
-
|
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
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.
|
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:
|
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.
|
117
|
+
rubygems_version: 3.3.7
|
118
118
|
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: See description
|