tapsoob 0.1.10
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 +7 -0
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +24 -0
- data/README.md +66 -0
- data/Rakefile +0 -0
- data/bin/schema +54 -0
- data/bin/tapsoob +6 -0
- data/lib/tapsoob.rb +9 -0
- data/lib/tapsoob/chunksize.rb +53 -0
- data/lib/tapsoob/cli.rb +145 -0
- data/lib/tapsoob/config.rb +33 -0
- data/lib/tapsoob/data_stream.rb +350 -0
- data/lib/tapsoob/errors.rb +16 -0
- data/lib/tapsoob/log.rb +16 -0
- data/lib/tapsoob/operation.rb +468 -0
- data/lib/tapsoob/progress_bar.rb +236 -0
- data/lib/tapsoob/railtie.rb +11 -0
- data/lib/tapsoob/schema.rb +83 -0
- data/lib/tapsoob/utils.rb +179 -0
- data/lib/tapsoob/version.rb +4 -0
- data/lib/tasks/tapsoob.rake +59 -0
- data/tapsoob.gemspec +30 -0
- metadata +138 -0
@@ -0,0 +1,59 @@
|
|
1
|
+
namespace :tapsoob do
|
2
|
+
desc "Pulls a database to your filesystem"
|
3
|
+
task :pull => :environment do
|
4
|
+
# Default options
|
5
|
+
opts={:default_chunksize => 1000, :debug => false, :resume_filename => nil, :disable_compression => false, :indexes_first => false}
|
6
|
+
|
7
|
+
# Get the dump_path
|
8
|
+
dump_path = File.expand_path(Rails.root.join("db", Time.now.strftime("%Y%m%d%I%M%S%p"))).to_s
|
9
|
+
|
10
|
+
# Create paths
|
11
|
+
FileUtils.mkpath "#{dump_path}/schemas"
|
12
|
+
FileUtils.mkpath "#{dump_path}/data"
|
13
|
+
FileUtils.mkpath "#{dump_path}/indexes"
|
14
|
+
|
15
|
+
# Run operation
|
16
|
+
Tapsoob::Operation.factory(:pull, database_uri, dump_path, opts).run
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Push a compatible dump on your filesystem to a database"
|
20
|
+
task :push => :environment do
|
21
|
+
# Default options
|
22
|
+
opts={:default_chunksize => 1000, :debug => false, :resume_filename => nil, :disable_compression => false, :indexes_first => false}
|
23
|
+
|
24
|
+
# Get the dump_path
|
25
|
+
dump_path = Dir[Rails.root.join("db", "*/")].select { |e| e =~ /([0-9]{14})([A-Z]{2})/ }.sort.last
|
26
|
+
|
27
|
+
# Run operation
|
28
|
+
Tapsoob::Operation.factory(:push, database_uri, dump_path, opts).run
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
def database_uri
|
33
|
+
uri = ""
|
34
|
+
connection_config = YAML.load_file(Rails.root.join("config", "database.yml"))[Rails.env]
|
35
|
+
|
36
|
+
case connection_config['adapter']
|
37
|
+
when "mysql", "mysql2"
|
38
|
+
if RUBY_PLATFORM =~ /java/
|
39
|
+
uri = "mysql://#{connection_config['host']}/#{connection_config['database']}?user=#{connection_config['username']}&password=#{connection_config['password']}"
|
40
|
+
else
|
41
|
+
uri = "#{connection_config['adapter']}://#{connection_config['host']}/#{connection_config['database']}?user=#{connection_config['username']}&password=#{connection_config['password']}"
|
42
|
+
end
|
43
|
+
when "oracle_enhanced"
|
44
|
+
if RUBY_PLATFORM =~ /java/
|
45
|
+
uri = "oracle:thin:#{connection_config['username']}/#{connection_config['password']}@#{connection_config['host']}:1521:#{connection_config['database']}"
|
46
|
+
else
|
47
|
+
uri = "oracle://#{connection_config['host']}/#{connection_config['database']}?user=#{connection_config['username']}&password=#{connection_config['password']}"
|
48
|
+
end
|
49
|
+
when "sqlite"
|
50
|
+
uri = "sqlite://#{connection_config['adapter']}"
|
51
|
+
else
|
52
|
+
uri = "#{connection_config['adapter']}://#{connection_config['host']}/#{connection_config['database']}?user=#{connection_config['username']}&password=#{connection_config['password']}"
|
53
|
+
end
|
54
|
+
|
55
|
+
uri = "jdbc:#{uri}" if RUBY_PLATFORM =~ /java/
|
56
|
+
|
57
|
+
uri
|
58
|
+
end
|
59
|
+
end
|
data/tapsoob.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "tapsoob/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
# Metadata
|
7
|
+
s.name = "tapsoob"
|
8
|
+
s.version = Tapsoob::VERSION.dup
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.authors = ["Félix Bellanger"]
|
11
|
+
s.email = "felix.bellanger@faveod.com"
|
12
|
+
s.homepage = "https://github.com/Keeguon/tapsoob"
|
13
|
+
s.summary = "Simple tool to import/export databases."
|
14
|
+
s.description = "Simple tool to import/export databases inspired by taps but OOB, meaning databases are imported/exported from the filesystem."
|
15
|
+
s.license = "MIT"
|
16
|
+
|
17
|
+
# Manifest
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
|
23
|
+
# Dependencies
|
24
|
+
s.add_dependency "sequel", "~> 3.45.0"
|
25
|
+
|
26
|
+
s.add_development_dependency "mysql", "~> 2.9.1"
|
27
|
+
s.add_development_dependency "mysql2", "~> 0.3.11"
|
28
|
+
s.add_development_dependency "pg", "~> 0.14.1"
|
29
|
+
s.add_development_dependency "sqlite3", "~> 1.3.7"
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tapsoob
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.10
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Félix Bellanger
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sequel
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.45.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.45.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mysql
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.9.1
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.9.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mysql2
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.3.11
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.3.11
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pg
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.14.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.14.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sqlite3
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.3.7
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.3.7
|
83
|
+
description: Simple tool to import/export databases inspired by taps but OOB, meaning
|
84
|
+
databases are imported/exported from the filesystem.
|
85
|
+
email: felix.bellanger@faveod.com
|
86
|
+
executables:
|
87
|
+
- schema
|
88
|
+
- tapsoob
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- .gitignore
|
93
|
+
- Gemfile
|
94
|
+
- Gemfile.lock
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- bin/schema
|
98
|
+
- bin/tapsoob
|
99
|
+
- lib/tapsoob.rb
|
100
|
+
- lib/tapsoob/chunksize.rb
|
101
|
+
- lib/tapsoob/cli.rb
|
102
|
+
- lib/tapsoob/config.rb
|
103
|
+
- lib/tapsoob/data_stream.rb
|
104
|
+
- lib/tapsoob/errors.rb
|
105
|
+
- lib/tapsoob/log.rb
|
106
|
+
- lib/tapsoob/operation.rb
|
107
|
+
- lib/tapsoob/progress_bar.rb
|
108
|
+
- lib/tapsoob/railtie.rb
|
109
|
+
- lib/tapsoob/schema.rb
|
110
|
+
- lib/tapsoob/utils.rb
|
111
|
+
- lib/tapsoob/version.rb
|
112
|
+
- lib/tasks/tapsoob.rake
|
113
|
+
- tapsoob.gemspec
|
114
|
+
homepage: https://github.com/Keeguon/tapsoob
|
115
|
+
licenses:
|
116
|
+
- MIT
|
117
|
+
metadata: {}
|
118
|
+
post_install_message:
|
119
|
+
rdoc_options: []
|
120
|
+
require_paths:
|
121
|
+
- lib
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - '>='
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
requirements: []
|
133
|
+
rubyforge_project:
|
134
|
+
rubygems_version: 2.0.3
|
135
|
+
signing_key:
|
136
|
+
specification_version: 4
|
137
|
+
summary: Simple tool to import/export databases.
|
138
|
+
test_files: []
|