data-anonymization 0.7.3 → 0.7.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: 796e8e4ec064ab6777e4bdd05e33a8dd0e3b2bd4
4
- data.tar.gz: 6cb7c3f04d5686db81ff1d49b198ac4c14829d8d
3
+ metadata.gz: 066880fbf97030bf79f2365fa16cf2a64488861e
4
+ data.tar.gz: fb799b830d294413448e8bd3026fb23a8aff8519
5
5
  SHA512:
6
- metadata.gz: 2c60fc5490fc788c83d532848b163aa7bbf66d6c33e1d7dc5a94ca5da1c2ef0270fc89b13870141b4f01b6f5bf9cae11931ada0ca89bdc0fb03bf42604849af1
7
- data.tar.gz: a223340e8f64df4687eb91d22dd261b6e601fb262c82df07f4adc4c46f93713bc08e90db21ccc475b29160b6bc71072ba86743a0c88fc8521519a4627d660b86
6
+ metadata.gz: 3836066283d02a2be8886e97879f2de7d79f7c5d94b073cf021d7ff67d64ad11d655c17f268469053114e0be6226bb1e11f27f0243207dd400d0a096eac149e9
7
+ data.tar.gz: 4e4a9847744419a73aea031c77d5e74f495b8dab9015b818e07abb65a5eeb7cd27e31f067e13ac404526199103a43bf056c438053e2b4bd1f5506a99be5d1add
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.2.2
1
+ ruby-2.3.1
data/.travis.yml CHANGED
@@ -1,10 +1,9 @@
1
1
  language: ruby
2
2
  services:
3
3
  - mongodb
4
- before_install: gem install bundler -v 1.11.2
4
+ before_install: gem install bundler -v 1.12.5
5
5
  before_script: rake empty_dest
6
6
  rvm:
7
- - 1.9.3
8
- - 2.1.8
9
- - 2.2.4
10
- - 2.3.0
7
+ - 2.1.10
8
+ - 2.2.5
9
+ - 2.3.1
data/README.md CHANGED
@@ -501,7 +501,7 @@ has following attribute accessor
501
501
  <tr>
502
502
  <td align="left">Last name</td>
503
503
  <td align="left"><a href="http://rubydoc.info/github/sunitparekh/data-anonymization/DataAnon/Strategy/Field/RandomLastName">RandomLastName</a></td>
504
- <td align="left">Randomly picks up first name from the predefined list in the file. Default <a href="https://raw.github.com/sunitparekh/data-anonymization/master/resources/first_names.txt">file</a> is part of the gem.</td>
504
+ <td align="left">Randomly picks up last name from the predefined list in the file. Default <a href="https://raw.github.com/sunitparekh/data-anonymization/master/resources/last_names.txt">file</a> is part of the gem.</td>
505
505
  </tr>
506
506
  <tr>
507
507
  <td align="left">Full Name</td>
data/lib/core/database.rb CHANGED
@@ -48,8 +48,12 @@ module DataAnon
48
48
  logger.error "\n#{e.message} \n #{e.backtrace}"
49
49
  end
50
50
  if @strategy.whitelist?
51
- logger.info("Fields missing the anonymization strategy")
52
- @tables.each { |table| table.fields_missing_strategy.print }
51
+ @tables.each do |table|
52
+ if table.fields_missing_strategy.present?
53
+ logger.info('Fields missing the anonymization strategy:')
54
+ table.fields_missing_strategy.print
55
+ end
56
+ end
53
57
  end
54
58
 
55
59
  @tables.each { |table| table.errors.print }
@@ -24,6 +24,10 @@ module DataAnon
24
24
  end
25
25
  end
26
26
 
27
+ def present?
28
+ fields_missing_strategy.size > 0
29
+ end
30
+
27
31
  end
28
32
 
29
33
  end
data/lib/strategy/base.rb CHANGED
@@ -100,6 +100,9 @@ module DataAnon
100
100
  end
101
101
  progress.close
102
102
  end
103
+ if source_table.respond_to?('clear_all_connections!')
104
+ source_table.clear_all_connections!
105
+ end
103
106
  end
104
107
 
105
108
  def process_table progress
@@ -13,7 +13,7 @@ module DataAnon
13
13
 
14
14
  url = field.value
15
15
  randomized_url = ""
16
- protocols = url.scan(/http:\/\/|www\./)
16
+ protocols = url.scan(/https?:\/\/|www\./)
17
17
  protocols.each do |token|
18
18
  url = url.gsub(token,"")
19
19
  randomized_url += token
@@ -33,4 +33,4 @@ module DataAnon
33
33
  end
34
34
  end
35
35
  end
36
- end
36
+ end
@@ -5,8 +5,8 @@ module DataAnon
5
5
  # Similar to SelectFromList with difference is the list of values are collected from the database table using distinct column query.
6
6
  #
7
7
  # !!!ruby
8
- # # values are collected using `select distinct state from customers` query
9
- # anonymize('State').using FieldStrategy::SelectFromDatabase.new('customers','state')
8
+ # # values are collected using `select distinct state from customers` query connecting to specified database in connection_spec
9
+ # anonymize('State').using FieldStrategy::SelectFromDatabase.new('customers','state', connection_spec)
10
10
 
11
11
  class SelectFromDatabase < SelectFromFile
12
12
  include Utils::Logging
@@ -14,7 +14,7 @@ module DataAnon
14
14
  def initialize table_name, field_name, connection_spec
15
15
  DataAnon::Utils::SourceDatabase.establish_connection connection_spec
16
16
  source = Utils::SourceTable.create table_name, []
17
- @values = source.select(field_name).uniq.collect { |record| record[field_name]}
17
+ @values = source.select(field_name).distinct.collect { |record| record[field_name]}
18
18
  logger.debug "For field strategy #{table_name}:#{field_name} using values #{@values} "
19
19
 
20
20
  end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module DataAnonymization
2
- VERSION = '0.7.3'
2
+ VERSION = '0.7.4'
3
3
  end
@@ -5,11 +5,19 @@ describe FieldStrategy::RandomUrl do
5
5
  RandomUrl = FieldStrategy::RandomUrl
6
6
 
7
7
  describe 'anonymized url must not be the same as original url' do
8
- let(:field) {DataAnon::Core::Field.new('string_field','http://fakeurl.com',1,nil)}
8
+ let(:url) { 'http://example.org' }
9
+
10
+ let(:field) {DataAnon::Core::Field.new('string_field',url,1,nil)}
9
11
  let(:anonymized_url) {RandomUrl.new.anonymize(field)}
10
12
 
11
13
  it {anonymized_url.should_not equal field.value}
12
- it {anonymized_url.should match /https?:\/\/[\S]+/}
13
- end
14
+ it {anonymized_url.should match /http:\/\/[\S]+/}
14
15
 
15
- end
16
+ context 'with https url' do
17
+ let(:url) { 'https://example.org' }
18
+
19
+ it {anonymized_url.should_not equal field.value}
20
+ it {anonymized_url.should match /https:\/\/[\S]+/}
21
+ end
22
+ end
23
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data-anonymization
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sunit Parekh
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-02-04 00:00:00.000000000 Z
13
+ date: 2016-10-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord