octocat 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 54fc7f33727fafa07c586f9aaabf86e73d8537eb
4
- data.tar.gz: 4a60a1e3be2c8c332a693f03145447dfd9574b8a
3
+ metadata.gz: 7fd0821bdcc0d5b82a4bdff4b813ae4f4b4bdb78
4
+ data.tar.gz: b732cd5cb812f43492ae61165c488c32886d8150
5
5
  SHA512:
6
- metadata.gz: 49b16d024abcf163fdde06d07bb0ed52000196d217de0118a7d5f7e66a16815a777c3ed12c7ddab84e796e16e8ed05f903ed9a2eeb9f3310b0a8ee833b4f536c
7
- data.tar.gz: 88f63451cffd37bc01ee4b221f9f2dd9529c630bef1cd8566b133394ac576e4bb618ca2cf1ce0281e90b2d77fae5aa7033020847cb22f6d6cb453bc83dea4344
6
+ metadata.gz: 3ef147dbda2c7b51df1ae7089510e9373b283a2947003cbc764269b745a812408d0a3e49a05a91df2b6ea9270ee247ee15f37059250124538ed86da28dfe3878
7
+ data.tar.gz: f4b59eb18e4d868d02e182c5ad0fc3abbf89bc547887d33b5581c74298a736e57f4a91b02ceebbedddaea385b7a71d095a6b7cbef4b61ea024e82fc590c15f0e
data/README.md CHANGED
@@ -1,24 +1,12 @@
1
- # Octocat
1
+ # Octocat :octocat:
2
2
 
3
- TODO: Write a gem description
3
+ An OSX command line tool for GitHub
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
7
+ Octocat is OSX specific due to its relience on the credential-osxkeychain. You'll need to setup credential-osxkeychain correctly.
8
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
9
+ If you have GitHub 2FA enabled, you'll want to generate a Personal Access Token.
22
10
 
23
11
  ## Contributing
24
12
 
@@ -1,3 +1,5 @@
1
+ require 'uri'
2
+
1
3
  module Octocat
2
4
  class CommandLine
3
5
  COMMANDS = %w(open-branch new-pr open-pr compare-branch help)
@@ -8,17 +10,24 @@ module Octocat
8
10
  end
9
11
 
10
12
  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"
13
+ if command
14
+ run_command
15
+ else
16
+ puts "Octocat Version #{VERSION}"
17
+ help
18
+ end
19
+ end
20
+
21
+ def run_command
22
+ if command == "open-branch"
14
23
  api.open_branch(project, current_branch)
15
- elsif @command == "new-pr"
24
+ elsif command == "new-pr"
16
25
  api.new_pr(project, current_branch)
17
- elsif @command == "open-pr"
26
+ elsif command == "open-pr"
18
27
  api.open_pr(project, current_branch)
19
- elsif @command == "compare-branch"
28
+ elsif command == "compare-branch"
20
29
  api.compare_branch(project, current_branch)
21
- elsif @command == "help"
30
+ elsif command == "help"
22
31
  help
23
32
  else
24
33
  puts "Unknown Command. The known commands are:"
@@ -39,6 +48,23 @@ module Octocat
39
48
 
40
49
  private
41
50
 
42
- attr_reader :api
51
+ attr_reader :api, :command
52
+
53
+ def git_url
54
+ @git_url ||= `git remote show -n origin | grep 'URL' | head -1`.chomp.split(": ", 2).last
55
+ end
56
+
57
+ def project
58
+ @project ||= get_project
59
+ end
60
+
61
+ def get_project
62
+ if git_url.include? "@"
63
+ git_url.split(":", 2).last.gsub(/\.git$/, "")
64
+ else
65
+ URI(git_url).path[1..-1].gsub(/\.git$/, "")
66
+ end
67
+ end
68
+
43
69
  end
44
70
  end
@@ -1,3 +1,3 @@
1
1
  module Octocat
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octocat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - halogenandtoast
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-13 00:00:00.000000000 Z
11
+ date: 2014-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json