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
71 72 73 74 75 76 77 78 |
# File 'lib/evm/package.rb', line 71 def current if File.symlink?(Evm::EVM_EMACS_PATH) current_bin_path = File.readlink(Evm::EVM_EMACS_PATH) if (match = Regexp.new("#{Evm::LOCAL_PATH}/?(?<current>[^/]+)/.+").match(current_bin_path)) find match[:current] end end 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
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/evm/package.rb', line 32 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.file?(bin) && File.executable?(bin) end |
#path ⇒ Object
62 63 64 |
# File 'lib/evm/package.rb', line 62 def path File.join(Evm::LOCAL_PATH, @name) end |
#recipe ⇒ Object
58 59 60 |
# File 'lib/evm/package.rb', line 58 def recipe Evm::Recipe.find(@name) end |
#tmp_path ⇒ Object
66 67 68 |
# File 'lib/evm/package.rb', line 66 def tmp_path File.join(Evm::LOCAL_PATH, 'tmp') end |
#to_s ⇒ Object
54 55 56 |
# File 'lib/evm/package.rb', line 54 def to_s @name end |
#uninstall! ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/evm/package.rb', line 44 def uninstall! if File.exist?(path) FileUtils.rm_r(path) end if current? FileUtils.rm(Evm::EVM_EMACS_PATH) end end |
#use! ⇒ Object
25 26 27 28 29 30 |
# File 'lib/evm/package.rb', line 25 def use! FileUtils.ln_sf(bin, Evm::EVM_EMACS_PATH) unless File.symlink?(Evm::EMACS_PATH) FileUtils.ln_sf(Evm::EVM_EMACS_PATH, Evm::EMACS_PATH) end end |