gub 0.0.14

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f404a3e769c6040f96d2d43c64b82f7e180f6b02
4
+ data.tar.gz: 3340417a13ba2a93d51ae60e19531fc1ceb8f4ae
5
+ SHA512:
6
+ metadata.gz: b92068f3633107ff5751b36962cba0edac2231e5b275840051581731419788471053a34485c61d55346043814af83d2ad9eff821ec9e51c91cb15140c0272eae
7
+ data.tar.gz: 134f1fa532b2aea43ab9fd286b570990a30733dc059953df9d950c5accf2fd28a9f8f9103f6b4d7a1358c3cd42841c2e67814f59781776f9bc1ee1551988551e
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gub.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Omar Abdel-Wahab
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Gub
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'gub'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install gub
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/gub ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:<< File.expand_path("~/Projects/gub/lib/")
4
+
5
+ require 'rubygems'
6
+ require 'gub'
7
+
8
+ # Start our command line interface
9
+ Gub.start
data/gub.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gub/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gub"
8
+ spec.version = Gub::VERSION
9
+ spec.authors = ["Omar Abdel-Wahab"]
10
+ spec.email = ["owahab@gmail.com"]
11
+ spec.description = %q{Warning: Heavily Under Development, Still in early alpha}
12
+ spec.summary = %q{The missing command line tool for Github}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.3'
22
+ spec.add_development_dependency 'rake'
23
+ spec.add_development_dependency 'debugger'
24
+
25
+ spec.add_dependency 'thor'
26
+ spec.add_dependency 'octokit'
27
+ spec.add_dependency 'terminal-table'
28
+ end
data/lib/gub/cache.rb ADDED
@@ -0,0 +1,21 @@
1
+ module Gub
2
+ class Cache
3
+ def initialize base_dir
4
+ @base_dir = base_dir
5
+ end
6
+
7
+ def set key, value
8
+ cached_path = @base_dir + '/' + key
9
+ File.open(cached_path, 'w') do |f|
10
+ f.puts value
11
+ end
12
+ end
13
+
14
+ def get key
15
+ cached_path = @base_dir + '/' + key
16
+ if File.exists? cached_path
17
+ return IO.read cached_path
18
+ end
19
+ end
20
+ end
21
+ end
data/lib/gub/cli.rb ADDED
@@ -0,0 +1,152 @@
1
+ require 'gub/version'
2
+ require 'thor'
3
+ require 'terminal-table'
4
+
5
+ module Gub
6
+ class CLI < Thor
7
+ default_task :info
8
+
9
+ desc 'publish', 'Publish a local repo to Github'
10
+ def publish
11
+ setup
12
+ end
13
+
14
+ desc 'repos', 'List Github repositories'
15
+ def repos
16
+ setup
17
+ rows = []
18
+ id = 0
19
+ Gub.github.repos.list.each do |repo|
20
+ id = id.next
21
+ rows << [id, repo.full_name]
22
+ end
23
+ Gub.github.orgs.list.each do |org|
24
+ Gub.github.repos.list(org: org.login).each do |repo|
25
+ id = id.next
26
+ rows << [id, repo.full_name]
27
+ end
28
+ end
29
+ puts table rows, ['#', 'Repository']
30
+ end
31
+
32
+ desc 'issues', 'List Github issues'
33
+ method_options all: :boolean, default: false
34
+ def issues
35
+ setup
36
+ if options.all || repo_full_name.nil?
37
+ puts "Listing all issues:"
38
+ issues = Gub.github.issues
39
+ else
40
+ params = {}
41
+ if parent
42
+ params[:repo] = parent
43
+ else
44
+ params[:repo] = repo_full_name
45
+ end
46
+ puts "Listing issues for #{params[:repo]}:"
47
+ issues = Gub.github.issues params
48
+ end
49
+ unless issues.nil?
50
+ rows = []
51
+ issues.each do |issue|
52
+ row = []
53
+ row << issue.number
54
+ row << issue.title
55
+ row << issue.user.login
56
+ row << (issue.assignee.nil? ? '' : issue.assignee.login)
57
+ rows << row
58
+ end
59
+ puts table rows, ['ID', 'Title', 'Author', 'Assignee']
60
+ puts "Found #{issues.count} issue(s)."
61
+ puts 'Hint: use "gub start" to start working on an issue.'
62
+ end
63
+ # rescue Octokit::ClientError
64
+ # puts 'Issues are disabled for this repository.'
65
+ end
66
+
67
+ desc 'start', 'Start working on a Github issue'
68
+ def start id
69
+ if id.nil?
70
+ puts 'Issue ID required.'
71
+ else
72
+ # Fetch issue to validate it exists
73
+ issue = Gub.github.issue(repo, id)
74
+ Gub.github.update_issue repo, issue.number, issue.title, issue.description, { assignee: Gub.github.user.login }
75
+ sync
76
+ `git checkout -b issue-#{id}`
77
+ end
78
+ end
79
+
80
+ desc 'finish', 'Finish working on a Github issue'
81
+ def finish id = nil
82
+ setup
83
+ id ||= `git rev-parse --abbrev-ref HEAD`.split('-').last.to_s.chop
84
+ if id.nil?
85
+ puts "Unable to guess issue ID from branch name. You might want to specify it explicitly."
86
+ else
87
+ issue = Gub.github.issue(repo, id)
88
+ puts 'Pushing branch...'
89
+ `git push -q origin issue-#{id}`
90
+ puts "Creating pull-request for issue ##{id}..."
91
+ Gub.github.create_pull_request_for_issue(repo, 'master', "#{user_name}:issue-#{id}", id)
92
+ `git checkout master`
93
+ end
94
+ end
95
+
96
+ desc 'clone', 'Clone a Github repository'
97
+ def clone repo
98
+ `git clone git@github.com:#{repo}`
99
+ end
100
+
101
+ desc 'sync', 'Synchronize fork with upstream repository'
102
+ def sync
103
+ puts 'Synchroizing with upstream...'
104
+ `git checkout master`
105
+ `git fetch -q upstream`
106
+ `git merge -q upstream/master`
107
+ end
108
+
109
+ desc 'info', 'Show current respository information'
110
+ def info
111
+ repo = Gub::Repository.new
112
+ puts "Github repository: #{repo.full_name}"
113
+ puts "Forked from: #{repo.parent}" if repo.parent
114
+ end
115
+
116
+ desc 'version', 'Show Gub version'
117
+ def version
118
+ puts Gub::VERSION
119
+ end
120
+
121
+
122
+ private
123
+ def setup
124
+ end
125
+
126
+ def table rows, header = []
127
+ Terminal::Table.new :headings => header, :rows => rows
128
+ end
129
+
130
+ def run command, params = {}
131
+ end
132
+
133
+ def repo
134
+ if parent
135
+ name = parent
136
+ else
137
+ name = repo_full_name
138
+ end
139
+ name
140
+ end
141
+ def repo_full_name
142
+ `git remote -v | grep origin | grep fetch | awk '{print $2}' | cut -d ':' -f 2`.to_s.chop
143
+ end
144
+ def repo_name
145
+ repo_full_name.split('/').last
146
+ end
147
+ def user_name
148
+ repo_full_name.split('/').first
149
+ end
150
+
151
+ end
152
+ end
@@ -0,0 +1,4 @@
1
+ module Gub
2
+ class Git
3
+ end
4
+ end
@@ -0,0 +1,9 @@
1
+ require 'octokit'
2
+
3
+ module Gub
4
+ class Github
5
+ def initialize token
6
+ Octokit::Client.new(access_token: token)
7
+ end
8
+ end
9
+ end
data/lib/gub/config.rb ADDED
@@ -0,0 +1,6 @@
1
+ module Gub
2
+ class Config
3
+ def initialize
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+ class Hash
2
+ def symbolize_keys!
3
+ keys.each do |key|
4
+ self[(key.to_sym rescue key) || key] = delete(key)
5
+ end
6
+ self
7
+ end
8
+ end
@@ -0,0 +1,33 @@
1
+ module Gub
2
+ class Repository
3
+ attr_accessor :full_name, :github
4
+
5
+ def initialize full_name = nil
6
+ if full_name.nil?
7
+ @full_name = `git remote -v | grep origin | grep fetch | awk '{print $2}' | cut -d ':' -f 2`.to_s.chop
8
+ else
9
+ @full_name = full_name
10
+ end
11
+ if @full_name.nil?
12
+ puts 'Unable to find repo name'
13
+ else
14
+ @github = Gub.github.repo(repo: @full_name)
15
+ end
16
+ end
17
+
18
+ def issues
19
+ Gub.github.issues
20
+ end
21
+
22
+ def owner
23
+ @full_name.split('/').first
24
+ end
25
+
26
+ def is_fork?
27
+ end
28
+
29
+ def parent
30
+ @github.parent.full_name if @github.parent
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ module Gub
2
+ VERSION = "0.0.14"
3
+ end
data/lib/gub.rb ADDED
@@ -0,0 +1,33 @@
1
+ require 'yaml'
2
+
3
+ require 'gub/extensions'
4
+ require 'gub/version'
5
+ require 'gub/clients/git'
6
+ require 'gub/clients/github'
7
+ require 'gub/repository'
8
+ require 'gub/cli'
9
+
10
+ module Gub
11
+ def self.config
12
+ @@config
13
+ end
14
+
15
+ def self.config=
16
+ @@config
17
+ end
18
+
19
+ def self.start
20
+ rc = File.expand_path("~/.gubrc")
21
+ if File.exists?(rc)
22
+ @@config = YAML.load_file(rc).symbolize_keys!
23
+ end
24
+ # @@git = Gub::Git.new
25
+ Gub::CLI.start
26
+ end
27
+
28
+ def self.github
29
+ Gub::Github.new(@@config['token'])
30
+ end
31
+
32
+
33
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gub
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.14
5
+ platform: ruby
6
+ authors:
7
+ - Omar Abdel-Wahab
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: debugger
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: thor
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: octokit
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: terminal-table
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: 'Warning: Heavily Under Development, Still in early alpha'
98
+ email:
99
+ - owahab@gmail.com
100
+ executables:
101
+ - gub
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - .gitignore
106
+ - Gemfile
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - bin/gub
111
+ - gub.gemspec
112
+ - lib/gub.rb
113
+ - lib/gub/cache.rb
114
+ - lib/gub/cli.rb
115
+ - lib/gub/clients/git.rb
116
+ - lib/gub/clients/github.rb
117
+ - lib/gub/config.rb
118
+ - lib/gub/extensions.rb
119
+ - lib/gub/repository.rb
120
+ - lib/gub/version.rb
121
+ homepage: ''
122
+ licenses:
123
+ - MIT
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 2.0.3
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: The missing command line tool for Github
145
+ test_files: []
146
+ has_rdoc: