fast_github 0.0.4 → 0.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 90b8476386aee5048ab44bb06b8b42ce2cbdd526
4
- data.tar.gz: 47a9cd4193c4f4187023329eaba21808632e467e
3
+ metadata.gz: 20f341b4a7d25127878b33b69f2b35dad81e7273
4
+ data.tar.gz: c5537b8f4e4c8a0f4b813be9d1542ca02fcc6b20
5
5
  SHA512:
6
- metadata.gz: 21fd8633e7dc223794a86e86352ac6964c78b0fed7541d2d55cca16913cd1c804e12f946111ace8a97a1ec6d14c59bdee4d8ece857cbf11f0fbb05c37de23f2b
7
- data.tar.gz: c415c4a75929aadda0b1c0d7a1b9ddb07b3f6557482fdff0d6d16ac019216aa9d0f27973034ad935990b27c5b2b4d2a2c753340f2ba450d33e4594d01604119c
6
+ metadata.gz: 1d2655b6885811a503172ba7763400f9b440be0249ca3d7bbd7e2cd439a312ad66561c0a4257abc2d1dd65d3a66ae06a0979e0162cb29b8732bf78cb0766aff2
7
+ data.tar.gz: df775a54bd584a4b228440834144836a51d698fb31d1a76065087de98be6f1538bb9edb63e503fc9a0ac51deff5656b959145c5c8373f13006d0e06118970ed1
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ client_secret
data/bin/fast_github CHANGED
@@ -11,4 +11,11 @@ confirm = gets.chomp
11
11
  if confirm.chomp.upcase == "Y" || confirm.chomp == ""
12
12
  repo.create
13
13
  repo.upload
14
+ if repo.upload_response == 'Failed'
15
+ auth.request_oauth
16
+ repo.upload
17
+ if repo.upload_response == 'Failed'
18
+ raise "Could not login to Github"
19
+ end
20
+ end
14
21
  end
@@ -1,3 +1,3 @@
1
1
  module FastGithub
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/lib/fast_github.rb CHANGED
@@ -3,7 +3,6 @@ require "io/console"
3
3
  require "net/http"
4
4
  require "uri"
5
5
  require "json"
6
- require 'yaml'
7
6
 
8
7
  module FastGithub
9
8
  class Auth
@@ -50,7 +49,8 @@ module FastGithub
50
49
  pass = STDIN.noecho(&:gets).chomp
51
50
  puts ""
52
51
  request.basic_auth(user.chomp, pass.chomp)
53
- request.body = { "client_secret" => "2e05ca092118ef4df3c5089717a0bf8cfe1192f1", "scopes" => [ "repo" ] }.to_json
52
+ client_secret = File.open(File.dirname(__FILE__) + "/client_secret", &:readline).chomp
53
+ request.body = { "client_secret" => client_secret, "scopes" => [ "repo" ] }.to_json
54
54
  response = http.request(request)
55
55
  if response.code == "200" || response.code == "201"
56
56
  json_response = JSON.parse(response.body)
@@ -63,11 +63,12 @@ module FastGithub
63
63
  end
64
64
 
65
65
  class Repo
66
- attr_accessor :directory, :remote_name
66
+ attr_accessor :directory, :remote_name, :upload_response
67
67
 
68
68
  def initialize(token, remote_name=nil, dir=Dir.pwd)
69
69
  @token = token
70
70
  @directory = dir
71
+ @upload_response = ''
71
72
  if remote_name && !remote_name.empty?
72
73
  @remote_name = remote_name
73
74
  else
@@ -93,6 +94,12 @@ module FastGithub
93
94
  request["Authorization"] = "token #{@token}"
94
95
  request.body = { "name" => @remote_name }.to_json
95
96
  response = http.request(request)
97
+ if response.code[0] == "2"
98
+ @upload_response == 'Success'
99
+ else
100
+ @upload_response == 'Failed'
101
+ return
102
+ end
96
103
  repo_fullname = (JSON.parse response.body)['full_name']
97
104
  puts `git remote add origin git@github.com:#{repo_fullname}.git`
98
105
  puts `git push -u origin master`
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast_github
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-22 00:00:00.000000000 Z
11
+ date: 2014-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler