tmb 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,133 @@
1
+ module TM
2
+
3
+ class Commands
4
+
5
+ def self.commands
6
+ self.methods - [ Class.methods, "commands", "run"].flatten
7
+ end
8
+
9
+ def self.run(args)
10
+ tm_command = args[0].to_sym
11
+ unless self.respond_to?(tm_command)
12
+ puts "Bad command: #{tm_command}\n\nTMB only understands: #{self.commands.join(', ')}\n\n| Args: #{args.inspect}"
13
+ exit 1
14
+ else
15
+ # puts ["Running TMB", tm_command].join(": ")
16
+ self.send(tm_command, args)
17
+ end
18
+
19
+ end
20
+
21
+ def self.uninstall(args)
22
+ results = TM::Bundle.select(args[1])
23
+ if results.size > 1
24
+ puts "\nYou are trying to uninstall multiple bundles. Select the bundle you wish to remove: \n\n"
25
+ results.each_with_index do |r,i|
26
+ puts "#{(i+1)}) #{r}"
27
+ end
28
+ print "\n\nMake your selection: "
29
+ selection = STDIN.gets.chomp
30
+ result = results[selection.to_i - 1]
31
+
32
+ else
33
+ result = results.first
34
+ end
35
+ puts "\nYou chose #{result}\n\nUninstalling...\n\n"
36
+ removed = TM::Bundle.uninstall(result)
37
+ puts "#{result} uninstalled" if removed
38
+ end
39
+
40
+ def self.list(args=nil)
41
+ TM::Bundle.list
42
+ end
43
+
44
+ def self.search_remote(args)
45
+ searcher = TM::Bundles.new
46
+ search_terms = args[1..-1]
47
+ searcher.search
48
+ search_terms.to_a.each{|term| searcher.search(term) }
49
+ puts "\n" + searcher.search_description(search_terms) + "\n\n" + searcher.display_results + "\n\n"
50
+ end
51
+
52
+ def self.search_local(args)
53
+ explain = <<-eos
54
+
55
+ Searching your local database of textmate bundles.
56
+ To update your listing of bundles do:
57
+
58
+ #{"tmb updatedb".bold}
59
+
60
+ or to search remote listings & update your local listing:
61
+
62
+ #{"tmb search_remote <search terms>".bold}
63
+
64
+
65
+ eos
66
+
67
+
68
+ puts explain
69
+ searcher = TM::Bundles.new
70
+ search_terms = args[1..-1]
71
+ searcher.search_local(search_terms)
72
+ puts "\n" + searcher.search_description(search_terms) + "\n\n" + searcher.display_results + "\n\n"
73
+ end
74
+
75
+ def self.updatedb(args)
76
+ self.search_remote(args)
77
+ end
78
+
79
+ def self.search(args)
80
+ TM::Bundles.searchdb? ? self.search_local(args) : self.search_remote(args)
81
+ end
82
+
83
+ def self.local(args=nil)
84
+ puts File.read(TM::Bundles.searchdb_file)
85
+ end
86
+
87
+ def self.install(args)
88
+ if args[1] =~ /^(https|git):\S*\.git$/
89
+ TM::Bundle.new( {}, :repo => args[1] ).install
90
+ exit 0
91
+ end
92
+ searcher = TM::Bundles.new
93
+ search_terms = args[1..-1]
94
+
95
+ results = searcher.search_local(args[1])
96
+ if results.size == 0
97
+ puts "No matches found"
98
+ elsif results.size == 1
99
+ TM::Bundle.new(results.first).install
100
+ else
101
+ puts "\nYour installation attempt found multiple bundles. Which of the following repositories would you like to install?\n\n"
102
+ bundles = results.map{|r| TM::Bundle.new(r)}.sort{|a,b| b.popularity <=> a.popularity }
103
+ bundles.each_with_index do |b,i|
104
+ puts b.as_selection(i) + (i==0 ? " (default)" : "").bold
105
+ end
106
+ print "\n\nMake your selection (hit enter to choose default #{bundles.first.name.bold}): "
107
+ selection = STDIN.gets.chomp
108
+ selection = 1 if selection.nil? or selection == ""
109
+ result = results[selection.to_i - 1]
110
+ puts "\nYou chose #{selection}: #{result['name']}\n\nInstalling...\n\n"
111
+ bundle = TM::Bundle.new(result)
112
+ bundle.install
113
+ puts "Bundle installed to #{bundle.destination}"
114
+ end
115
+ end
116
+
117
+ def self.reload(args=nil)
118
+ IO.popen("osascript -e 'tell app \"TextMate\" to reload bundles'").read
119
+ end
120
+
121
+ def self.info(args=nil)
122
+ puts TM::Bundle.info
123
+ end
124
+
125
+ def self.help(args=nil)
126
+ puts TM::Help
127
+ end
128
+
129
+ end
130
+
131
+ end
132
+
133
+
data/tmb.gemspec CHANGED
@@ -2,18 +2,18 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{tmb}
5
- s.version = "0.0.5"
5
+ s.version = "0.0.6"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Justin Thibault"]
9
9
  s.cert_chain = ["/Users/jvthibault/.gem/gem-public_cert.pem"]
