Class: Evm::Package
- Inherits:
-
Object
- Object
- Evm::Package
- Defined in:
- lib/evm/package.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #bin ⇒ Object
- #current? ⇒ Boolean
-
#initialize(name) ⇒ Package
constructor
A new instance of Package.
- #install! ⇒ Object
- #installed? ⇒ Boolean
- #path ⇒ Object
- #recipe ⇒ Object
- #tmp_path ⇒ Object
- #to_s ⇒ Object
- #uninstall! ⇒ Object
- #use! ⇒ Object
Constructor Details
#initialize(name) ⇒ Package
Returns a new instance of Package.
5 6 7 |
# File 'lib/evm/package.rb', line 5 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/evm/package.rb', line 3 def name @name end |
Class Method Details
.all ⇒ Object
89 90 91 92 93 94 |
# File 'lib/evm/package.rb', line 89 def all recipes = Evm::Recipe.all recipes.map do |recipe| Package.new(recipe.name) end end |
.current ⇒ Object
74 75 76 77 78 |
# File 'lib/evm/package.rb', line 74 def current if File.exist?(current_file) find File.read(current_file) end end |
.current_file ⇒ Object
70 71 72 |
# File 'lib/evm/package.rb', line 70 def current_file File.join(Evm::LOCAL_PATH, 'current') end |
Instance Method Details
#bin ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/evm/package.rb', line 17 def bin if Evm::Os.osx? && File.exist?(File.join(path, 'Emacs.app')) File.join(path, 'Emacs.app', 'Contents', 'MacOS', 'Emacs') else File.join(path, 'bin', 'emacs') end end |
#current? ⇒ Boolean
9 10 11 |
# File 'lib/evm/package.rb', line 9 def current? Package.current && Package.current.name == @name end |
#install! ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/evm/package.rb', line 31 def install! unless File.exist?(path) Dir.mkdir(path) end unless File.exist?(tmp_path) Dir.mkdir(tmp_path) end Evm::Builder.new(recipe).build! end |
#installed? ⇒ Boolean
13 14 15 |
# File 'lib/evm/package.rb', line 13 def installed? File.exist?(path) end |
#path ⇒ Object
61 62 63 |
# File 'lib/evm/package.rb', line 61 def path File.join(Evm::LOCAL_PATH, @name) end |
#recipe ⇒ Object
57 58 59 |
# File 'lib/evm/package.rb', line 57 def recipe Evm::Recipe.find(@name) end |
#tmp_path ⇒ Object
65 66 67 |
# File 'lib/evm/package.rb', line 65 def tmp_path File.join(Evm::LOCAL_PATH, 'tmp') end |
#to_s ⇒ Object
53 54 55 |
# File 'lib/evm/package.rb', line 53 def to_s @name end |
#uninstall! ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/evm/package.rb', line 43 def uninstall! if File.exist?(path) FileUtils.rm_r(path) end if current? File.delete(Package.current_file) end end |
#use! ⇒ Object
25 26 27 28 29 |
# File 'lib/evm/package.rb', line 25 def use! File.open(Package.current_file, 'w') do |file| file.write(@name) end end |