Class: Jetel::Modules::Wifileaks
- Inherits:
-
Module
- Object
- Module
- Jetel::Modules::Wifileaks
show all
- Defined in:
- lib/jetel/modules/wifileaks/wifileaks.rb
Instance Attribute Summary
Attributes inherited from Module
#downloader
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Module
#download_dir, download_dir, #download_source, downloaded_file, #downloaded_file, extract_dir, #extract_dir, extracted_file, #extracted_file, #initialize, #sources, target_dir, #target_dir, #transform_dir, transform_dir, transformed_file, #transformed_file, #unzip
Class Method Details
.sources ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'lib/jetel/modules/wifileaks/wifileaks.rb', line 33
def sources
[
{
name: 'wifileaks',
url: 'http://download.wifileaks.cz/data/wifileaks_150709.tsv'
}
]
end
|
Instance Method Details
#download(global_options, options, args) ⇒ Object
43
44
45
46
47
|
# File 'lib/jetel/modules/wifileaks/wifileaks.rb', line 43
def download(global_options, options, args)
self.class.sources.pmap do |source|
download_source(source, global_options.merge(options))
end
end
|
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/jetel/modules/wifileaks/wifileaks.rb', line 49
def (global_options, options, args)
self.class.sources.pmap do |source|
downloaded_file = downloaded_file(source, global_options.merge(options))
dest_dir = (source, global_options.merge(options))
puts "Extracting #{downloaded_file}"
FileUtils.mkdir_p(dest_dir)
FileUtils.cp(downloaded_file, dest_dir)
end
end
|
#load(global_options, options, args) ⇒ Object
92
93
94
95
|
# File 'lib/jetel/modules/wifileaks/wifileaks.rb', line 92
def load(global_options, options, args)
res = super(global_options, options.merge({:delimiter => "\t"}), args)
res
end
|
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/jetel/modules/wifileaks/wifileaks.rb', line 61
def transform(global_options, options, args)
self.class.sources.pmap do |source|
opts = global_options.merge(options)
= (source, opts)
transformed_file = transformed_file(source, opts)
puts "Transforming #{extracted_file}"
= %w(
MAC
SSID
security
latitude
longitude
altitude
updated_at
)
File.open(, 'r') do |file_in|
File.open(transformed_file, 'w') do |file_out|
file_out.puts(.join("\t"))
file_in.each do |line|
next if line == "\n"
file_out.puts(line.chomp)
end
end
end
end
end
|