Class: Adaptibrew

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

Overview

This is the ‘manager’ for the adaptibrew repo. It handles cloning and such.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAdaptibrew



8
9
10
11
# File 'lib/adaptibrew.rb', line 8

def initialize
  @install_dir = Dir.home + "/.brewer/"
  refresh
end

Instance Attribute Details

#install_dirObject

Returns the value of attribute install_dir.



6
7
8
# File 'lib/adaptibrew.rb', line 6

def install_dir
  @install_dir
end

Instance Method Details

#clearObject

Danger zone…



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/adaptibrew.rb', line 23

def clear
  # :nocov: since this requires network to be off
  if !network?
    print "Warning: you have no network connection. If you clear, you will not be able to clone again, and you'll be stuck without the adaptibrew source. Are you sure? "
    if !confirm
      exit
    end
  end
  # :nocov:
  FileUtils.rm_rf(@install_dir + 'adaptibrew')
  self
end

#cloneObject

If used in IRB, Ripl, etc. it will clone into the directory IRB was started in



14
15
16
17
18
19
20
# File 'lib/adaptibrew.rb', line 14

def clone
  raise "🛑  Cannot clone, no network connection" unless network?
  if !Dir.exists?(@install_dir + "adaptibrew")
    Git.clone('https://github.com/llamicron/adaptibrew.git', 'adaptibrew', :path => @install_dir)
  end
  self
end

#present?Boolean



43
44
45
46
47
48
# File 'lib/adaptibrew.rb', line 43

def present?
  if Dir.exists?(@install_dir + 'adaptibrew/')
    return true
  end
  false
end

#refreshObject



36
37
38
39
40
41
# File 'lib/adaptibrew.rb', line 36

def refresh
  raise "🛑  Cannot refresh, no network connection" unless network?
  clear
  clone
  self
end