ghs 0.1.1

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 (5) hide show
  1. data/README.markdown +37 -0
  2. data/Rakefile +2 -0
  3. data/bin/ghs +59 -0
  4. data/ghs.gemspec +24 -0
  5. metadata +76 -0
data/README.markdown ADDED
@@ -0,0 +1,37 @@
1
+ Github Repo Search (ghs)
2
+ ========================
3
+
4
+ A script for the truly lazy github devs, ghs quickly finds clone urls for repositories.
5
+
6
+ Cloning the rails repo, the old way:
7
+
8
+ 1. Open a browser
9
+ 2. Google "Rails github"
10
+ 3. Go to the Rails github page
11
+ 4. Copy the url
12
+ 5. Open a terminal
13
+ 6. Paste in the url
14
+
15
+ Vs. the new way, using ghs:
16
+ $ git clone `ghs -b rails`
17
+
18
+
19
+ Getting ghs
20
+ -----------
21
+
22
+ $ gem install ghs
23
+
24
+
25
+ Usage
26
+ -----
27
+
28
+ Get a repo's clone url:
29
+
30
+ $ ghs [repo name]
31
+
32
+ If there are multiple matches, ghs will stop by default.
33
+ To choose the best match, use either of these:
34
+
35
+ $ ghs -b [reponame]
36
+ $ ghs --best [reponame]
37
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'rake'
2
+ require 'rake/clean'
data/bin/ghs ADDED
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env ruby -wKU
2
+ require "yaml"
3
+ require "pp"
4
+ require 'optparse'
5
+ require 'open-uri'
6
+
7
+ # Command line options
8
+ app = Hash.new
9
+ options = OptionParser.new do |opts|
10
+ opts.on("-b", "--best", "If multiple repos are found, choose the best one.") do |opt|
11
+ app['best'] = opt
12
+ end
13
+ end
14
+
15
+ begin
16
+ options.parse!(ARGV)
17
+ rescue OptionParser::ParseError => e
18
+ STDERR.puts "#{$0}: #{e}"
19
+ end
20
+
21
+ if ARGV.length < 1
22
+ STDERR.puts "#{$0}: You need to specify a repo to search for."
23
+ raise SystemExit
24
+ end
25
+
26
+ repo = ARGV[0]
27
+
28
+ # STEP 1: Search for the correct repo
29
+ search = open("http://github.com/api/v2/yaml/repos/search/#{repo}").read
30
+ results = YAML.load(search) # y is now a hash containing the yaml data.
31
+
32
+ if results["repositories"].length > 1 && !app['best']
33
+ STDERR.puts "#{$0}: Multiple repos found, not sure which one you wanted.\nTo let me make the choice, rerun with the --best flag."
34
+ raise SystemExit
35
+ end
36
+
37
+ repo_name = results["repositories"][0]["name"]
38
+ username = results["repositories"][0]["username"]
39
+
40
+ # STEP 2: Get the correct url
41
+ show = open("http://github.com/api/v2/yaml/repos/show/#{username}/#{repo_name}").read
42
+ repo_info = YAML.load(show) # y is now a hash containing the yaml data.
43
+ url = repo_info["repository"][:url]
44
+
45
+ if !url
46
+ STDERR.puts "#{$0}: Couldn't find the url."
47
+ raise SystemExit
48
+ end
49
+
50
+ STDERR.puts "
51
+ ==
52
+
53
+ Matched repository: #{repo_name}
54
+ Description: #{repo_info["repository"][:description]}
55
+
56
+ ==
57
+ "
58
+
59
+ puts "#{url}.git"
data/ghs.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{ghs}
5
+ s.version = "0.1.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Aditya Bhargava"]
9
+ s.date = %q{2010-09-30}
10
+ s.description = %q{Find the clone url for repos on Github}
11
+ s.email = %q{aditya@wefoundland.com}
12
+ s.extra_rdoc_files = ["README.markdown"]
13
+ s.files = ["README.markdown", "Rakefile", "bin/ghs", "ghs.gemspec"]
14
+ s.executables = ["ghs"]
15
+ s.homepage = %q{http://github.com/egonSchiele/Github-Repo-Search}
16
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Ghs", "--main", "README.markdown"]
17
+ s.rubyforge_project = %q{ghs}
18
+ s.rubygems_version = %q{1.3.1}
19
+ s.summary = %q{Find the clone url for repos on Github}
20
+
21
+ if s.respond_to? :specification_version then
22
+ s.specification_version = 2
23
+ end
24
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ghs
3
+ version: !ruby/object:Gem::Version
4
+ hash: 25
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 1
10
+ version: 0.1.1
11
+ platform: ruby
12
+ authors:
13
+ - Aditya Bhargava
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-09-30 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Find the clone url for repos on Github
23
+ email: aditya@wefoundland.com
24
+ executables:
25
+ - ghs
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - README.markdown
30
+ files:
31
+ - README.markdown
32
+ - Rakefile
33
+ - bin/ghs
34
+ - ghs.gemspec
35
+ has_rdoc: true
36
+ homepage: http://github.com/egonSchiele/Github-Repo-Search
37
+ licenses: []
38
+
39
+ post_install_message:
40
+ rdoc_options:
41
+ - --line-numbers
42
+ - --inline-source
43
+ - --title
44
+ - Ghs
45
+ - --main
46
+ - README.markdown
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ hash: 3
55
+ segments:
56
+ - 0
57
+ version: "0"
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ hash: 11
64
+ segments:
65
+ - 1
66
+ - 2
67
+ version: "1.2"
68
+ requirements: []
69
+
70
+ rubyforge_project: ghs
71
+ rubygems_version: 1.3.7
72
+ signing_key:
73
+ specification_version: 2
74
+ summary: Find the clone url for repos on Github
75
+ test_files: []
76
+