Class: BundleMate::Bundle
- Inherits:
-
Object
- Object
- BundleMate::Bundle
- Defined in:
- lib/bundle_mate/bundle.rb
Class Attribute Summary collapse
-
.local_bundle_path ⇒ Object
Returns the value of attribute local_bundle_path.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
- .from_macromates(bundle_name) ⇒ Object
- .installed_bundles ⇒ Object
- .remote_bundle_list(repository = BundleMate::MACROMATES_REPOSITORY) ⇒ Object
Instance Method Summary collapse
-
#initialize(bundle_url) ⇒ Bundle
constructor
A new instance of Bundle.
- #install(revision = 'HEAD') ⇒ Object
- #installed? ⇒ Boolean
- #meta_data(key) ⇒ Object
- #uninstall ⇒ Object
- #uninstall_with_confirmation ⇒ Object
- #update ⇒ Object
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_path ⇒ Object
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
#name ⇒ Object (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_bundles ⇒ Object
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
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 |
#uninstall ⇒ Object
37 38 39 |
# File 'lib/bundle_mate/bundle.rb', line 37 def uninstall FileUtils.rm_rf(local_path) end |
#uninstall_with_confirmation ⇒ Object
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 |
#update ⇒ Object
27 28 29 |
# File 'lib/bundle_mate/bundle.rb', line 27 def update system("cd '#{local_path}' && svn up") end |