Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
f6774011
Commit
f6774011
authored
May 08, 2018
by
Jacob Schatz
Committed by
Micaël Bergeron
Jun 22, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create list of files that are output.
parent
ec533816
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletion
+10
-1
lib/pseudonymity/table.rb
lib/pseudonymity/table.rb
+10
-1
No files found.
lib/pseudonymity/table.rb
View file @
f6774011
...
...
@@ -31,11 +31,12 @@ module Pseudonymity
@csv_output
=
""
parse_config
@schema
=
{}
@output_files
=
[]
end
def
tables_to_csv
tables
=
config
[
"tables"
]
@csv_output
=
config
[
"output"
][
"csv"
]
@csv_output
=
config
[
"output"
][
"csv"
]
.
chomp
(
"
\/
"
)
if
not
File
.
directory?
(
@csv_output
)
puts
"No such directory
#{
@csv_output
}
"
return
...
...
@@ -45,13 +46,20 @@ module Pseudonymity
table_to_csv
(
k
,
v
[
"whitelist"
],
v
[
"pseudo"
])
end
schema_to_yml
file_list_to_json
end
def
schema_to_yml
file_path
=
"
#{
@csv_output
}
/schema_
#{
Time
.
now
.
to_i
}
.yml"
@output_files
<<
file_path
File
.
open
(
file_path
,
'w'
)
{
|
file
|
file
.
write
(
@schema
.
to_yaml
)
}
end
def
file_list_to_json
file_path
=
"
#{
@csv_output
}
/file_list.json"
File
.
open
(
file_path
,
'w'
)
{
|
file
|
file
.
write
(
@output_files
.
to_json
)
}
end
def
table_to_csv
(
table
,
whitelist_columns
,
pseudonymity_columns
)
sql
=
"SELECT
#{
whitelist_columns
.
join
(
","
)
}
FROM
#{
table
}
;"
type_sql
=
"SELECT column_name, data_type FROM information_schema.columns WHERE table_name = '
#{
table
}
';"
...
...
@@ -86,6 +94,7 @@ module Pseudonymity
end
end
File
.
open
(
file_path
,
'w'
)
{
|
file
|
file
.
write
(
contents
)
}
@output_files
<<
file_path
return
file_path
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment