tapsoob 0.5.21 → 0.5.23

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: 0e98f326b61791afec42fef5b7d200b91578f86cfb0a6b9cd3dcbd374770cf6d
4
- data.tar.gz: 721a6f487de1f2a81c1b45d891588b5c50d7047ba6b5539df8b9c92bd6761def
3
+ metadata.gz: d7a84b5a6f4398257b459a0a8b74ff67bfcac3f50620b7e7e72c9ebd513b5211
4
+ data.tar.gz: 037127603d8cae32df3a0b71d2ffd89f4631632ee1d5d726e6105d2e5e0fccee
5
5
  SHA512:
6
- metadata.gz: 550ca33cca8ff7efccb80d52f52e7f7826ab52bfc932f5da27f2a3c7c2dffc7049fe20495c2908a0eff1a9a4b7d38cc933e977a1856ef4044d57d1f8f0d61cfc
7
- data.tar.gz: 9a88b837cfe093ec973655016343f70602d71682aea6595987deccabd37fdeac13567d6cc8e7331e5c9134569317b0d238fd1f5f4005d0a8e1601bccd934b510
6
+ metadata.gz: 5158318d197305651b772044b98a614638d3c1e3e540ade7e1997b2799fef2607914442c1ce4050023516cef8fdec00c4e31379720288b6ea2714e59840243d5
7
+ data.tar.gz: 4bba24e4863a6034611da2d055766e87deb680e63291e32ef13993364937c109f1979799496700656edfb24dfa1173883d34303c188598842584f54340faca09
@@ -36,7 +36,7 @@ module Tapsoob
36
36
  opts = parse_opts(options)
37
37
 
38
38
  # read data from dump_path or from STDIN
39
- if dump_path && Dir.exists?(dump_path)
39
+ if dump_path && Dir.exist?(dump_path)
40
40
  files = Dir[Pathname.new(dump_path).join("*.json")]
41
41
  files.each { |file| data << JSON.parse(File.read(file), symbolize_names: true) }
42
42
  else
@@ -1,5 +1,6 @@
1
1
  require 'thor'
2
2
  require 'fileutils'
3
+ require 'yaml'
3
4
 
4
5
  require_relative '../config'
5
6
  require_relative '../log'
@@ -10,6 +11,7 @@ module Tapsoob
10
11
  module CLI
11
12
  class Root < Thor
12
13
  desc "pull DUMP_PATH DATABASE_URL", "Pull a dump from a database to a folder"
14
+ option :config, desc: "Define all options in a config file", type: :string, aliases: '-C'
13
15
  option :data, desc: "Pull the data to the database", default: true, type: :boolean, aliases: '-d'
14
16
  option :schema, desc: "Pull the schema to the database", default: true, type: :boolean, aliases: "-s"
15
17
  option :"indexes-first", desc: "Transfer indexes first before data", default: false, type: :boolean, aliases: "-i"
@@ -33,6 +35,7 @@ module Tapsoob
33
35
  end
34
36
 
35
37
  desc "push DUMP_PATH DATABASE_URL", "Push a previously tapsoob dump to a database"
38
+ option :config, desc: "Define all options in a config file", type: :string, aliases: '-C'
36
39
  option :data, desc: "Push the data to the database", default: true, type: :boolean, aliases: '-d'
37
40
  option :schema, desc: "Push the schema to the database", default: true, type: :boolean, aliases: "-s"
38
41
  option :"indexes-first", desc: "Transfer indexes first before data", default: false, type: :boolean, aliases: "-i"
@@ -56,6 +59,11 @@ module Tapsoob
56
59
  end
57
60
  end
58
61
 
62
+ def ripl
63
+ require 'ripl'
64
+ Ripl.start
65
+ end
66
+
59
67
  desc "version", "Show tapsoob version"
60
68
  def version
61
69
  puts Tapsoob::VERSION.dup
@@ -69,8 +77,11 @@ module Tapsoob
69
77
 
70
78
  private
71
79
  def parse_opts(options)
80
+ # Load config file if it exist
81
+ opts = ((options[:config] && File.exist?(options[:config])) ? YAML.load_file(options[:config]) : {})
82
+
72
83
  # Default options
73
- opts = {
84
+ opts = opts.merge({
74
85
  data: options[:data],
75
86
  schema: options[:schema],
76
87
  indexes_first: options[:"indexes_first"],
@@ -78,7 +89,7 @@ module Tapsoob
78
89
  tables: options[:tables],
79
90
  progress: options[:progress],
80
91
  debug: options[:debug]
81
- }
92
+ })
82
93
 
83
94
  # Pull only options
84
95
  opts[:indexes] = options[:"indexes"] if options.key?(:"indexes")
@@ -91,7 +102,7 @@ module Tapsoob
91
102
 
92
103
  # Resume
93
104
  if options[:resume]
94
- if File.exists?(options[:resume])
105
+ if File.exist?(options[:resume])
95
106
  opts[:resume_file] = options[:resume]
96
107
  else
97
108
  raise "Unable to find resume file."
@@ -54,7 +54,7 @@ module Tapsoob
54
54
  desc "load DATABASE_URL [FILENAME]", "Load a database schema from a file or STDIN to a database using a database URL"
55
55
  option :drop, type: :boolean, default: false
