tapsoob 0.4.23 → 0.4.26

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: 02ae7de93cd8aeddb465cd48bafe2e33eec932a72a946d6dbde9c05e5d8232d1
4
- data.tar.gz: c7e6a34e96cfebb2a0cd16fdd3f6f30d84abd918b17f1a78392a08e53783762b
3
+ metadata.gz: b2b2be0ffd99c3fc27ce017d8ce75232aa5d8577a2505d70091251a640c83b0a
4
+ data.tar.gz: bcfc16b261e43eabe032e0e2b6c497e62e378e65ff60309eb702128a97d2fb21
5
5
  SHA512:
6
- metadata.gz: af637e1c4486956987ac94dbac997b77d48d34789333161701618588849db8ef50396b607c29f74613bba88f410a608f7ae4f4856296e4a33e1672f2540146a4
7
- data.tar.gz: 70b0f436ed34583a25a8715acd7c60dea54eac1728c7e615bc64ba4d9341ab066944806fd63bfcecf46c1b2120a10ad39e71109ea4b6225e676c9fe3fc2d03db
6
+ metadata.gz: 7390dc58317da7e8316ba6d32fac40064a82eaf90ce5091328c5227577a283e371e14993a823f104149ba01b6e2069c35817b7619ba25f25259dd01d65c0928e
7
+ data.tar.gz: 016ee37bcfe9db90355fc654ae9a7d7b6c23547eb5f1451aa5cdcf73789b423e64f15d7d7f62c771b35af0cde9bdc32467eb815de44a895a3d4a313ce4c5595f
@@ -12,7 +12,6 @@ module Tapsoob
12
12
  class DataStream < Thor
13
13
  desc "pull DATABASE_URL [DUMP_PATH]", "Pull data from a database."
14
14
  option :chunksize, desc: "Initial chunksize", default: 1000, type: :numeric, aliases: "-c"
15
- option :filter, desc: "Regex Filter for tables", type: :string, aliases: "-f"
16
15
  option :tables, desc: "Shortcut to filter on a list of tables", type: :array, aliases: "-t"
17
16
  option :"exclude-tables", desc: "Shortcut to exclude a list of tables", type: :array, aliases: "-e"
18
17
  option :progress, desc: "Show progress", default: true, type: :boolean, aliases: "-p"
@@ -24,7 +23,6 @@ module Tapsoob
24
23
 
25
24
  desc "push DATABASE_URL [DUMP_PATH]", "Push data to a database."
26
25
  option :chunksize, desc: "Initial chunksize", default: 1000, type: :numeric, aliases: "-c"
27
- option :filter, desc: "Regex Filter for tables", type: :string, aliases: "-f"
28
26
  option :tables, desc: "Shortcut to filter on a list of tables", type: :array, aliases: "-t"
29
27
  option :"exclude-tables", desc: "Shortcut to exclude a list of tables", type: :array, aliases: "-e"
30
28
  option :progress, desc: "Show progress", default: true, type: :boolean, aliases: "-p"
@@ -65,6 +63,7 @@ module Tapsoob
65
63
  # Default options
66
64
  opts = {
67
65
  progress: options[:progress],
66
+ tables: options[:tables],
68
67
  debug: options[:debug]
69
68
  }
70
69
 
@@ -78,15 +77,6 @@ module Tapsoob
78
77
  opts[:default_chunksize] = (options[:chunksize] < 10 ? 10 : options[:chunksize])
79
78
  end
80
79
 
81
- # Regex filter
82
- opts[:table_filter] = options[:filter] if options[:filter]
83
-
84
- # Table filter
85
- if options[:tables]
86
- r_tables = options[:tables].collect { |t| "^#{t}" }.join("|")
87
- opts[:table_filter] = "#{r_tables}"
88
- end
89
-
90
80
  # Exclude tables
91
81
  opts[:exclude_tables] = options[:"exclude-tables"] if options[:"exclude-tables"]
92
82
 
@@ -15,7 +15,6 @@ module Tapsoob
15
15
  option :resume, desc: "Resume a Tapsoob Session from a stored file", type: :string, aliases: "-r"
16
16
  option :chunksize, desc: "Initial chunksize", default: 1000, type: :numeric, aliases: "-c"
17
17
  option :"disable-compression", desc: "Disable Compression", default: false, type: :boolean, aliases: "-g"
18
- option :filter, desc: "Regex Filter for tables", type: :string, aliases: "-f"
19
18
  option :tables, desc: "Shortcut to filter on a list of tables", type: :array, aliases: "-t"
20
19
  option :"exclude-tables", desc: "Shortcut to exclude a list of tables", type: :array, aliases: "-e"
21
20
  option :debug, desc: "Enable debug messages", default: false, type: :boolean, aliases: "-d"
@@ -35,7 +34,6 @@ module Tapsoob
35
34
  option :resume, desc: "Resume a Tapsoob Session from a stored file", type: :string, aliases: "-r"
36
35
  option :chunksize, desc: "Initial chunksize", default: 1000, type: :numeric, aliases: "-c"
37
36
  option :"disable-compression", desc: "Disable Compression", default: false, type: :boolean, aliases: "-g"
