You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
736 B
38 lines
736 B
12 years ago
|
class Cask
|
||
|
class AppLinker
|
||
|
def initialize(cask)
|
||
|
@cask = cask
|
||
|
end
|
||
|
|
||
|
def link
|
||
|
@cask.linkable_apps.each do |app|
|
||
|
link_app(app)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def unlink
|
||
|
@cask.linkable_apps.each do |app|
|
||
|
unlink_app(app)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def unlink_app(app)
|
||
|
app_path = Cask.appdir.join(app.basename)
|
||
|
app_path.delete if app_path.exist?
|
||
|
end
|
||
|
|
||
|
def remove_app_extension(path)
|
||
|
Pathname(path.to_s.sub(/\.app$/, ''))
|
||
|
end
|
||
|
|
||
|
def link_app(app)
|
||
|
app_path = Cask.appdir.join(app.basename)
|
||
|
if app_path.directory?
|
||
|
ohai "It seems there is already an app at #{app_path}; not linking."
|
||
|
return
|
||
|
end
|
||
|
`ln -s #{app} #{app_path}`
|
||
|
end
|
||
|
end
|
||
|
end
|