Class: Tara::Fetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/tara/fetcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(download_dir, target, tr_version, options = {}) ⇒ Fetcher

Returns a new instance of Fetcher.



9
10
11
12
13
14
15
16
# File 'lib/tara/fetcher.rb', line 9

def initialize(download_dir, target, tr_version, options={})
  @download_dir = download_dir
  @target = target
  @tr_version = tr_version
  @ruby_version = options[:ruby_version] || RUBY_VERSION
  @release_url = options[:tr_release_url] || 'https://d6r77u77i8pq3.cloudfront.net/releases'
  @shell = options[:shell] || Shell
end

Instance Method Details

#fetch_native_gem(name, version) ⇒ Object



28
29
30
31
32
# File 'lib/tara/fetcher.rb', line 28

def fetch_native_gem(name, version)
  remote_uri = native_gem_remote_uri(name, version)
  local_uri = %(#{@download_dir}/#{name}-#{version}-#{@tr_version}-#{@ruby_version}-#{@target}.tar.gz)
  fetch(remote_uri, local_uri)
end

#fetch_rubyObject



23
24
25
26
# File 'lib/tara/fetcher.rb', line 23

def fetch_ruby
  local_uri = %(#{@download_dir}/ruby-#{@tr_version}-#{@ruby_version}-#{@target}.tar.gz)
  fetch(ruby_remote_uri, local_uri)
end

#setupObject



18
19
20
21
# File 'lib/tara/fetcher.rb', line 18

def setup
  FileUtils.mkdir_p(@download_dir)
  self
end