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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d14fc10f4732aaa04b7d3fab0da39e55eb35c0d9
4
- data.tar.gz: 72a5299d37764a11eb1556f3125b8fae80c8518e
3
+ metadata.gz: 4110a207f5ec622d93605367c5b1d27ce8df4273
4
+ data.tar.gz: a1e0dad2c061cc9fe29553118307c1b74601664a
5
5
  SHA512:
6
- metadata.gz: b132102fd9d06dfcb2eda58fa76801bbf26a0f7990e0b4df2a5a035aa8b276d9e278b56d22a0e844ad4ee4da3b2af10481bce5cb7e0673a7c14d00b42bfb9dd6
7
- data.tar.gz: f78d11cfa53c5502e818f9c6e03c1f324a489df3da064bda01b7df58e3e6feabce933cc03743e5fdaa7013c3d6772805e4941c56761a06c8d1111ea99f02d389
6
+ metadata.gz: 76981e3f9db62fd65818027a22b6d1e159cf8e49a0a14f91c75ab0433987859ce21bac18e60451370999e3cc4d3891c48fa7e6c7ac056ddd4f3160f3189ea6dc
7
+ data.tar.gz: 3a532fadae30465952240f70f3f743883ae9c418f3bc663a0d4309f35b89f9fa152e155c4d2c64e63e686c69f61a6e9d86edd65a74786f6846735775b3b56058
data/Gemfile CHANGED
@@ -5,7 +5,6 @@ gemspec
5
5
 
6
6
  group :development do
7
7
  gem 'rspec'
8
- gem 'pg_tester'
9
8
  gem 'pry-byebug'
10
9
  gem 'coveralls'
11
10
  gem 'yard'
@@ -11,7 +11,7 @@ module Toku
11
11
  attr_accessor :column_filters
12
12
  attr_accessor :row_filters
13
13
 
14
- # A few default column filters mappings
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
- # A few default row filters mappings
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] config_file_path path of config file
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
- @global_count = 0
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 #{@global_count} elements in total and that took #{(Time.now - begin_time_stamp).round(2)} seconds with #{THREADPOOL_SIZE} green threads"
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
- @global_count += count
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]
@@ -1,8 +1,8 @@
1
1
  module Toku
2
2
  class ColumnFilter
3
3
  class FakerEmail < Toku::ColumnFilter
4
- def initialize(value, options)
5
- @value = Faker::Internet.email
4
+ def call
5
+ Faker::Internet.email
6
6
  end
7
7
  end
8
8
  end
@@ -1,8 +1,8 @@
1
1
  module Toku
2
2
  class ColumnFilter
3
3
  class FakerFirstName < Toku::ColumnFilter
4
- def initialize(value, options)
5
- @value = Faker::Name.first_name
4
+ def call
5
+ Faker::Name.first_name
6
6
  end
7
7
  end
8
8
  end
@@ -1,8 +1,8 @@
1
1
  module Toku
2
2
  class ColumnFilter
3
3
  class FakerLastName < Toku::ColumnFilter
4
- def initialize(value, options)
5
- @value = Faker::Name.last_name
4
+ def call
5
+ Faker::Name.last_name
6
6
  end
7
7
  end
8
8
  end
@@ -1,8 +1,8 @@
1
1
  module Toku
2
2
  class ColumnFilter
3
3
  class Nullify < Toku::ColumnFilter
4
- def initialize(value, options)
5
- @value = nil
4
+ def call
5
+ nil
6
6
  end
7
7
  end
8
8
  end
@@ -1,8 +1,8 @@
1
1
  module Toku
2
2
  class ColumnFilter
3
3
  class Obfuscate < Toku::ColumnFilter
4
- def initialize(value, options)
5
- @value = SecureRandom.hex(10)
4
+ def call
5
+ SecureRandom.hex(10)
6
6
  end
7
7
  end
8
8
  end
@@ -1,3 +1,3 @@
1
1
  module Toku
2
- VERSION = "0.1.0.4.4"
2
+ VERSION = "0.1.0.5.1"
3
3
  end
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.4
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-26 00:00:00.000000000 Z
12
+ date: 2018-02-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sequel