toku 0.1.0.3 → 0.1.0.4
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/.travis.yml +8 -3
- data/Gemfile +2 -0
- data/README.md +6 -0
- data/lib/toku/version.rb +1 -1
- data/lib/toku.rb +7 -3
- 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: e70bb4204cbf11445010bd7584a09bd5d69c0e65
|
4
|
+
data.tar.gz: 1d0eb4ffd0abcc58232f01351f95e69750be5ab8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aed4d6ab6277d3753b1b80614af9530d12099102d58470d964b7f8cd11c2a49f2df421c2e36d22f86c88be88c4b91582632cfdd13d8ff843facec574a890d37c
|
7
|
+
data.tar.gz: 5a8c278778ad445dcff1bc3edb6485cb8335e7327a004481def6ec7034dbe9ac2c77fbff842cf032ff4e2ab9ea2bc6bbee8d0facbd6cb6c3b09ab795def71fa3
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Toku
|
2
2
|
|
3
|
+
[](https://rubygems.org/gems/toku)
|
4
|
+
[](https://travis-ci.org/LIQIDTechnology/toku)
|
5
|
+
[](https://coveralls.io/github/LIQIDTechnology/toku?branch=master)
|
6
|
+
[](http://www.rubydoc.info/gems/toku/)
|
7
|
+
[](https://inch-ci.org/github/LIQIDTechnology/toku)
|
8
|
+
|
3
9
|
Toku (which comes from 'Tokumei' 匿名 in Japanese) is a gem originally designed to anonymize a database in order to feed a another database with same columns but with filtered row contents.
|
4
10
|
|
5
11
|
## Installation
|
data/lib/toku/version.rb
CHANGED
data/lib/toku.rb
CHANGED
@@ -29,6 +29,7 @@ module Toku
|
|
29
29
|
# @param [String] uri_db_source URI of the DB to be anonimized
|
30
30
|
# @param [String] uri_db_destination URI of the destination DB
|
31
31
|
def run(uri_db_source, uri_db_destination)
|
32
|
+
|
32
33
|
source_db = Sequel.connect(uri_db_source)
|
33
34
|
destination_db = Sequel.connect(uri_db_destination)
|
34
35
|
|
@@ -40,8 +41,8 @@ module Toku
|
|
40
41
|
if !row_filters?(table) && @config[table.to_s]['columns'].count < source_db.from(table).columns.count
|
41
42
|
raise Toku::ColumnFilterMissingError
|
42
43
|
end
|
43
|
-
|
44
|
-
|
44
|
+
row_enumerator = source_db[table].stream.lazy
|
45
|
+
destination_db[table].truncate
|
45
46
|
|
46
47
|
@config[table.to_s]['rows'].each do |f|
|
47
48
|
if f.is_a? String
|
@@ -55,7 +56,10 @@ module Toku
|
|
55
56
|
|
56
57
|
row_enumerator = row_enumerator.map { |row| transform(row, table) }
|
57
58
|
destination_db.copy_into(table, data: row_enumerator, format: :csv)
|
59
|
+
count = destination_db[table].count
|
60
|
+
puts "Toku: copied #{count} objects into #{table} #{count != 0 ? ':)' : ':|'}"
|
58
61
|
end
|
62
|
+
nil
|
59
63
|
end
|
60
64
|
|
61
65
|
# @param [Symbol] name
|
@@ -73,7 +77,7 @@ module Toku
|
|
73
77
|
column_filter = self.column_filters[filter_params.to_sym].new(v, {})
|
74
78
|
end
|
75
79
|
column_filter.call
|
76
|
-
end.join(
|
80
|
+
end.join(",") + "\n"
|
77
81
|
end
|
78
82
|
|
79
83
|
def source_schema_included?(source_db, destination_db)
|
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.4
|
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-01-
|
12
|
+
date: 2018-01-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|