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 Method Summary collapse

Constructor Details

#initializeAdaptibrew

Returns a new instance of Adaptibrew.



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

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

Instance Method Details

#clearObject

Danger zone…



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

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



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

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

Returns:

  • (Boolean)


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

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

#refreshObject



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

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