Class: Mineshaft::Install

Inherits:
Object
  • Object
show all
Defined in:
lib/mineshaft/install.rb

Instance Method Summary collapse

Instance Method Details

#build(prefix) ⇒ Object



57
58
59
# File 'lib/mineshaft/install.rb', line 57

def build(prefix)
  %x(./configure --prefix #{prefix}; make; sudo make install)
end

#download(url, download_dir) ⇒ Object



43
44
45
46
47
48
49
50
51
52
# File 'lib/mineshaft/install.rb', line 43

def download(url, download_dir)
  split_url(url) do |site, file|
    Net::HTTP.start(site) do |http|
      response = http.get(file)
      open("#{download_dir}/ruby.tar.bz2", "w") do |f|
        f.write(response.body)
      end
    end
  end
end

#find_slash_indices(url) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/mineshaft/install.rb', line 18

def find_slash_indices(url)
  slash_array = []
  url = url.split("")
  i = 0

  url.each do |l|
    break if slash_array.length == 3
    slash_array.push(i) if l == "/"
    i += 1
  end

  @slash_array = slash_array
end

#get_latest_stableObject



14
15
16
# File 'lib/mineshaft/install.rb', line 14

def get_latest_stable
  "2.3.0"
end

#split_url(url) {|site, tar| ... } ⇒ Object

Yields:

  • (site, tar)


32
33
34
35
36
37
38
39
40
41
# File 'lib/mineshaft/install.rb', line 32

def split_url(url)
  find_slash_indices(url)
  beg = @slash_array[1] + 1
  fin = @slash_array[2] - 1
  site = url[beg..fin]
  fin += 1
  tar = url[fin..url.length]

  yield site, tar
end

#unzipObject



54
55
# File 'lib/mineshaft/install.rb', line 54

def unzip
end