toku 0.1.0.4.4 → 0.1.0.5.1
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 +4 -4
- data/Gemfile +0 -1
- data/lib/toku.rb +14 -6
- data/lib/toku/filters/column/faker_email.rb +2 -2
- data/lib/toku/filters/column/faker_first_name.rb +2 -2
- data/lib/toku/filters/column/faker_last_name.rb +2 -2
- data/lib/toku/filters/column/nullify.rb +2 -2
- data/lib/toku/filters/column/obfuscate.rb +2 -2
- data/lib/toku/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4110a207f5ec622d93605367c5b1d27ce8df4273
|
4
|
+
data.tar.gz: a1e0dad2c061cc9fe29553118307c1b74601664a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76981e3f9db62fd65818027a22b6d1e159cf8e49a0a14f91c75ab0433987859ce21bac18e60451370999e3cc4d3891c48fa7e6c7ac056ddd4f3160f3189ea6dc
|
7
|
+
data.tar.gz: 3a532fadae30465952240f70f3f743883ae9c418f3bc663a0d4309f35b89f9fa152e155c4d2c64e63e686c69f61a6e9d86edd65a74786f6846735775b3b56058
|
data/Gemfile
CHANGED
data/lib/toku.rb
CHANGED
@@ -11,7 +11,7 @@ module Toku
|
|
11
11
|
attr_accessor :column_filters
|
12
12
|
attr_accessor :row_filters
|
13
13
|
|
14
|
-
#
|
14
|
+
# Default column filters
|
15
15
|
COLUMN_FILTER_MAP = {
|
16
16
|
none: Toku::ColumnFilter::Passthrough,
|
17
17
|
faker_last_name: Toku::ColumnFilter::FakerLastName,
|
@@ -21,7 +21,7 @@ module Toku
|
|
21
21
|
nullify: Toku::ColumnFilter::Nullify
|
22
22
|
}
|
23
23
|
|
24
|
-
#
|
24
|
+
# Default row filters
|
25
25
|
ROW_FILTER_MAP = {
|
26
26
|
drop: Toku::RowFilter::Drop
|
27
27
|
}
|
@@ -30,7 +30,7 @@ module Toku
|
|
30
30
|
|
31
31
|
SCHEMA_DUMP_PATH = "tmp/toku_source_schema_dump.sql"
|
32
32
|
|
33
|
-
# @param [String]
|
33
|
+
# @param config_file_path [String] path of config file
|
34
34
|
def initialize(config_file_path, column_filters = {}, row_filters = {})
|
35
35
|
@config = YAML.load(ERB.new(File.read(config_file_path)).result)
|
36
36
|
@threadpool = Concurrent::FixedThreadPool.new(THREADPOOL_SIZE)
|
@@ -44,7 +44,8 @@ module Toku
|
|
44
44
|
# @return [void]
|
45
45
|
def run(uri_db_source, uri_db_destination)
|
46
46
|
begin_time_stamp = Time.now
|
47
|
-
@
|
47
|
+
@global_object_count = 0
|
48
|
+
@tables_processed_count = 0
|
48
49
|
source_db = Sequel.connect(uri_db_source)
|
49
50
|
dump_schema(uri_db_source)
|
50
51
|
parsed_destination_uri = URI(uri_db_destination)
|
@@ -77,7 +78,7 @@ module Toku
|
|
77
78
|
source_db.disconnect
|
78
79
|
destination_db.disconnect
|
79
80
|
FileUtils.rm(SCHEMA_DUMP_PATH)
|
80
|
-
puts "Toku: copied #{@
|
81
|
+
puts "Toku: copied #{@global_object_count} elements accross #{@tables_processed_count} tables and that took #{(Time.now - begin_time_stamp).round(2)} seconds with #{THREADPOOL_SIZE} green threads"
|
81
82
|
nil
|
82
83
|
end
|
83
84
|
|
@@ -99,6 +100,9 @@ module Toku
|
|
99
100
|
end.to_csv
|
100
101
|
end
|
101
102
|
|
103
|
+
# @param source_connection [Sequel::Postgres::Database]
|
104
|
+
# @param destination_connection [Sequel::Postgres::Database]
|
105
|
+
# @return [void]
|
102
106
|
def process_table(table, source_connection, destination_connection)
|
103
107
|
row_enumerator = source_connection[table].stream.lazy
|
104
108
|
@config[table.to_s]['rows'].each do |f|
|
@@ -114,7 +118,8 @@ module Toku
|
|
114
118
|
destination_connection.copy_into(table, data: row_enumerator.map { |row| transform(row, table) }, format: :csv)
|
115
119
|
destination_connection.run("ALTER TABLE #{table} ENABLE TRIGGER ALL;")
|
116
120
|
count = destination_connection[table].count
|
117
|
-
@
|
121
|
+
@global_object_count += count
|
122
|
+
@tables_processed_count += 1
|
118
123
|
puts "Toku: copied #{count} objects into #{table} #{count != 0 ? ':)' : ':|'}"
|
119
124
|
end
|
120
125
|
|
@@ -133,6 +138,9 @@ module Toku
|
|
133
138
|
)
|
134
139
|
end
|
135
140
|
|
141
|
+
# param type [Hash]
|
142
|
+
# param symbol [Symbol]
|
143
|
+
# @return [Class]
|
136
144
|
def filter_class(type, symbol)
|
137
145
|
raise "Please provide a filter for #{symbol}" if type[symbol].nil?
|
138
146
|
type[symbol]
|
data/lib/toku/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toku
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PSKL
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-02-
|
12
|
+
date: 2018-02-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sequel
|