csv2psql 0.0.14 → 0.0.15

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
  SHA1:
3
- metadata.gz: 18591293889ef7109ae2bb0fa587ce87e85ea334
4
- data.tar.gz: d34f8d623012e56f62af73f394975b2e8938c82c
3
+ metadata.gz: 764ba1f133551d811fce81b53bda7b9fa53c3f31
4
+ data.tar.gz: d5501dd56420a37048ec43c08a61bd6070bc054d
5
5
  SHA512:
6
- metadata.gz: b649b2969b116054245eb4284e6d5a4a9290be40b7b19d7d2aa602d5badb89939ddcdbb25bba5e073b9ba635bee9e048960e4ec23ad6d766b2dbf11d3ea8a718
7
- data.tar.gz: 5bdd371ba418aed540bea5b2578cd331770429853f54805e5c4a56bd75f448a585643fa52d61e7f071ff617f1e3e4b00291e250019fd97b4434868d54d0b92d5
6
+ metadata.gz: 33e26a12dbce605939c42199023a321da5e871ddd7664b6ad221dffacb5ad3cf7b557e12d40ae01647fc551f7a7bff89cdaa53fca29e66abb6f8a6877e4443b8
7
+ data.tar.gz: 78b0315b8a67a9add8eb58fd4ac62df82f731f37a796fe90cdbf968af1bf22ed3f46a5f41db02542dd0cca1a72e35f1f72e2f4b389704bf90c45404484f002a1
@@ -14,6 +14,8 @@ module Csv2Psql
14
14
 
15
15
  class << self
16
16
  def analyze(val)
17
+ return false
18
+
17
19
  match = val && val.match(RE)
18
20
  !match.nil?
19
21
  end
@@ -33,20 +33,13 @@ formats = {
33
33
  end
34
34
  }
35
35
 
36
- cmds = {
37
- f: {
38
- desc: 'Output format',
39
- type: String,
40
- default_value: formats.keys.first
41
- }
42
- }
43
-
44
36
  desc 'Analyze csv file'
45
37
  command :analyze do |c|
46
- c.flag [:f, :format], cmds[:f]
47
-
38
+ c.desc "Output format #{formats.keys.join(', ')}"
39
+ c.default_value(formats.keys.first)
40
+ c.flag [:f, :format]
48
41
  c.action do |global_options, options, args|
49
- fail ArgumentError, 'No file to analyze specified' if args.empty?
42
+ help_now!('No file to analyze specified!') if args.empty?
50
43
 
51
44
  opts = {}.merge(global_options).merge(options)
52
45
 
@@ -3,44 +3,30 @@
3
3
  require_relative '../../convert/convert'
4
4
  require_relative '../../processor/processor'
5
5
 
6
- cmds = {
7
- t: {
8
- desc: 'Table to insert to',
9
- type: String,
10
- default_value: Csv2Psql::Processor::DEFAULT_OPTIONS[:table]
11
- },
12
-
13
- transaction: {
14
- desc: 'Import in transaction block',
15
- default_value: Csv2Psql::Processor::DEFAULT_OPTIONS[:transaction]
16
- },
17
-
18
- 'create-table' => {
19
- desc: 'Crate SQL Table before inserts',
20
- default_value: Csv2Psql::Processor::DEFAULT_OPTIONS['create-table']
21
- },
22
-
23
- 'drop-table' => {
24
- desc: 'Drop SQL Table before inserts',
25
- default_value: Csv2Psql::Processor::DEFAULT_OPTIONS['drop-table']
26
- },
27
-
28
- 'truncate-table' => {
29
- desc: 'Truncate SQL Table before inserts',
30
- default_value: Csv2Psql::Processor::DEFAULT_OPTIONS['truncate-table']
31
- }
32
- }
33
-
34
6
  desc 'Convert csv file'
35
7
  command :convert do |c|
36
- c.flag [:t, :table], cmds[:t]
37
- c.switch [:transaction], cmds[:transaction]
38
- c.switch ['create-table'], cmds['create-table']
39
- c.switch ['drop-table'], cmds['drop-table']
40
- c.switch ['truncate-table'], cmds['truncate-table']
8
+ c.desc 'Table to insert to'
9
+ c.default_value Csv2Psql::Processor::DEFAULT_OPTIONS[:table]
10
+ c.flag [:t, :table]
11
+
12
+ c.desc 'Import in transaction block'
13
+ c.default_value Csv2Psql::Processor::DEFAULT_OPTIONS[:transaction]
14
+ c.switch [:transaction]
15
+
16
+ c.desc 'Crate SQL Table before inserts'
17
+ c.default_value Csv2Psql::Processor::DEFAULT_OPTIONS['create-table']
18
+ c.switch ['create-table']
19
+
20
+ c.desc 'Drop SQL Table before inserts'
21
+ c.default_value Csv2Psql::Processor::DEFAULT_OPTIONS['drop-table']
22
+ c.switch ['drop-table']
23
+
24
+ c.desc 'Truncate SQL Table before inserts'
25
+ c.default_value Csv2Psql::Processor::DEFAULT_OPTIONS['truncate-table']
26
+ c.switch ['truncate-table']
41
27
 
42
28
  c.action do |global_options, options, args|
43
- fail ArgumentError, 'No file to convert specified' if args.empty?
29
+ help_now!('No file to convert specified!') if args.empty?
44
30
 
45
31
  opts = {}.merge(global_options).merge(options)
46
32
  Csv2Psql::Convert.convert(args, opts)
@@ -42,20 +42,13 @@ formats = {
42
42
  end
43
43
  }
44
44
 
45
- cmds = {
46
- f: {
47
- desc: 'Output format',
48
- type: String,
49
- default_value: formats.keys.first
50
- }
51
- }
52
-
53
45
  desc 'Generate schema for file'
54
46
  command :schema do |c|
55
- c.flag [:f, :format], cmds[:f]
56
-
47
+ c.desc "Output format - #{formats.keys.join(', ')}"
48
+ c.default_value(formats.keys.first)
49
+ c.flag [:f, :format]
57
50
  c.action do |global_options, options, args|
58
- fail ArgumentError, 'No file to analyze specified' if args.empty?
51
+ help_now!('No file to analyze specified!') if args.empty?
59
52
 
60
53
  opts = {}.merge(global_options).merge(options)
61
54
 
@@ -5,6 +5,6 @@ require_relative '../../version'
5
5
  desc 'Print version info'
6
6
  command :version do |c|
7
7
  c.action do |_global_options, _options, _args|
8
- pp Csv2Psql::VERSION
8
+ puts Csv2Psql::VERSION
9
9
  end
10
10
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Csv2Psql module
4
4
  module Csv2Psql
5
- VERSION = '0.0.14'
5
+ VERSION = '0.0.15'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csv2psql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Korcak