38
- option :filter, desc: "Regex Filter for tables", type: :string, aliases: "-f"
39
37
  option :tables, desc: "Shortcut to filter on a list of tables", type: :array, aliases: "-t"
40
38
  option :"exclude-tables", desc: "Shortcut to exclude a list of tables", type: :array, aliases: "-e"
41
39
  option :purge, desc: "Purge data in tables prior to performing the import", default: false, type: :boolean, aliases: "-p"
@@ -70,6 +68,7 @@ module Tapsoob
70
68
  skip_schema: options[:"skip-schema"],
71
69
  indexes_first: options[:"indexes_first"],
72
70
  disable_compression: options[:"disable-compression"],
71
+ tables: options[:tables],
73
72
  debug: options[:debug]
74
73
  }
75
74
 
@@ -92,15 +91,6 @@ module Tapsoob
92
91
  opts[:default_chunksize] = (options[:chunksize] < 10 ? 10 : options[:chunksize])
93
92
  end
94
93
 
95
- # Regex filter
96
- opts[:table_filter] = options[:filter] if options[:filter]
97
-
98
- # Table filter
99
- if options[:tables]
100
- r_tables = options[:tables].collect { |t| "^#{t}" }.join("|")
101
- opts[:table_filter] = "#{r_tables}"
102
- end
103
-
104
94
  # Exclude tables
105
95
  opts[:exclude_tables] = options[:"exclude-tables"] if options[:"exclude-tables"]
106
96
 
@@ -30,7 +30,7 @@ module Tapsoob
30
30
  end
31
31
 
32
32
  def table_filter
33
- opts[:table_filter]
33
+ opts[:tables] || []
34
34
  end
35
35
 
36
36
  def exclude_tables
@@ -38,19 +38,18 @@ module Tapsoob
38
38
  end
39
39
 
40
40
  def apply_table_filter(tables)
41
- return tables unless table_filter || exclude_tables
41
+ return tables if table_filter.empty? && exclude_tables.empty?
42
42
 
43
- re = table_filter ? Regexp.new(table_filter) : nil
44
43
  if tables.kind_of?(Hash)
45
44
  ntables = {}
46
45
  tables.each do |t, d|
47
- if !exclude_tables.include?(t.to_s) && (!re || !re.match(t.to_s).nil?)
46
+ if !exclude_tables.include?(t.to_s) && (!table_filter.empty? && table_filter.include?(t.to_s))
48
47
  ntables[t] = d
49
48
  end
50
49
  end
51
50
  ntables
52
51
  else
53
- tables.reject { |t| exclude_tables.include?(t.to_s) || (re && re.match(t.to_s).nil?) }
52
+ tables.reject { |t| exclude_tables.include?(t.to_s) }.select { |t| table_filter.include?(t.to_s) }
54
53
  end
55
54
  end
56
55
 
@@ -182,7 +181,7 @@ module Tapsoob
182
181
  schema_data = Tapsoob::Schema.dump_table(database_url, table_name)
183
182
  log.debug "Table: #{table_name}\n#{schema_data}\n"
184
183
  output = Tapsoob::Utils.export_schema(dump_path, table_name, schema_data)
185
- puts output if output
184
+ puts output if dump_path.nil? && output
186
185
  progress.inc(1)
187
186
  end
188
187
  progress.finish
@@ -290,7 +289,7 @@ module Tapsoob
290
289
  def pull_indexes
291
290
  log.info "Receiving indexes"
292
291
 
293
- raw_idxs = Tapsoob::Utils.schema_bin(:indexes_individual, database_url)
292
+ raw_idxs = Tapsoob::Schema.indexes_individual(database_url)
294
293
  idxs = (raw_idxs && raw_idxs.length >= 2 ? JSON.parse(raw_idxs) : {})
295
294
 
296
295
  apply_table_filter(idxs).each do |table, indexes|
@@ -298,7 +297,7 @@ module Tapsoob
298
297
  progress = ProgressBar.new(table, indexes.size)
299
298
  indexes.each do |idx|
300
299
  output = Tapsoob::Utils.export_indexes(dump_path, table, idx)
301
- puts output if output
300
+ puts output if dump_path.nil? && output
302
301
  progress.inc(1)
303
302
  end
304
303
  progress.finish
@@ -309,7 +308,7 @@ module Tapsoob
309
308
  log.info "Resetting sequences"
310
309
 
311
310
  output = Tapsoob::Utils.schema_bin(:reset_db_sequences, database_url)
312
- puts output if output
311
+ puts output if dump_path.nil? && output
313
312
  end
314
313
  end
315
314
 
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Tapsoob
3
- VERSION = "0.4.23".freeze
3
+ VERSION = "0.4.26".freeze
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tapsoob
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.23
4
+ version: 0.4.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Félix Bellanger
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-10-20 00:00:00.000000000 Z
12
+ date: 2022-01-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ripl
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  - !ruby/object:Gem::Version
150
150
  version: '0'
151
151
  requirements: []
152
- rubygems_version: 3.1.6
152
+ rubygems_version: 3.2.32
153
153
  signing_key:
154
154
  specification_version: 4
155
155
  summary: Simple tool to import/export databases.