56
56
  def load(database_url, filename = nil)
57
- schema = if filename && File.exists?(filename)
57
+ schema = if filename && File.exist?(filename)
58
58
  File.read(filename)
59
59
  else
60
60
  STDIN.read
@@ -69,7 +69,7 @@ module Tapsoob
69
69
 
70
70
  desc "load_foreign_keys DATABASE_URL [FILENAME]", "Load foreign keys from a file or STDIN to a database using a database URL"
71
71
  def load_foreign_keys(database_url, filename = nil)
72
- indexes = if filename && File.exists?(filename)
72
+ indexes = if filename && File.exist?(filename)
73
73
  File.read(filename)
74
74
  else
75
75
  STDIN.read
@@ -84,7 +84,7 @@ module Tapsoob
84
84
 
85
85
  desc "load_indexes DATABASE_URL [FILENAME]", "Load indexes from a file or STDIN to a database using a database URL"
86
86
  def load_indexes(database_url, filename = nil)
87
- indexes = if filename && File.exists?(filename)
87
+ indexes = if filename && File.exist?(filename)
88
88
  File.read(filename)
89
89
  else
90
90
  STDIN.read
@@ -428,7 +428,7 @@ module Tapsoob
428
428
  log.info "#{tables.size} tables, #{format_number(record_count)} records"
429
429
 
430
430
  tables.each do |table_name, count|
431
- next unless File.exists?(File.join(dump_path, "data", "#{table_name}.json")) || File.exists?(File.join(dump_path, "data", "#{table_name}.json")) && JSON.parse(File.read(File.join(dump_path, "data", "#{table_name}.json")))["data"].size == 0
431
+ next unless File.exist?(File.join(dump_path, "data", "#{table_name}.json")) || File.exist?(File.join(dump_path, "data", "#{table_name}.json")) && JSON.parse(File.read(File.join(dump_path, "data", "#{table_name}.json")))["data"].size == 0
432
432
  db[table_name.to_sym].truncate if @opts[:purge]
433
433
  stream = Tapsoob::DataStream.factory(db, {
434
434
  :table_name => table_name,
@@ -521,7 +521,7 @@ module Tapsoob
521
521
  tables_with_counts = {}
522
522
  tbls = Dir.glob(File.join(dump_path, "schemas", "*")).map { |path| File.basename(path, ".rb") }
523
523
  tbls.each do |table|
524
- if File.exists?(File.join(dump_path, "data", "#{table}.json"))
524
+ if File.exist?(File.join(dump_path, "data", "#{table}.json"))
525
525
  data = JSON.parse(File.read(File.join(dump_path, "data", "#{table}.json")))
526
526
  tables_with_counts[table] = data["data"].size
527
527
  else
data/lib/tapsoob/utils.rb CHANGED
@@ -144,7 +144,7 @@ Data : #{data}
144
144
 
145
145
  def export_indexes(dump_path, table, index_data)
146
146
  data = [index_data]
147
- if File.exists?(File.join(dump_path, "indexes", "#{table}.json"))
147
+ if File.exist?(File.join(dump_path, "indexes", "#{table}.json"))
148
148
  previous_data = JSON.parse(File.read(File.join(dump_path, "indexes", "#{table}.json")))
149
149
  data = data + previous_data
150
150
  end
@@ -156,7 +156,7 @@ Data : #{data}
156
156
 
157
157
  def export_rows(dump_path, table, row_data)
158
158
  data = row_data
159
- if File.exists?(File.join(dump_path, "data", "#{table}.json"))
159
+ if File.exist?(File.join(dump_path, "data", "#{table}.json"))
160
160
  previous_data = JSON.parse(File.read(File.join(dump_path, "data", "#{table}.json")))
161
161
  data[:data] = previous_data["data"] + row_data[:data] unless row_data[:data].nil?
162
162
  end
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Tapsoob
3
- VERSION = "0.5.21".freeze
3
+ VERSION = "0.5.23".freeze
4
4
  end
@@ -56,7 +56,7 @@ namespace :tapsoob do
56
56
  if dumps.count > keep
57
57
  old_dumps = dumps - dumps.reverse[0..(keep - 1)]
58
58
  old_dumps.each do |dir|
59
- if Dir.exists?(dir)
59
+ if Dir.exist?(dir)
60
60
  puts "Deleting old dump directory ('#{dir}')"
61
61
  FileUtils.remove_entry_secure(dir)
62
62
  end
data/tapsoob.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
 
22
22
  # Dependencies
23
23
  s.add_dependency "ripl", "~> 0.7.1"
24
- s.add_dependency "sequel", "~> 5.65.0"
24
+ s.add_dependency "sequel", "~> 5.70.0"
25
25
  s.add_dependency "thor", "~> 1.2.1"
26
26
 
27
27
  if (RUBY_PLATFORM =~ /java/).nil?
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.5.21
4
+ version: 0.5.23
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: 2023-04-09 00:00:00.000000000 Z
12
+ date: 2024-01-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ripl
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: 5.65.0
34
+ version: 5.70.0
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: 5.65.0
41
+ version: 5.70.0
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: thor
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -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.2.32
152
+ rubygems_version: 3.3.26
153
153
  signing_key:
154
154
  specification_version: 4
155
155
  summary: Simple tool to import/export databases.