githublaunch 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.
data/.gitignore ADDED
@@ -0,0 +1,44 @@
1
+ !.gitignore
2
+ *.gem
3
+ *.rbc
4
+ *.sw[a-p]
5
+ *.tmproj
6
+ *.tmproject
7
+ *.un~
8
+ *~
9
+ .Spotlight-V100
10
+ .Trashes
11
+ ._*
12
+ .bundle
13
+ .config
14
+ .directory
15
+ .elc
16
+ .emacs.desktop
17
+ .emacs.desktop.lock
18
+ .idea
19
+ .redcar
20
+ .rvmrc
21
+ .yardoc
22
+ Desktop.ini
23
+ Gemfile.lock
24
+ Icon?
25
+ InstalledFiles
26
+ Session.vim
27
+ \#*\#
28
+ _yardoc
29
+ auto-save-list
30
+ coverage
31
+ doc/
32
+ lib/bundler/man
33
+ pkg
34
+ pkg/*
35
+ rdoc
36
+ spec/reports
37
+ spec/sandbox
38
+ test/tmp
39
+ test/version_tmp
40
+ tmp
41
+ tmtags
42
+ tramp
43
+ .rbx
44
+ b/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+ gem 'grit'
3
+ gem 'thor'
data/bin/ghl ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path('../../lib/githublaunch', __FILE__)
4
+
5
+ GithubLaunch.start
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/githublaunch/version', __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "githublaunch"
6
+ s.authors = ['Logan Linn']
7
+ s.description = %q{A CLI command for launching Github URLs}
8
+ s.summary = s.description
9
+ s.email = 'logan@loganlinn.com'
10
+ s.homepage = "https://github.com/loganlinn/githublaunch"
11
+ s.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
12
+ s.files = `git ls-files`.split("\n")
13
+ s.require_paths = ['lib']
14
+ s.version = GithubLaunch::VERSION
15
+
16
+ s.add_dependency 'thor'
17
+ s.add_dependency 'grit'
18
+ end
@@ -0,0 +1,3 @@
1
+ class GithubLaunch
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,77 @@
1
+ require 'thor'
2
+ require 'pathname'
3
+ require 'grit'
4
+
5
+ class GithubLaunch < Thor
6
+
7
+ desc "network", "Open network view"
8
+ def network; launch "/network"; end
9
+
10
+ desc "branches", "Open branches view"
11
+ def branches; launch "/branches"; end
12
+
13
+ desc "pulls", "Open pull request view"
14
+ def pulls; launch "/pulls"; end
15
+
16
+ desc "branch BRANCH", "Open Files view for branch (defaults to current branch)"
17
+ def branch(b=nil)
18
+ launch "/tree/#{b || repo.head.name}"
19
+ end
20
+
21
+ desc "commits BRANCH", "Open Commits view for branch (defaults to current branch)"
22
+ def commits(b=nil)
23
+ launch "/commits/#{b || repo.head.name}"
24
+ end
25
+
26
+ desc "compare BASE HEAD", "Open compare page between two branches (defaults to current branch)"
27
+ def compare(base, head=nil)
28
+ if head.nil?
29
+ head = base
30
+ base = repo.head.name
31
+ end
32
+
33
+ launch "/compare/#{base}...#{head}"
34
+ end
35
+
36
+ desc "show COMMIT", "Open a commit (defaults to last commit on current branch)"
37
+ def show(sha=nil)
38
+ launch "/commit/#{sha || repo.head.commit.sha}"
39
+ end
40
+
41
+ desc "pull BASE HEAD", "Open page to create pull request (head defaults to current branch)"
42
+ def pull(base, head=nil)
43
+ launch "/pull/new/#{base}...#{head || repo.head.name}"
44
+ end
45
+
46
+ private
47
+
48
+ def repo
49
+ @repo ||= Grit::Repo.new(repo_path)
50
+ end
51
+
52
+ # Finds closest git repository
53
+ def repo_path
54
+ @repo_path ||= Pathname.new(Dir.pwd).descend { |p| break p if (p + '.git').directory? }
55
+ end
56
+
57
+ # Launch (or prints) the URL
58
+ # Ending action for most commands
59
+ def launch(path)
60
+ # force leading slash
61
+ path.insert(0, '/') unless path[0] == '/'
62
+ url = "https://github.com/#{repo_github_path + path.chomp}"
63
+ # use open if on OSX
64
+ if RUBY_PLATFORM.downcase.include? "darwin"
65
+ %x{open #{url}}
66
+ else
67
+ puts url
68
+ end
69
+ end
70
+
71
+ # <username>/<repo> for repository in pwd
72
+ def repo_github_path
73
+ descrip = %x{git remote -v}.match(/^.+git@github\.com:(.+\/.+)\.git/)
74
+ raise "Could not find a Github remote" if descrip.nil?
75
+ descrip[1]
76
+ end
77
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: githublaunch
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Logan Linn
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: grit
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: A CLI command for launching Github URLs
47
+ email: logan@loganlinn.com
48
+ executables:
49
+ - ghl
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - bin/ghl
56
+ - githublaunch.gemspec
57
+ - lib/githublaunch.rb
58
+ - lib/githublaunch/version.rb
59
+ homepage: https://github.com/loganlinn/githublaunch
60
+ licenses: []
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 1.8.24
80
+ signing_key:
81
+ specification_version: 3
82
+ summary: A CLI command for launching Github URLs
83
+ test_files: []