octocat 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 54fc7f33727fafa07c586f9aaabf86e73d8537eb
4
+ data.tar.gz: 4a60a1e3be2c8c332a693f03145447dfd9574b8a
5
+ SHA512:
6
+ metadata.gz: 49b16d024abcf163fdde06d07bb0ed52000196d217de0118a7d5f7e66a16815a777c3ed12c7ddab84e796e16e8ed05f903ed9a2eeb9f3310b0a8ee833b4f536c
7
+ data.tar.gz: 88f63451cffd37bc01ee4b221f9f2dd9529c630bef1cd8566b133394ac576e4bb618ca2cf1ce0281e90b2d77fae5aa7033020847cb22f6d6cb453bc83dea4344
@@ -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 octocat.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 halogenandtoast
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.
@@ -0,0 +1,29 @@
1
+ # Octocat
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'octocat'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install octocat
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 CHANGED
@@ -1,29 +1,6 @@
1
- require "rubygems"
2
- require "rubygems/package_task"
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
3
 
4
- spec = Gem::Specification.new do |s|
4
+ RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- # Change these as appropriate
7
- s.name = "octocat"
8
- s.version = "0.0.0"
9
- s.summary = "Sane Github v3 api"
10
- s.author = "halogenandtoast"
11
- s.email = "halogenandtoast@gmail.com"
12
- s.homepage = "http://github.com/halogenandtoast/octocat"
13
- s.has_rdoc = false
14
- s.files = %w(Rakefile) + Dir.glob("lib/**/*")
15
- s.require_paths = ["lib"]
16
- s.required_rubygems_version = Gem::Requirement.new(">= 1.3")
17
- end
18
-
19
- Gem::PackageTask.new(spec) do |pkg|
20
- pkg.gem_spec = spec
21
- end
22
-
23
- desc "Build the gemspec file #{spec.name}.gemspec"
24
- task :gemspec do
25
- file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
26
- File.open(file, "w") {|f| f << spec.to_ruby }
27
- end
28
-
29
- task :package => :gemspec
6
+ task :default => :spec
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+
4
+ require 'octocat'
5
+
6
+ cli = Octocat::CommandLine.new(ARGV)
7
+ cli.run
@@ -0,0 +1,7 @@
1
+ require "octocat/version"
2
+ require "octocat/command_line"
3
+ require "octocat/api"
4
+
5
+ module Octocat
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,63 @@
1
+ require 'json'
2
+ require 'open-uri'
3
+
4
+ module Octocat
5
+ class API
6
+ API_ROOT_URL = 'https://api.github.com/'
7
+
8
+ def pull_requests(project)
9
+ password = `/usr/bin/security find-internet-password -g -a halogenandtoast -s github.com -w`.chomp
10
+ connection = open("#{API_ROOT_URL}repos/#{project}/pulls", http_basic_authentication: ["halogenandtoast", password])
11
+ JSON.parse(connection.read)
12
+ end
13
+
14
+ def new_pr(project, current_branch)
15
+ `open #{pr_url_for(project, current_branch)}`
16
+ end
17
+
18
+ def open_pr(project, current_branch)
19
+ `open #{pull_request_url_for_branch(project, current_branch)}`
20
+ end
21
+
22
+ def open_branch(project, current_branch)
23
+ `open #{branch_url_for(project, current_branch)}`
24
+ end
25
+
26
+ def compare_branch(project, current_branch)
27
+ `open #{compare_url_for_branch(project, current_branch)}`
28
+ end
29
+
30
+ private
31
+
32
+ def pull_request_url_for_branch(project, branch)
33
+ current_pull_requests = pull_requests(project)
34
+ pull_request = current_pull_requests.detect { |pr| pr["head"]["ref"] == branch }
35
+ if pull_request
36
+ pull_request["html_url"]
37
+ else
38
+ print "No pull request for #{branch}. Create one now? [Y/n]"
39
+ response = $stdin.gets.chomp
40
+ unless response.downcase == "n"
41
+ new_pr(project, branch)
42
+ end
43
+ end
44
+ end
45
+
46
+ def base_url
47
+ "https://github.com"
48
+ end
49
+
50
+ def pr_url_for(project, branch)
51
+ "#{base_url}/#{project}/pull/new/#{branch}"
52
+ end
53
+
54
+ def branch_url_for(project, branch)
55
+ "#{base_url}/#{project}/tree/#{branch}"
56
+ end
57
+
58
+
59
+ def compare_url_for_branch(project, branch)
60
+ "#{base_url}/#{project}/compare/master...#{branch}"
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,44 @@
1
+ module Octocat
2
+ class CommandLine
3
+ COMMANDS = %w(open-branch new-pr open-pr compare-branch help)
4
+
5
+ def initialize arguments
6
+ @command = arguments.first
7
+ @api = API.new
8
+ end
9
+
10
+ def run
11
+ git_url = `git remote show -n origin | grep 'URL' | head -1`.chomp.split(": ", 2).last
12
+ project = git_url.split(":", 2).last.gsub(/\.git$/, "")
13
+ if @command == "open-branch"
14
+ api.open_branch(project, current_branch)
15
+ elsif @command == "new-pr"
16
+ api.new_pr(project, current_branch)
17
+ elsif @command == "open-pr"
18
+ api.open_pr(project, current_branch)
19
+ elsif @command == "compare-branch"
20
+ api.compare_branch(project, current_branch)
21
+ elsif @command == "help"
22
+ help
23
+ else
24
+ puts "Unknown Command. The known commands are:"
25
+ help
26
+ end
27
+ end
28
+
29
+ def help
30
+ COMMANDS.each do |command|
31
+ puts "- #{command}"
32
+ end
33
+ puts
34
+ end
35
+
36
+ def current_branch
37
+ `git rev-parse --abbrev-ref HEAD`.chomp
38
+ end
39
+
40
+ private
41
+
42
+ attr_reader :api
43
+ end
44
+ end
@@ -0,0 +1,3 @@
1
+ module Octocat
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'octocat/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "octocat"
8
+ spec.version = Octocat::VERSION
9
+ spec.authors = ["halogenandtoast"]
10
+ spec.email = ["halogenandtoast@gmail.com"]
11
+ spec.description = %q{Command line github}
12
+ spec.summary = %q{Make interactions between your local repository and github seemless and awesome.}
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_dependency "json"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec"
26
+ end
metadata CHANGED
@@ -1,68 +1,112 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: octocat
3
- version: !ruby/object:Gem::Version
4
- hash: 31
5
- prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 0
10
- version: 0.0.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - halogenandtoast
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2011-11-04 00:00:00 -04:00
19
- default_executable:
20
- dependencies: []
21
-
22
- description:
23
- email: halogenandtoast@gmail.com
24
- executables: []
25
-
11
+ date: 2014-03-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
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: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Command line github
70
+ email:
71
+ - halogenandtoast@gmail.com
72
+ executables:
73
+ - octocat
26
74
  extensions: []
