privacy 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ca8e649274c09605e85a27d6012ac1e68545abd2fa6dc455a03c3448e45c7e4
4
- data.tar.gz: 987a6aebf97b840f3d46d2e1e5a1c63b8b07b292839df2a7b0f37f6e86f867d0
3
+ metadata.gz: 8be253d2d26c29d1d4f5145621bafad66858146e1e2e1e311f2a97b3a5f56479
4
+ data.tar.gz: b20aaaa204b7b1bb814c6a42bb32105b2236641d381048941dae452f9db69362
5
5
  SHA512:
6
- metadata.gz: 6cf9a39fc15d9bc7be7fc36e4364cca347ca1e54a15be6cd02fd382c2bac65c839579b465a0801a8c1ae690c4a8ae885731bfe82c2b6aefb168323b68991fe34
7
- data.tar.gz: 73333bc1f2bb945bdd6963f7f5cdfebc7fce906edd391b036ea81f0c462e37dad752caac15449e8778e7878e19d8c433b15b255de37d743249cebcd3516ce151
6
+ metadata.gz: 1ec29124dac0e2b84f2bfbb0a2625f9441e43f51f4416c62b606cbf5b91a5d6cda846caf629b3b6cfbbb1989e71ec2321479d37b557423cba9995a95e5808184
7
+ data.tar.gz: 49802f38af22e86afb99ab8c628f2f367415116bcc4301e9757fc14d7f54ed339338e3c4356dffbab4b3c672b625cf59d1e52c0ce65c9c1eb8ccb44189f0c560
data/.gitignore CHANGED
@@ -6,3 +6,6 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ *.xlsx
10
+ *.xls
11
+ *.csv
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- privacy (0.1.1)
4
+ privacy (0.1.3)
5
5
  creek
6
6
  thor
7
+ write_xlsx
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
@@ -16,7 +17,12 @@ GEM
16
17
  mini_portile2 (~> 2.4.0)
17
18
  rake (12.3.3)
18
19
  rubyzip (2.3.0)
19
- thor (0.20.3)
20
+ thor (1.0.1)
21
+ write_xlsx (0.85.7)
22
+ rubyzip (>= 1.0.0)
23
+ zip-zip
24
+ zip-zip (0.3)
25
+ rubyzip (>= 1.0.0)
20
26
 
21
27
  PLATFORMS
22
28
  ruby
data/README.md CHANGED
@@ -20,9 +20,9 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- ```
24
- privacy process ./file.xlsx
25
- ```
23
+ Process all excel files in current directory `privacy process`.
24
+
25
+ Process a specific file in current directory `privacy process /file.xlsx`.
26
26
 
27
27
  ## Development
28
28
 
@@ -1,11 +1,13 @@
1
1
  require 'privacy/version'
2
+ require 'privacy/processor'
2
3
  require 'thor'
3
4
 
4
5
  module Privacy
5
6
  class CLI < Thor
6
7
  desc "process [file]", "Make data private"
7
- def process(file)
8
- puts file
8
+ def process(file = nil)
9
+ file.nil? ? Dir.glob("*.xlsx") { |file| Processor.new(file) }
10
+ : Processor.new(file)
9
11
  end
10
12
  end
11
13
  end
@@ -0,0 +1,68 @@
1
+ require 'creek'
2
+ require 'write_xlsx'
3
+
4
+ class Privacy::Processor
5
+ attr_reader :file
6
+
7
+ DIRECTORY = 'processed'
8
+
9
+ def initialize(file)
10
+ @file = file
11
+ process
12
+ end
13
+
14
+ protected
15
+
16
+ def process
17
+ puts "Processing #{@file}"
18
+ make_directory
19
+ filter_data
20
+ write_file
21
+ end
22
+
23
+ def make_directory
24
+ Dir.mkdir DIRECTORY unless File.exists? DIRECTORY
25
+ end
26
+
27
+ def filter_data
28
+ sheet.rows.each do |row|
29
+ row.each do |key, value|
30
+ worksheet.write key, value
31
+ end
32
+ end
33
+ end
34
+
35
+ def write_file
36
+ workbook.close
37
+ end
38
+
39
+ # New file
40
+ # http://cxn03651.github.io/write_xlsx/index.html
41
+
42
+ def workbook
43
+ @workbook ||= WriteXLSX.new processed_file_name
44
+ end
45
+
46
+ def worksheet
47
+ @worksheet ||= workbook.add_worksheet
48
+ end
49
+
50
+ def processed_file_name
51
+ "#{DIRECTORY}/#{file}"
52
+ end
53
+
54
+ # Current file
55
+ # https://github.com/pythonicrubyist/creek
56
+
57
+ def path
58
+ @path ||= File.expand_path file
59
+ end
60
+
61
+ def data
62
+ @data ||= Creek::Book.new path
63
+ end
64
+
65
+ def sheet
66
+ @sheet ||= data.sheets[0]
67
+ end
68
+ end
@@ -1,3 +1,3 @@
1
1
  module Privacy
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.require_paths = ["lib"]
28
28
  spec.add_dependency "thor"
29
29
  spec.add_dependency "creek"
30
+ spec.add_dependency "write_xlsx"
30
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: privacy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arnaud Levy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-27 00:00:00.000000000 Z
11
+ date: 2020-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: write_xlsx
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  description: Remove first name and last name from xls files, replace them with an
42
56
  anonymous placeholder
43
57
  email:
@@ -58,6 +72,7 @@ files:
58
72
  - bin/setup
59
73
  - exe/privacy
60
74
  - lib/privacy.rb
75
+ - lib/privacy/processor.rb
61
76
  - lib/privacy/version.rb
62
77
  - privacy.gemspec
63
78
  homepage: https://github.com/arnaudlevy/privacy