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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 807b82f4f96731a6608be9242124f961aac40cce
4
- data.tar.gz: a180d4a1d099102aff7881ca02703f36de5f841f
3
+ metadata.gz: e70bb4204cbf11445010bd7584a09bd5d69c0e65
4
+ data.tar.gz: 1d0eb4ffd0abcc58232f01351f95e69750be5ab8
5
5
  SHA512:
6
- metadata.gz: ef78bfd7ef50ee764560ae6412004ee302a0ff5a2e8dd67e7c5651b4e938e0928d9c346d48a67eec76149cacf3b88b509f24024bf880eb7fa68bf22f5d9246c0
7
- data.tar.gz: f126394c13afbc197d1461e7c6ba3924b5f9fceea92e47820022263475d170546ce8c397dd65f888740bb4f01aba1a9605a7eb12fb9c7c5d35c849b20bb5dd06
6
+ metadata.gz: aed4d6ab6277d3753b1b80614af9530d12099102d58470d964b7f8cd11c2a49f2df421c2e36d22f86c88be88c4b91582632cfdd13d8ff843facec574a890d37c
7
+ data.tar.gz: 5a8c278778ad445dcff1bc3edb6485cb8335e7327a004481def6ec7034dbe9ac2c77fbff842cf032ff4e2ab9ea2bc6bbee8d0facbd6cb6c3b09ab795def71fa3
data/.travis.yml CHANGED
@@ -1,5 +1,10 @@
1
- sudo: false
2
1
  language: ruby
3
2
  rvm:
4
- - 2.3.1
5
- before_install: gem install bundler -v 1.13.6
3
+ - 2.5.0
4
+ before_install:
5
+ - dropdb destination --if-exists
6
+ - dropdb origin --if-exists
7
+ dist: trusty
8
+ sudo: required
9
+ addons:
10
+ postgresql: "9.5"
data/Gemfile CHANGED
@@ -7,4 +7,6 @@ group :development do
7
7
  gem 'rspec'
8
8
  gem 'pg_tester'
9
9
  gem 'pry-byebug'
10
+ gem 'coveralls'
11
+ gem 'yard'
10
12
  end
data/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Toku
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/toku.svg)](https://rubygems.org/gems/toku)
4
+ [![Build Status](https://travis-ci.org/LIQIDTechnology/toku.svg?branch=master)](https://travis-ci.org/LIQIDTechnology/toku)
5
+ [![Coverage Status](https://coveralls.io/repos/github/LIQIDTechnology/toku/badge.svg?branch=master)](https://coveralls.io/github/LIQIDTechnology/toku?branch=master)
6
+ [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/gems/toku/)
7
+ [![Documentation coverage](https://inch-ci.org/github/LIQIDTechnology/toku.svg?branch=master)](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
@@ -1,3 +1,3 @@
1
1
  module Toku
2
- VERSION = "0.1.0.3"
2
+ VERSION = "0.1.0.4"
3
3
  end
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
- row_enumerator = source_db[table].stream.to_enum
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.3
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-03 00:00:00.000000000 Z
12
+ date: 2018-01-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler