Class: Downloader

Inherits:
Object
  • Object
show all
Defined in:
lib/teuton-get/downloader.rb

Instance Method Summary collapse

Constructor Details

#initializeDownloader

Returns a new instance of Downloader.



12
13
14
15
16
17
18
19
20
21
# File 'lib/teuton-get/downloader.rb', line 12

def initialize
  @dev = TerminalWriter.new
  @repo_config = RepoConfig.default.data
  cache_dirpath = Settings.get(:cache_dirpath)
  @repo_data = RepoData.new(
    config_reader: IniFileReader.new,
    progress_writer: TerminalWriter.new,
    cache_dirpath: cache_dirpath
  )
end

Instance Method Details

#run(id, dirpath = ".") ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/teuton-get/downloader.rb', line 23

def run(id, dirpath = ".")
  reponame, testpath = id.split(Settings::SEPARATOR)

  repourl, status = get_url_for reponame
  unless status == :ok
    @dev.writeln "    #{status}"
    return false
  end

  files, status = get_files_for_test id
  unless status == :ok
    @dev.writeln "    #{status}"
    return false
  end

  download(reponame, repourl, dirpath, testpath, files)
end