bundlemate 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 0.0.1 2007-09-03
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/License.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2007 Luke Redpath
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,13 @@
1
+ History.txt
2
+ License.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ bin/bundlemate
7
+ lib/bundle_mate.rb
8
+ lib/bundle_mate/application.rb
9
+ lib/bundle_mate/bundle.rb
10
+ spec/application_spec.rb
11
+ spec/bundle_spec.rb
12
+ spec/spec.opts
13
+ spec/spec_helper.rb
data/README.txt ADDED
@@ -0,0 +1,26 @@
1
+ bundlemate
2
+ by Luke Redpath
3
+
4
+ == DESCRIPTION:
5
+
6
+ Bundlemate is a simple CLI bundle manager for TextMate.
7
+
8
+ == FEATURES/PROBLEMS:
9
+
10
+ * List bundles available in the Macromates repository
11
+ * Install, uninstall and update bundles
12
+ * Install bundles from third-party repositories
13
+ * Automatic reloading of TextMate bundles.
14
+
15
+ == SYNOPSIS:
16
+
17
+ Run 'bundlemate help' for instructions.
18
+
19
+ == REQUIREMENTS:
20
+
21
+ * simpleconsole >= 0.1.1
22
+ * plist >= 3.0.0
23
+
24
+ == INSTALL:
25
+
26
+ * sudo gem install bundlemate --include-dependencies
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ require 'rubygems'
2
+ require 'hoe'
3
+ require './lib/bundle_mate'
4
+
5
+ begin
6
+ require 'spec/rake/spectask'
7
+ rescue LoadError
8
+ puts 'To use rspec for testing you must install rspec gem:'
9
+ puts '$ sudo gem install rspec'
10
+ exit
11
+ end
12
+
13
+ Hoe.new('bundlemate', BundleMate::VERSION::STRING) do |p|
14
+ p.rubyforge_name = 'ljr'
15
+ p.author = 'Luke Redpath'
16
+ p.email = 'contact@lukeredpath.co.uk'
17
+ p.summary = 'A command-line TextMate bundle manager.'
18
+ p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
19
+ p.url = '' # p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
20
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
21
+ p.extra_deps = [ ['plist', '>= 3.0.0'], ['simpleconsole', '>= 0.1.1'] ]
22
+ p.test_globs = ["spec/**/*_spec.rb"]
23
+ end
24
+
25
+ desc "Run the specs under spec/models"
26
+ Spec::Rake::SpecTask.new do |t|
27
+ t.spec_opts = ['--options', "spec/spec.opts"]
28
+ t.spec_files = FileList['spec/*_spec.rb']
29
+ end
30
+
31
+ Rake::Task['default'].prerequisites.clear
32
+
33
+ desc "Default task is to run specs"
34
+ task :default => :spec
data/bin/bundlemate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ local_libs = [
4
+ File.join(File.dirname(__FILE__), *%w[../lib/bundle_mate])
5
+ ]
6
+
7
+ if File.exist?(local_libs.first)
8
+ local_libs.each { |lib| require lib }
9
+ else
10
+ require 'rubygems'
11
+ require 'bundlemate'
12
+ end
13
+
14
+ BundleMate::Application.run(ARGV)
@@ -0,0 +1,29 @@
1
+ module BundleMate
2
+ MACROMATES_REPOSITORY = 'http://macromates.com/svn/Bundles/trunk/Bundles/'
3
+
4
+ def self.reload_textmate_bundles!
5
+ system("osascript -e 'tell app \"TextMate\" to reload bundles'")
6
+ end
7
+
8
+ module VERSION #:nodoc:
9
+ MAJOR = 0
10
+ MINOR = 1
11
+ TINY = 0
12
+
13
+ STRING = [MAJOR, MINOR, TINY].join('.')
14
+ end
15
+ end
16
+
17
+ class String
18
+ def sanitize_html
19
+ gsub(/<\/?[^>]*>/, "")
20
+ end
21
+ end
22
+
23
+ %w( bundle_mate/bundle
24
+ bundle_mate/application ).each { |lib|
25
+
26
+ require File.join(File.dirname(__FILE__), lib)
27
+ }
28
+
29
+ BundleMate::Bundle.local_bundle_path = File.expand_path("~/Library/Application Support/TextMate/Bundles")
@@ -0,0 +1,161 @@
1
+ require 'simpleconsole'
2
+ require 'fileutils'
3
+
4
+ module BundleMate #:nodoc:
5
+ class Application < SimpleConsole::Application #:nodoc:
6
+
7
+ def self.run(input)
8
+ super(input, Controller, View)
9
+ end
10
+
11
+ class Controller < SimpleConsole::Controller
12
+ params :string => {:u => :url},
13
+ :int => {:r => :revision},
14
+ :bool => {:y => :noprompt}
15
+
16
+ before_filter :prepare_environment
17
+ before_filter :create_local_repository, :only => [:install]
18
+ after_filter :reload_textmate_bundles, :only => [:install, :uninstall, :update]
19
+
20
+ def default
21
+ render :action => :help
22
+ end
23
+
24
+ def list
25
+ @bundle_list = Bundle.remote_bundle_list
26
+ end
27
+
28
+ def info
29
+ @bundle = Bundle.from_macromates(params[:id])
30
+ @description = @bundle.meta_data('description').sanitize_html
31
+ end
32
+
33
+ def install
34
+ if params[:url]
35
+ @bundle = Bundle.new(params[:url])
36
+ else
37
+ @bundle = Bundle.from_macromates(params[:id])
38
+ end
39
+
40
+ if @bundle.installed?
41
+ puts "\n** #{@bundle.name} bundle is already installed. Use 'update' command instead. **\n\n"
42
+ else
43
+ revision = params[:revision] || 'HEAD'
44
+ puts "\n** Installing #{@bundle.name} (revision: #{revision}) **\n\n"
45
+ @result = @bundle.install(revision)
46
+ end
47
+ end
48
+
49
+ def update
50
+ @bundle = Bundle.from_macromates(params[:id])
51
+ @result = @bundle.update
52
+ end
53
+
54
+ def update_all
55
+ Bundle.installed_bundles.each do |bundle|
56
+ puts "\n** Updating #{bundle.name} bundle. **"
57
+ bundle.update
58
+ end
59
+ end
60
+
61
+ def uninstall
62
+ @bundle = Bundle.from_macromates(params[:id])
63
+ uninstall_method = params[:noprompt] ? :uninstall : :uninstall_with_confirmation
64
+
65
+ unless @bundle.installed?
66
+ @already_uninstalled = true
67
+ else
68
+ @result = @bundle.send(uninstall_method)
69
+ end
70
+ end
71
+
72
+ private
73
+ def prepare_environment
74
+ ENV['LC_CTYPE'] = 'en_US.UTF-8'
75
+ ENV['LC_ALL'] = nil
76
+ end
77
+
78
+ def create_local_repository
79
+ FileUtils.mkdir_p(BundleMate::Bundle.local_bundle_path)
80
+ end
81
+
82
+ def reload_textmate_bundles
83
+ BundleMate.reload_textmate_bundles!
84
+ end
85
+ end
86
+
87
+ class View < SimpleConsole::View
88
+ def list
89
+ puts "\n** AVAILABLE BUNDLES **\n\n"
90
+ @bundle_list.each { |name| puts "- #{name}" }
91
+ puts "\nA total of #{@bundle_list.length} bundles were found."
92
+ end
93
+
94
+ def info
95
+ puts "\n** #{@bundle.name} Bundle **"
96
+ puts "#{@description}\n\n"
97
+ end
98
+
99
+ def install
100
+ if @result
101
+ puts "\n** #{@bundle.name} bundle installed successfully. **"
102
+ else
103
+ puts "\n** AN ERROR OCCURRED INSTALLING #{@bundle.name} BUNDLE **"
104
+ end
105
+ end
106
+
107
+ def update
108
+ if @result
109
+ puts "\n** #{@bundle.name} bundle updated successfully. **"
110
+ else
111
+ puts "\n** AN ERROR OCCURRED UPDATING #{@bundle.name} BUNDLE **"
112
+ end
113
+ end
114
+
115
+ def uninstall
116
+ if @already_uninstalled
117
+ puts "\n** #{@bundle.name} bundle is not installed. **\n\n"
118
+ return
119
+ end
120
+ if @result
121
+ puts "\n** #{@bundle.name} bundle uninstalled successfully. **"
122
+ else
123
+ puts "\n** #{@bundle.name} could not be uninstalled. **"
124
+ end
125
+ end
126
+
127
+ def help
128
+ version = BundleMate::VERSION::STRING
129
+
130
+ puts %(
131
+ Bundlemate Utility #{version}
132
+ ========================
133
+
134
+ Bundlemate is a command utility for managing TextMate bundles.
135
+
136
+ Usage:
137
+ bundlemate command [args] [options]
138
+
139
+ Available commands:
140
+ list # List available bundles in the remote repository.
141
+ info [name] # Display the bundle description.
142
+ install [name] # Install bundle [name]
143
+ update [name] # Download the latest updates for bundle [name]
144
+ uninstall [name] # Remove bundle [name] completely
145
+ update_all # Update all installed bundles
146
+ help # Displays this help text
147
+
148
+ Examples:
149
+ bundlemate install Ruby # install Ruby.tmbundle
150
+ bundlemate update Ruby # download the latest Ruby.rmbundle updates
151
+ bundlemate unisntall Ruby # remove the bundle completely
152
+
153
+ Note:
154
+ It is not necessary to reload TextMate's bundles manually, bundlemate
155
+ will do this automatically when installing/updating/uninstalling a bundle.
156
+ )
157
+ end
158
+ end
159
+
160
+ end
161
+ end
@@ -0,0 +1,87 @@
1
+ require 'plist'
2
+ require 'open-uri'
3
+ require 'fileutils'
4
+
5
+ module BundleMate
6
+
7
+ class Bundle
8
+ attr_reader :name
9
+
10
+ def initialize(bundle_url)
11
+ @url = bundle_url
12
+ @name = File.basename(bundle_url, '.tmbundle')
13
+ end
14
+
15
+ def installed?
16
+ File.exist?(local_path)
17
+ end
18
+
19
+ def meta_data(key)
20
+ (@meta_data ||= remote_plist)[key]
21
+ end
22
+
23
+ def install(revision = 'HEAD')
24
+ system("cd '#{self.class.local_bundle_path}' && svn co -r#{revision} #{remote_url}")
25
+ end
26
+
27
+ def update
28
+ system("cd '#{local_path}' && svn up")
29
+ end
30
+
31
+ def uninstall_with_confirmation
32
+ with_confirmation("About to remove #{local_path}.") do
33
+ uninstall
34
+ end
35
+ end
36
+
37
+ def uninstall
38
+ FileUtils.rm_rf(local_path)
39
+ end
40
+
41
+ class << self
42
+ attr_accessor :local_bundle_path
43
+
44
+ def from_macromates(bundle_name)
45
+ new(File.join(BundleMate::MACROMATES_REPOSITORY, bundle_name + '.tmbundle'))
46
+ end
47
+
48
+ def installed_bundles
49
+ Dir["#{local_bundle_path}/**/*.tmbundle"].map do |bundle_path|
50
+ new(File.basename(bundle_path, '.tmbundle'))
51
+ end
52
+ end
53
+
54
+ def remote_bundle_list(repository = BundleMate::MACROMATES_REPOSITORY)
55
+ `svn ls #{repository}`.split("\n").map do |bundle|
56
+ bundle_name = bundle.match(/(.*)\.tmbundle\/$/)[1]
57
+ end
58
+ end
59
+ end
60
+
61
+ private
62
+ def with_confirmation(confirmation_message, &block)
63
+ puts confirmation_message
64
+ print "Proceed? "
65
+ input = $stdin.gets.strip
66
+ yield if input =~ /^(yes|Yes|y|Y)/
67
+ end
68
+
69
+ def local_path
70
+ File.join(self.class.local_bundle_path, bundle_file_name)
71
+ end
72
+
73
+ def bundle_file_name
74
+ @name + '.tmbundle'
75
+ end
76
+
77
+ def remote_plist
78
+ plist_xml = open(File.join(remote_url, 'info.plist')).read
79
+ Plist.parse_xml(plist_xml)
80
+ end
81
+
82
+ def remote_url
83
+ URI.encode(@url)
84
+ end
85
+ end
86
+
87
+ end
@@ -0,0 +1,211 @@
1
+ require File.join(File.dirname(__FILE__), *%w[spec_helper])
2
+
3
+ module BundleMate
4
+
5
+ describe Application, " when invoking the list command" do
6
+
7
+ before(:each) do
8
+ $stdout = @recorder = StringIO.new
9
+ BundleMate.stubs(:reload_textmate_bundles!)
10
+ end
11
+
12
+ it "should print bundle list to STDOUT" do
13
+ Bundle.stubs(:remote_bundle_list).returns(%w(bundle_one bundle_two))
14
+ BundleMate::Application.run(%w(list))
15
+
16
+ @recorder.rewind
17
+ output = @recorder.read
18
+ output.should match(/bundle_one/)
19
+ output.should match(/bundle_two/)
20
+ end
21
+
22
+ after(:each) do
23
+ $stdout = STDOUT
24
+ end
25
+
26
+ end
27
+
28
+ describe Application, " when invoking the info command" do
29
+
30
+ before(:each) do
31
+ $stdout = @recorder = StringIO.new
32
+ BundleMate.stubs(:reload_textmate_bundles!)
33
+ end
34
+
35
+ it "should download bundle information from repository and display its description" do
36
+ bundle = stub('bundle', :installed? => false, :name => 'Ruby')
37
+ Bundle.stubs(:from_macromates).with('Ruby').returns(bundle)
38
+ bundle.stubs(:meta_data).with('description').returns('My awesome bundle')
39
+ BundleMate::Application.run(%w(info Ruby))
40
+
41
+ @recorder.rewind
42
+ output = @recorder.read
43
+ output.should match(/My awesome bundle/)
44
+ end
45
+
46
+ it "should sanitize bundle of html description before displaying" do
47
+ bundle = stub('bundle', :installed? => false, :name => 'Ruby')
48
+ Bundle.stubs(:from_macromates).with('Ruby').returns(bundle)
49
+ bundle.stubs(:meta_data).with('description').returns(description = 'My <b>awesome</b> bundle')
50
+ BundleMate::Application.run(%w(info Ruby))
51
+
52
+ @recorder.rewind
53
+ output = @recorder.read
54
+ output.should match(/My awesome bundle/)
55
+ end
56
+
57
+ after(:each) do
58
+ $stdout = STDOUT
59
+ end
60
+
61
+ end
62
+
63
+ describe Application, " when invoking the install command" do
64
+
65
+ before(:each) do
66
+ $stdout = @recorder = StringIO.new
67
+ BundleMate.stubs(:reload_textmate_bundles!)
68
+ end
69
+
70
+ it "should install bundle from Macromates repository at HEAD revision" do
71
+ bundle = stub('bundle', :installed? => false, :name => 'Ruby')
72
+ Bundle.stubs(:from_macromates).with('Ruby').returns(bundle)
73
+ bundle.expects(:install).with('HEAD')
74
+ BundleMate::Application.run(%w(install Ruby))
75
+ end
76
+
77
+ it "should print error message and not try and install bundle if bundle is already installed" do
78
+ bundle = stub('bundle', :installed? => true, :name => 'Ruby')
79
+ Bundle.stubs(:from_macromates).with('Ruby').returns(bundle)
80
+ bundle.expects(:install).never
81
+ BundleMate::Application.run(%w(install Ruby))
82
+ @recorder.rewind
83
+ output = @recorder.read
84
+ output.should match(/already installed/)
85
+ end
86
+
87
+ it "should print error message if bundle installation fails" do
88
+ bundle = stub('bundle', :installed? => false, :name => 'Ruby')
89
+ Bundle.stubs(:from_macromates).with('Ruby').returns(bundle)
90
+ bundle.expects(:install).returns(false)
91
+ BundleMate::Application.run(%w(install Ruby))
92
+ @recorder.rewind
93
+ output = @recorder.read
94
+ output.should match(/ERROR OCCURRED INSTALLING/)
95
+ end
96
+
97
+ it "should install bundle from specific URL if specified" do
98
+ bundle = stub('bundle', :installed? => false, :name => 'Ruby')
99
+ Bundle.stubs(:new).with('svn://myrepo.org/Ruby.tmbundle').returns(bundle)
100
+ bundle.expects(:install).with(anything).returns(true)
101
+ BundleMate::Application.run(%w(install --url svn://myrepo.org/Ruby.tmbundle))
102
+ end
103
+
104
+ it "should install bundle at specific revision if specified" do
105
+ bundle = stub('bundle', :installed? => false, :name => 'Ruby')
106
+ Bundle.stubs(:from_macromates).with('Ruby').returns(bundle)
107
+ bundle.expects(:install).with(1234)
108
+ BundleMate::Application.run(%w(install Ruby --revision 1234))
109
+ end
110
+
111
+ after(:each) do
112
+ $stdout = STDOUT
113
+ end
114
+
115
+ end
116
+
117
+ describe Application, " when invoking the update command" do
118
+
119
+ before(:each) do
120
+ $stdout = @recorder = StringIO.new
121
+ BundleMate.stubs(:reload_textmate_bundles!)
122
+ end
123
+
124
+ it "should print bundle list to STDOUT" do
125
+ bundle = stub('bundle', :name => 'Ruby')
126
+ Bundle.stubs(:from_macromates).with('Ruby').returns(bundle)
127
+ bundle.expects(:update).returns(true)
128
+ BundleMate::Application.run(%w(update Ruby))
129
+
130
+ @recorder.rewind
131
+ output = @recorder.read
132
+ output.should match(/updated successfully/)
133
+ end
134
+
135
+ it "should print an error message if update fails" do
136
+ bundle = stub('bundle', :name => 'Ruby')
137
+ Bundle.stubs(:from_macromates).with('Ruby').returns(bundle)
138
+ bundle.expects(:update).returns(false)
139
+ BundleMate::Application.run(%w(update Ruby))
140
+
141
+ @recorder.rewind
142
+ output = @recorder.read
143
+ output.should match(/ERROR OCCURRED UPDATING/)
144
+ end
145
+
146
+ after(:each) do
147
+ $stdout = STDOUT
148
+ end
149
+
150
+ end
151
+
152
+ describe Application, " when invoking the update_all command" do
153
+
154
+ before(:each) do
155
+ $stdout = @recorder = StringIO.new
156
+ BundleMate.stubs(:reload_textmate_bundles!)
157
+ end
158
+
159
+ it "should update all installed bundles" do
160
+ bundle = stub('bundle', :name => 'Ruby')
161
+ Bundle.stubs(:from_macromates).with('Ruby').returns(bundle)
162
+ Bundle.stubs(:installed_bundles).returns([
163
+ b1 = stub_everything('bundle'),
164
+ b2 = stub_everything('bundle'),
165
+ b3 = stub_everything('bundle')
166
+ ])
167
+ [b1, b2, b3].each { |bundle| bundle.expects(:update) }
168
+ BundleMate::Application.run(%w(update_all))
169
+ end
170
+
171
+ after(:each) do
172
+ $stdout = STDOUT
173
+ end
174
+
175
+ end
176
+
177
+ describe Application, " when invoking the uninstall command" do
178
+
179
+ before(:each) do
180
+ $stdout = @recorder = StringIO.new
181
+ BundleMate.stubs(:reload_textmate_bundles!)
182
+ end
183
+
184
+ it "should uninstall the specified bundle with confirmation" do
185
+ bundle = stub('bundle', :name => 'Ruby', :installed? => true)
186
+ Bundle.stubs(:from_macromates).with('Ruby').returns(bundle)
187
+ bundle.expects(:uninstall_with_confirmation).returns(true)
188
+ BundleMate::Application.run(%w(uninstall Ruby))
189
+ end
190
+
191
+ it "should uninstall the specified bundle without confirmation if the -y switch is set" do
192
+ bundle = stub('bundle', :name => 'Ruby', :installed? => true)
193
+ Bundle.stubs(:from_macromates).with('Ruby').returns(bundle)
194
+ bundle.expects(:uninstall).returns(true)
195
+ BundleMate::Application.run(%w(uninstall Ruby -y))
196
+ end
197
+
198
+ it "should display an error if the specified bundle is not installed" do
199
+ bundle = stub('bundle', :name => 'Ruby', :installed? => false)
200
+ Bundle.stubs(:from_macromates).with('Ruby').returns(bundle)
201
+ bundle.expects(:uninstall).never
202
+ BundleMate::Application.run(%w(uninstall Ruby))
203
+ end
204
+
205
+ after(:each) do
206
+ $stdout = STDOUT
207
+ end
208
+
209
+ end
210
+
211
+ end
@@ -0,0 +1,91 @@
1
+ require File.join(File.dirname(__FILE__), *%w[spec_helper])
2
+
3
+ describe "Bundle" do
4
+ before(:all) do
5
+ BundleMate::Bundle.local_bundle_path = '/tmp/bundles'
6
+ end
7
+
8
+ before(:each) do
9
+ @bundle = BundleMate::Bundle.new('http://example.com/bundles/example_bundle.tmbundle')
10
+ end
11
+
12
+ it "should report installed if bundle folder exists" do
13
+ File.stubs(:exist?).with("/tmp/bundles/example_bundle.tmbundle").returns(true)
14
+ @bundle.should be_installed
15
+ end
16
+
17
+ it "should report not installed if bundle folder does not exist" do
18
+ File.stubs(:exist?).with("/tmp/bundles/example_bundle.tmbundle").returns(false)
19
+ @bundle.should_not be_installed
20
+ end
21
+
22
+ it "should return meta data from remote plist file" do
23
+ plist = stub('io', :read => 'plist data')
24
+ @bundle.stubs(:open).with("http://example.com/bundles/example_bundle.tmbundle/info.plist").returns(plist)
25
+ Plist.stubs(:parse_xml).with('plist data').returns({'description' => 'an example bundle'})
26
+ @bundle.meta_data('description').should == 'an example bundle'
27
+ end
28
+ end
29
+
30
+ describe "Bundle", " when installing" do
31
+ before(:all) do
32
+ BundleMate::Bundle.local_bundle_path = '/tmp/bundles'
33
+ end
34
+
35
+ before(:each) do
36
+ @bundle = BundleMate::Bundle.new('http://example.com/bundles/example_bundle.tmbundle')
37
+ end
38
+
39
+ it "should checkout remote bundle at HEAD to local bundle path" do
40
+ @bundle.expects(:system).with("cd '/tmp/bundles' && svn co -rHEAD http://example.com/bundles/example_bundle.tmbundle")
41
+ @bundle.install
42
+ end
43
+
44
+ it "should checkout specific revision if specified" do
45
+ @bundle.expects(:system).with("cd '/tmp/bundles' && svn co -r1234 http://example.com/bundles/example_bundle.tmbundle")
46
+ @bundle.install(1234)
47
+ end
48
+ end
49
+
50
+ describe "Bundle", " when updating" do
51
+ before(:all) do
52
+ BundleMate::Bundle.local_bundle_path = '/tmp/bundles'
53
+ end
54
+
55
+ before(:each) do
56
+ @bundle = BundleMate::Bundle.new('example_bundle')
57
+ end
58
+
59
+ it "should run a subversion update against local path for bundle" do
60
+ @bundle.expects(:system).with("cd '/tmp/bundles/example_bundle.tmbundle' && svn up")
61
+ @bundle.update
62
+ end
63
+ end
64
+
65
+ describe "Bundle", " when uninstalling" do
66
+ before(:all) do
67
+ BundleMate::Bundle.local_bundle_path = '/tmp/bundles'
68
+ end
69
+
70
+ before(:each) do
71
+ @bundle = BundleMate::Bundle.new('example_bundle')
72
+ end
73
+
74
+ it "should delete bundle folder from system" do
75
+ FileUtils.expects(:rm_rf).with('/tmp/bundles/example_bundle.tmbundle')
76
+ @bundle.uninstall
77
+ end
78
+ end
79
+
80
+ describe "Asking for all installed_bundles" do
81
+ it "should return a bundle for each locally installed bundle" do
82
+ Dir.stubs(:[]).with("/tmp/bundles/**/*.tmbundle").returns(%w(
83
+ bundle_one.tmbundle/ bundle_two.tmbundle/ bundle_three.tmbundle/
84
+ ))
85
+ bundles = BundleMate::Bundle.installed_bundles
86
+ bundles.size.should == 3
87
+ bundles[0].name.should == 'bundle_one'
88
+ bundles[1].name.should == 'bundle_two'
89
+ bundles[2].name.should == 'bundle_three'
90
+ end
91
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,6 @@
1
+ require 'spec'
2
+ require File.join(File.dirname(__FILE__), *%w[../lib/bundle_mate])
3
+
4
+ Spec::Runner.configure do |config|
5
+ config.mock_with :mocha
6
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.2
3
+ specification_version: 1
4
+ name: bundlemate
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.1.0
7
+ date: 2007-11-01 00:00:00 +00:00
8
+ summary: A command-line TextMate bundle manager.
9
+ require_paths:
10
+ - lib
11
+ email: contact@lukeredpath.co.uk
12
+ homepage:
13
+ rubyforge_project: ljr
14
+ description: "== FEATURES/PROBLEMS: * List bundles available in the Macromates repository * Install, uninstall and update bundles * Install bundles from third-party repositories * Automatic reloading of TextMate bundles. == SYNOPSIS: Run 'bundlemate help' for instructions. == REQUIREMENTS:"
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Luke Redpath
31
+ files:
32
+ - History.txt
33
+ - License.txt
34
+ - Manifest.txt
35
+ - README.txt
36
+ - Rakefile
37
+ - bin/bundlemate
38
+ - lib/bundle_mate.rb
39
+ - lib/bundle_mate/application.rb
40
+ - lib/bundle_mate/bundle.rb
41
+ - spec/application_spec.rb
42
+ - spec/bundle_spec.rb
43
+ - spec/spec.opts
44
+ - spec/spec_helper.rb
45
+ test_files:
46
+ - spec/application_spec.rb
47
+ - spec/bundle_spec.rb
48
+ rdoc_options:
49
+ - --main
50
+ - README.txt
51
+ extra_rdoc_files:
52
+ - History.txt
53
+ - License.txt
54
+ - Manifest.txt
55
+ - README.txt
56
+ executables:
57
+ - bundlemate
58
+ extensions: []
59
+
60
+ requirements: []
61
+
62
+ dependencies:
63
+ - !ruby/object:Gem::Dependency
64
+ name: plist
65
+ version_requirement:
66
+ version_requirements: !ruby/object:Gem::Version::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 3.0.0
71
+ version:
72
+ - !ruby/object:Gem::Dependency
73
+ name: simpleconsole
74
+ version_requirement:
75
+ version_requirements: !ruby/object:Gem::Version::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 0.1.1
80
+ version:
81
+ - !ruby/object:Gem::Dependency
82
+ name: hoe
83
+ version_requirement:
84
+ version_requirements: !ruby/object:Gem::Version::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: 1.3.0
89
+ version: