cypher-textmate 0.9.2 → 0.9.3

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.
Files changed (3) hide show
  1. data/Rakefile +1 -1
  2. data/bin/textmate +47 -4
  3. metadata +2 -2
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'rake/gempackagetask'
3
3
  require 'date'
4
4
 
5
5
  GEM = "textmate"
6
- GEM_VERSION = "0.9.2"
6
+ GEM_VERSION = "0.9.3"
7
7
  AUTHOR = "Yehuda Katz"
8
8
  EMAIL = "wycats@gmail.com"
9
9
  HOMEPAGE = "http://yehudakatz.com"
data/bin/textmate CHANGED
@@ -22,7 +22,13 @@ class TextmateInstaller < Thor
22
22
  when :git
23
23
  'git remotes not implemented yet'
24
24
  when :github
25
- find_github_bundles(search_term).map{|result| normalize_github_repo_name(result['name']).split('.').first}
25
+ find_github_bundles(search_term).map {|result|
26
+ "%s (by %s)" %
27
+ [
28
+ normalize_github_repo_name(result['name']).split('.').first,
29
+ result['url'][/github\.com\/([a-zA-Z0-9]+)\//, 1] # Extract the username out of the repo URL
30
+ ]
31
+ }
26
32
  end
27
33
 
28
34
  puts results
@@ -56,8 +62,35 @@ class TextmateInstaller < Thor
56
62
  when :svn
57
63
  %[svn co #{e_sh location[:url]}/#{e_sh bundle_name}.tmbundle #{e_sh install_bundles_path}/#{e_sh bundle_name}.tmbundle 2>&1]
58
64
  when :github
59
- repo = find_github_bundles(denormalize_github_repo_name(bundle_name)).first
60
- %[git clone #{e_sh repo['url'].sub('http', 'git') + '.git'} #{e_sh install_bundles_path}/#{e_sh bundle_name}.tmbundle 2>&1]
65
+ repos = find_github_bundles(denormalize_github_repo_name(bundle_name))
66
+
67
+ # Handle possible multiple Repos with the same name
68
+ case repos.size
69
+ when 0
70
+ 'echo "Sorry, no such bundle found"'
71
+ when 1
72
+ %[git clone #{e_sh repos.first['url'].sub('http', 'git') + '.git'} #{e_sh install_bundles_path}/#{e_sh bundle_name}.tmbundle 2>&1]
73
+ else
74
+ puts "Multiple bundles with that name found. Please choose which one you want to install:"
75
+ repos.each_with_index {|repo, idx|
76
+ puts "%d: %s by %s" %
77
+ [
78
+ idx + 1,
79
+ normalize_github_repo_name(repo['name']),
80
+ repo['url'][/github\.com\/([a-zA-Z0-9]+)\//, 1]
81
+ ]
82
+ }
83
+ print "Your choice: "
84
+
85
+ # Since to_i defaults to 0, we have to use Integer
86
+ choice = Integer(STDIN.gets.chomp) rescue nil
87
+ until choice && (0...repos.size).include?( choice - 1 ) do
88
+ print "Sorry, invalid choice. Please enter a valid number or Ctrl+C to stop: "
89
+ choice = Integer(STDIN.gets.chomp) rescue nil
90
+ end
91
+
92
+ %[git clone #{e_sh repos[choice - 1]['url'].sub('http', 'git') + '.git'} #{e_sh install_bundles_path}/#{e_sh bundle_name}.tmbundle 2>&1]
93
+ end
61
94
  end
62
95
 
63
96
  res = %x{#{cmd}}
@@ -141,7 +174,17 @@ class TextmateInstaller < Thor
141
174
  end
142
175
 
143
176
  def find_github_bundles(search_term)
144
- YAML.load(open('http://github.com/api/v1/yaml/search/tmbundle'))['repositories'].find_all{|result| result['name'].match(search_term)}
177
+ # Until GitHub fixes http://support.github.com/discussions/feature-requests/11-api-search-results,
178
+ # we need to account for multiple pages of results:
179
+ page = 1
180
+ repositories = YAML.load(open("http://github.com/api/v1/yaml/search/tmbundle?page=#{page}"))['repositories']
181
+ results = []
182
+ until repositories.empty?
183
+ results += repositories.find_all{|result| result['name'].match(search_term)}
184
+ page += 1
185
+ repositories = YAML.load(open("http://github.com/api/v1/yaml/search/tmbundle?page=#{page}"))['repositories']
186
+ end
187
+ results.sort{|a,b| a['name'] <=> b['name']}
145
188
  end
146
189
 
147
190
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cypher-textmate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yehuda Katz
@@ -57,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
57
  requirements: []
58
58
 
59
59
  rubyforge_project:
60
- rubygems_version: 1.0.1
60
+ rubygems_version: 1.2.0
61
61
  signing_key:
62
62
  specification_version: 2
63
63
  summary: Command-line textmate package manager