Class: Datafile::Dataset

Inherits:
Object
  • Object
show all
Includes:
LogUtils::Logging
Defined in:
lib/datafile/datasets/dataset.rb

Direct Known Subclasses

BeerDataset, FootballDataset, WorldDataset

Instance Method Summary collapse

Constructor Details

#initialize(name, opts = {}) ⇒ Dataset

Returns a new instance of Dataset.



8
9
10
11
# File 'lib/datafile/datasets/dataset.rb', line 8

def initialize( name, opts={} )
  @name = name
  @opts = opts
end

Instance Method Details

#downloadObject



39
40
41
42
43
44
45
# File 'lib/datafile/datasets/dataset.rb', line 39

def download()
  logger.info( "download dataset '#{@name}'" )
  logger.info( "   from '#{remote_zip_url}'" )
  logger.info( "   to '#{local_zip_path}'..." )

  download_blob( remote_zip_url, local_zip_path )
end

#local_zip_nameObject



24
25
26
27
28
# File 'lib/datafile/datasets/dataset.rb', line 24

def local_zip_name()
  ### note: replace / in name w/ --I--
  ##  e.g. flatten the filename, that is, do NOT include any folders
  @name.gsub('/', '--I--')   # note: will NOT include/return .zip extension
end

#local_zip_pathObject

local zip path



34
35
36
# File 'lib/datafile/datasets/dataset.rb', line 34

def local_zip_path()  # local zip path
  "#{local_zip_root}/#{local_zip_name}.zip"
end

#local_zip_rootObject



30
31
32
# File 'lib/datafile/datasets/dataset.rb', line 30

def local_zip_root()
  "./tmp"
end

#remote_zip_urlObject

remote zip url



18
19
20
21
22
# File 'lib/datafile/datasets/dataset.rb', line 18

def remote_zip_url()  # remote zip url
  ###  note: use http:// for now - lets us use (personal proxy NOT working w/ https) for now
  ## "https://github.com/#{@name}/archive/master.zip"
  "http://github.com/#{@name}/archive/master.zip"
end

#setupObject



13
14
15
16
# File 'lib/datafile/datasets/dataset.rb', line 13

def setup()
  value = @opts[:setup] || 'all'
  "setups/#{value}"
end