Class: BundleMate::Bundle

Inherits:
Object
  • Object
show all
Defined in:
lib/bundle_mate/bundle.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bundle_url) ⇒ Bundle

Returns a new instance of Bundle.



10
11
12
13
# File 'lib/bundle_mate/bundle.rb', line 10

def initialize(bundle_url)
  @url = bundle_url
  @name = File.basename(bundle_url, '.tmbundle')
end

Class Attribute Details

.local_bundle_pathObject

Returns the value of attribute local_bundle_path.



42
43
44
# File 'lib/bundle_mate/bundle.rb', line 42

def local_bundle_path
  @local_bundle_path
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/bundle_mate/bundle.rb', line 8

def name
  @name
end

Class Method Details

.from_macromates(bundle_name) ⇒ Object



44
45
46
# File 'lib/bundle_mate/bundle.rb', line 44

def from_macromates(bundle_name)
  new(File.join(BundleMate::MACROMATES_REPOSITORY, bundle_name + '.tmbundle'))
end

.installed_bundlesObject



48
49
50
51
52
# File 'lib/bundle_mate/bundle.rb', line 48

def installed_bundles
  Dir["#{local_bundle_path}/**/*.tmbundle"].map do |bundle_path|
    new(File.basename(bundle_path, '.tmbundle'))
  end
end

.remote_bundle_list(repository = BundleMate::MACROMATES_REPOSITORY) ⇒ Object



54
55
56
57
58
# File 'lib/bundle_mate/bundle.rb', line 54

def remote_bundle_list(repository = BundleMate::MACROMATES_REPOSITORY)
  `svn ls #{repository}`.split("\n").map do |bundle|
    bundle_name = bundle.match(/(.*)\.tmbundle\/$/)[1]
  end
end

Instance Method Details

#install(revision = 'HEAD') ⇒ Object



23
24
25
# File 'lib/bundle_mate/bundle.rb', line 23

def install(revision = 'HEAD')
  system("cd '#{self.class.local_bundle_path}' && svn co -r#{revision} #{remote_url}")
end

#installed?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/bundle_mate/bundle.rb', line 15

def installed?
  File.exist?(local_path)
end

#meta_data(key) ⇒ Object



19
20
21
# File 'lib/bundle_mate/bundle.rb', line 19

def (key)
  ( ||= remote_plist)[key]
end

#uninstallObject



37
38
39
# File 'lib/bundle_mate/bundle.rb', line 37

def uninstall
  FileUtils.rm_rf(local_path)
end

#uninstall_with_confirmationObject



31
32
33
34
35
# File 'lib/bundle_mate/bundle.rb', line 31

def uninstall_with_confirmation
  with_confirmation("About to remove #{local_path}.") do
    uninstall
  end
end

#updateObject



27
28
29
# File 'lib/bundle_mate/bundle.rb', line 27

def update
  system("cd '#{local_path}' && svn up")
end