lib/jetel/modules/ip/ip.rb in jetel-0.0.6 vs lib/jetel/modules/ip/ip.rb in jetel-0.0.7
- old
+ new
@@ -8,45 +8,49 @@
require_relative '../../modules/module'
module Jetel
module Modules
class Ip < Module
- SOURCES = [
- {
- name: 'afrinic',
- url: 'ftp://ftp.afrinic.net/pub/stats/afrinic/delegated-afrinic-latest'
- },
- {
- name: 'apnic',
- url: 'ftp://ftp.apnic.net/pub/stats/apnic/delegated-apnic-latest'
- },
- {
- name: 'arin',
- url: 'ftp://ftp.arin.net/pub/stats/arin/delegated-arin-latest'
- },
- {
- name: 'lacnic',
- url: 'ftp://ftp.lacnic.net/pub/stats/lacnic/delegated-lacnic-latest'
- },
- {
- name: 'ripencc',
- url: 'ftp://ftp.ripe.net/ripe/stats/delegated-ripencc-latest'
- },
- {
- name: 'iana',
- url: 'ftp://ftp.apnic.net/pub/stats/iana/delegated-iana-latest'
- }
- ]
+ class << self
+ def sources
+ [
+ {
+ name: 'afrinic',
+ url: 'ftp://ftp.afrinic.net/pub/stats/afrinic/delegated-afrinic-latest'
+ },
+ {
+ name: 'apnic',
+ url: 'ftp://ftp.apnic.net/pub/stats/apnic/delegated-apnic-latest'
+ },
+ {
+ name: 'arin',
+ url: 'ftp://ftp.arin.net/pub/stats/arin/delegated-arin-latest'
+ },
+ {
+ name: 'lacnic',
+ url: 'ftp://ftp.lacnic.net/pub/stats/lacnic/delegated-lacnic-latest'
+ },
+ {
+ name: 'ripencc',
+ url: 'ftp://ftp.ripe.net/ripe/stats/delegated-ripencc-latest'
+ },
+ {
+ name: 'iana',
+ url: 'ftp://ftp.apnic.net/pub/stats/iana/delegated-iana-latest'
+ }
+ ]
+ end
+ end
def download(global_options, options, args)
- SOURCES.pmap do |source|
+ self.class.sources.pmap do |source|
download_source(source, global_options.merge(options))
end
end
def extract(global_options, options, args)
- SOURCES.pmap do |source|
+ self.class.sources.pmap do |source|
downloaded_file = downloaded_file(source, global_options.merge(options))
dest_dir = extract_dir(source, global_options.merge(options))
puts "Extracting #{downloaded_file}"
@@ -54,11 +58,11 @@
FileUtils.cp(downloaded_file, dest_dir)
end
end
def transform(global_options, options, args)
- SOURCES.pmap do |source|
+ self.class.sources.pmap do |source|
opts = global_options.merge(options)
extracted_file = extracted_file(source, opts)
transformed_file = transformed_file(source, opts)
@@ -85,21 +89,9 @@
next if row[0] != source[:name]
csv_out << row
end
end
end
- end
- end
-
- def load(global_options, options, args)
- SOURCES.map do |source|
- opts = global_options.merge(options)
-
- transformed_file = transformed_file(source, opts)
-
- loader = Helper.get_loader(opts['data_loader'])
-
- loader.load(self, source, transformed_file, opts)
end
end
end
end
end