class Evm::Package
Attributes
name[R]
Public Class Methods
all()
click to toggle source
# File lib/evm/package.rb, line 102 def all recipes = Evm::Recipe.all recipes.map do |recipe| Package.new(recipe.name) end end
current()
click to toggle source
# File lib/evm/package.rb, line 87 def current if (name = Evm.config[:current]) find(name) end end
find(package_name)
click to toggle source
# File lib/evm/package.rb, line 93 def find(package_name) recipe = Evm::Recipe.find(package_name) if recipe Package.new(package_name) else raise Evm::Exception.new("No such package: #{package_name}") end end
new(name, options = {})
click to toggle source
# File lib/evm/package.rb, line 5 def initialize(name, options = {}) @name = name @file = options[:file] || File end
Public Instance Methods
bin()
click to toggle source
# File lib/evm/package.rb, line 18 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?()
click to toggle source
# File lib/evm/package.rb, line 10 def current? Package.current && Package.current.name == @name end
disuse!()
click to toggle source
# File lib/evm/package.rb, line 37 def disuse! delete_shims! Evm.config[:current] = nil end
install!()
click to toggle source
# File lib/evm/package.rb, line 48 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?()
click to toggle source
# File lib/evm/package.rb, line 14 def installed? File.file?(bin) && File.executable?(bin) end
path()
click to toggle source
# File lib/evm/package.rb, line 78 def path File.join(Evm.config[:path], @name) end
recipe()
click to toggle source
# File lib/evm/package.rb, line 74 def recipe Evm::Recipe.find(@name) end
tmp_path()
click to toggle source
# File lib/evm/package.rb, line 82 def tmp_path File.join(Evm.config[:path], 'tmp') end
to_s()
click to toggle source
# File lib/evm/package.rb, line 70 def to_s @name end
uninstall!()
click to toggle source
# File lib/evm/package.rb, line 60 def uninstall! if File.exist?(path) FileUtils.rm_r(path) end if current? FileUtils.rm(Evm::EVM_EMACS_PATH) end end
use!()
click to toggle source
# File lib/evm/package.rb, line 26 def use! delete_shims! [Evm::EMACS_PATH, Evm::EVM_EMACS_PATH].each do |bin_path| @file.open(bin_path, 'w') do |file| file.puts("#!/bin/bash\nexec \"#{bin}\" \"$@\"") end @file.chmod(0755, bin_path) end Evm.config[:current] = name end
Private Instance Methods
delete_shims!()
click to toggle source
# File lib/evm/package.rb, line 42 def delete_shims! [Evm::EMACS_PATH, Evm::EVM_EMACS_PATH].each do |bin_path| @file.delete(bin_path) if @file.exists?(bin_path) end end