10
- s.date = %q{2011-03-16}
10
+ s.date = %q{2011-03-28}
11
11
  s.default_executable = %q{tmb}
12
12
  s.description = %q{tmb provides a command line interface to manage your textmate bundles, allowing you to search for new bundles on github, install them, and uninstall existing local bundles.}
13
13
  s.email = %q{jvthibault@gmail.com}
14
14
  s.executables = ["tmb"]
15
- s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README.md", "bin/tmb"]
16
- s.files = ["CHANGELOG", "LICENSE", "Manifest", "README.md", "Rakefile", "bin/tmb", "tmb.gemspec"]
15
+ s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README.md", "bin/tmb", "lib/tmb.rb", "lib/tmb/bundle.rb", "lib/tmb/bundles.rb", "lib/tmb/commands.rb"]
16
+ s.files = ["CHANGELOG", "LICENSE", "README.md", "Rakefile", "bin/tmb", "lib/tmb.rb", "lib/tmb/bundle.rb", "lib/tmb/bundles.rb", "lib/tmb/commands.rb", "Manifest", "tmb.gemspec"]
17
17
  s.homepage = %q{http://tmb.github.com/tmb/}
18
18
  s.post_install_message = %q{
19
19
  tmb is a utility to search for textmate bundles, download and install
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tmb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Justin Thibault
@@ -36,7 +36,7 @@ cert_chain:
36
36
  qKZc+z33GcN0Zg==
37
37
  -----END CERTIFICATE-----
38
38
 
39
- date: 2011-03-16 00:00:00 -07:00
39
+ date: 2011-03-28 00:00:00 -07:00
40
40
  default_executable:
41
41
  dependencies: []
42
42
 
@@ -51,13 +51,21 @@ extra_rdoc_files:
51
51
  - LICENSE
52
52
  - README.md
53
53
  - bin/tmb
54
+ - lib/tmb.rb
55
+ - lib/tmb/bundle.rb
56
+ - lib/tmb/bundles.rb
57
+ - lib/tmb/commands.rb
54
58
  files:
55
59
  - CHANGELOG
56
60
  - LICENSE
57
- - Manifest
58
61
  - README.md
59
62
  - Rakefile
60
63
  - bin/tmb
64
+ - lib/tmb.rb
65
+ - lib/tmb/bundle.rb
66
+ - lib/tmb/bundles.rb
67
+ - lib/tmb/commands.rb
68
+ - Manifest
61
69
  - tmb.gemspec
62
70
  has_rdoc: true
63
71
  homepage: http://tmb.github.com/tmb/
metadata.gz.sig CHANGED
Binary file