27
-
28
75
  extra_rdoc_files: []
29
-
30
- files:
76
+ files:
77
+ - ".gitignore"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
31
81
  - Rakefile
32
- has_rdoc: true
33
- homepage: http://github.com/halogenandtoast/octocat
34
- licenses: []
35
-
82
+ - bin/octocat
83
+ - lib/octocat.rb
84
+ - lib/octocat/api.rb
85
+ - lib/octocat/command_line.rb
86
+ - lib/octocat/version.rb
87
+ - octocat.gemspec
88
+ homepage: ''
89
+ licenses:
90
+ - MIT
91
+ metadata: {}
36
92
  post_install_message:
37
93
  rdoc_options: []
38
-
39
- require_paths:
94
+ require_paths:
40
95
  - lib
41
- required_ruby_version: !ruby/object:Gem::Requirement
42
- none: false
43
- requirements:
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
44
98
  - - ">="
45
- - !ruby/object:Gem::Version
46
- hash: 3
47
- segments:
48
- - 0
49
- version: "0"
50
- required_rubygems_version: !ruby/object:Gem::Requirement
51
- none: false
52
- requirements:
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
53
103
  - - ">="
54
- - !ruby/object:Gem::Version
55
- hash: 9
56
- segments:
57
- - 1
58
- - 3
59
- version: "1.3"
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
60
106
  requirements: []
61
-
62
107
  rubyforge_project:
63
- rubygems_version: 1.6.2
108
+ rubygems_version: 2.2.2
64
109
  signing_key:
65
- specification_version: 3
66
- summary: Sane Github v3 api
110
+ specification_version: 4
111
+ summary: Make interactions between your local repository and github seemless and awesome.
67
112
  test_files: []
68
-