Class: Adaptibrew
- Inherits:
-
Object
- Object
- Adaptibrew
- Defined in:
- lib/adaptibrew.rb
Overview
This is the ‘manager’ for the adaptibrew repo. It handles cloning and such.
Instance Attribute Summary collapse
-
#install_dir ⇒ Object
Returns the value of attribute install_dir.
Instance Method Summary collapse
-
#clear ⇒ Object
Danger zone…
-
#clone ⇒ Object
If used in IRB, Ripl, etc.
-
#initialize ⇒ Adaptibrew
constructor
A new instance of Adaptibrew.
- #present? ⇒ Boolean
- #refresh ⇒ Object
Constructor Details
#initialize ⇒ Adaptibrew
8 9 10 11 |
# File 'lib/adaptibrew.rb', line 8 def initialize @install_dir = Dir.home + "/.brewer/" refresh end |
Instance Attribute Details
#install_dir ⇒ Object
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
#clear ⇒ Object
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 |
#clone ⇒ Object
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 |
#refresh ⇒ Object
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 |