Module: Downlow

Defined in:
lib/downlow.rb,
lib/downlow/fetcher.rb,
lib/downlow/extractor.rb,
lib/downlow/fetchers/git.rb,
lib/downlow/fetchers/http.rb,
lib/downlow/extractors/dir.rb,
lib/downlow/extractors/zip.rb,
lib/downlow/fetchers/local.rb,
lib/downlow/fetchers/github.rb,
lib/downlow/extractors/tar_gz.rb

Defined Under Namespace

Classes: Dir, Extractor, Fetcher, Git, Github, Http, Local, TarGz, Zip

Constant Summary collapse

VERSION =
'0.1.4'

Class Method Summary collapse

Class Method Details

.extract(*args) ⇒ Object



31
32
33
# File 'lib/downlow.rb', line 31

def self.extract(*args)
  Downlow::Extractor.extract(*args)
end

.fetch(*args) ⇒ Object



27
28
29
# File 'lib/downlow.rb', line 27

def self.fetch(*args)
  Downlow::Fetcher.fetch(*args)
end

.get(url, *args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/downlow.rb', line 6

def self.get(url, *args)
  options = {}
  first = args.shift
  if first.is_a?(Hash)
    # hash as argument means were setting the options
    options = first
  elsif first.to_s != ''
    # string as argument means we're setting the destination
    options[:destination] = first
  end
  # merge the rest as options
  options = args.inject(options) {|o, arg| o = o.merge(arg) } if !args.empty?
  # fetch to a temp dir
  fetch_options = options.dup
  fetch_options.delete(:destination)
  path = fetch(url, fetch_options)
  final_path = extract(path, options)
  FileUtils.rm_r(path) # delete tmp path
  final_path
end