Class: Textmate::Local

Inherits:
Object
  • Object
show all
Defined in:
lib/textmate/local.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.bundle_install_pathObject



19
20
21
# File 'lib/textmate/local.rb', line 19

def self.bundle_install_path
  bundle_paths['User Pristine']
end

.bundle_pathsObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/textmate/local.rb', line 3

def self.bundle_paths
  bundle_paths = {
    'Application'     => '/Applications/TextMate.app/Contents/SharedSupport/Bundles',
    'User'            => "#{ENV["HOME"]}/Library/Application Support/TextMate/Bundles",
    'System'          => '/Library/Application Support/TextMate/Bundles',
    'User Pristine'   => "#{ENV["HOME"]}/Library/Application Support/TextMate/Pristine Copy/Bundles",
    'System Pristine' => '/Library/Application Support/TextMate/Pristine Copy/Bundles',
  }

  # specific to my setup
  shell_subsystem_dir = "#{ENV["HOME"]}/.bash/config/textmate.d"
  bundle_paths['User Pristine'] = shell_subsystem_dir if File.exist?(shell_subsystem_dir)

  bundle_paths
end

Instance Method Details

#bundle_install_pathObject



27
28
29
# File 'lib/textmate/local.rb', line 27

def bundle_install_path
  self.class.bundle_install_path
end

#bundle_pathsObject



23
24
25
# File 'lib/textmate/local.rb', line 23

def bundle_paths
  self.class.bundle_paths
end

#bundles(search = '') ⇒ Object



31
32
33
34
35
36
# File 'lib/textmate/local.rb', line 31

def bundles(search = '')
  bundle_paths.inject({}) do |hash, (name, path)|
    hash[name] = find_bundles(name, search) if File.exist?(path)
    hash
  end
end

#install(bundle, remote) ⇒ Object



38
39
40
# File 'lib/textmate/local.rb', line 38

def install(bundle, remote)
  remote.install(bundle)
end

#uninstall(bundle) ⇒ Object



42
43
44
45
46
47
48
49
# File 'lib/textmate/local.rb', line 42

def uninstall(bundle)
  bundle_paths.values.each do |path|
    bundle_path = File.join(path, "#{bundle}.tmbundle")
    if File.exist? bundle_path
      %x[osascript -e 'tell application "Finder" to move the POSIX file "#{bundle_path}" to trash']
    end
  end
end