Class: Datafile::ZipDataset

Inherits:
DatasetNode show all
Defined in:
lib/datafile/workers/zip/dataset.rb

Overview

use(rename to) ZipDatasetWorker - why, why not ???

Instance Method Summary collapse

Methods inherited from DatasetNode

#name, #opts, #setup

Constructor Details

#initialize(dataset) ⇒ ZipDataset

read dataset from zip(archive)



9
10
11
# File 'lib/datafile/workers/zip/dataset.rb', line 9

def initialize( dataset )
  super( dataset )
end

Instance Method Details

#downloadObject



34
35
36
37
38
39
40
# File 'lib/datafile/workers/zip/dataset.rb', line 34

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

#dumpObject



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/datafile/workers/zip/dataset.rb', line 43

def dump
  ## for debuggin dump dataset (also check if zip exits)
  puts "dataset '#{name}' opts=#{opts.to_json}"     ## use opts.inspect instead of to_json - why? why not?
  puts "  local '#{local_zip_name}' (#{local_zip_path})"
  if File.exist?( local_zip_path )
    puts "    size: #{File.size(local_zip_path)} bytes"
  else
    puts "    (file not found)"
  end
  puts "  remote '#{remote_zip_url}'"
end

#local_zip_nameObject



19
20
21
22
23
# File 'lib/datafile/workers/zip/dataset.rb', line 19

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



29
30
31
# File 'lib/datafile/workers/zip/dataset.rb', line 29

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

#local_zip_rootObject



25
26
27
# File 'lib/datafile/workers/zip/dataset.rb', line 25

def local_zip_root
  "./tmp"
end

#remote_zip_urlObject

remote zip url



13
14
15
16
17
# File 'lib/datafile/workers/zip/dataset.rb', line 13

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