gripst 0.1.0 → 0.2.0

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: dc4166725366d8376ffac640f2790bcb1e3815f9
4
- data.tar.gz: 59d3c347ee3e7577f468b1b75ed41ecf89b34058
3
+ metadata.gz: bb89d2f6444d0fb62f56a817cf023ac014f787da
4
+ data.tar.gz: 5a1f9b26616c8d476e493efc1a06eacf384d81fc
5
5
  SHA512:
6
- metadata.gz: 17cb2a9747fd9417a5fb63e5b2cb0cdd4b28e7ee767574f8e99fb1b711f73861e19f7df7d7234e3e15133a3e5dcbc3b7e118e2048bd1651f925ba705528a5b36
7
- data.tar.gz: afc395c8f85de986767019f6c4d5c42347cf20b3be8d6dc697ad73131e9df2fe8fec1232691c7f7d47c6ff17175ce099203e226f0f746fd7cd8119f00633c522
6
+ metadata.gz: bd13ddce77b956daea9dd714ffd133b8c4c64524415c4296f13d79413cbbd5c5b5fec6ad5c7720edc85dc83f1cc0a31e018ef27fa5e78911babbfdfcd61474d5
7
+ data.tar.gz: fd91fcc34bb5d529a8cef7f82c3cd4f06e6db9dd8509bd2e524e5e8cdea3cdc66f3d3bd5d488f546e29e41aa9a8e1db4f396794d52dc422da2f44c025c34faf8
data/bin/gripst CHANGED
@@ -8,7 +8,6 @@ require 'gripst'
8
8
 
9
9
  begin
10
10
  gripst = Gripst::Gripst.new
11
- raise 'please set GITHUB_USER_ACCESS_TOKEN as instructed in the README' unless gripst.initialized?
12
11
  puts 'gripsting'
13
12
  gripst.all_gist_ids.each { |id| gripst.run(ARGV[0], id) }
14
13
  rescue SystemExit, Interrupt
data/lib/gripst/client.rb CHANGED
@@ -11,10 +11,22 @@ class Client
11
11
  authorizer.authorize
12
12
  end
13
13
 
14
+ def login_with_oauth(oauth_token)
15
+ client = Octokit::Client.new :access_token => oauth_token
16
+ client.user.login
17
+ client
18
+ rescue Octokit::Unauthorized
19
+ puts '---'
20
+ puts '---'
21
+ puts '---'
22
+ puts 'Unable to create personal access token on github. Is the gripst application already set? https://github.com/settings/tokens'
23
+ exit
24
+ end
25
+
14
26
  private
15
27
 
16
28
  def oauth_from_file
17
- File.open PATH, &:readline if File.exists? PATH
29
+ File.open PATH, &:readline if File.exists?(PATH) && !File.zero?(PATH)
18
30
  end
19
31
  end
20
32
 
@@ -27,16 +39,21 @@ class Client
27
39
  end
28
40
 
29
41
  def authorize
30
-
31
42
  begin
32
43
  auth_token = client.create_authorization :scopes => ['gists'], :note => 'gripst'
33
44
  rescue Octokit::OneTimePasswordRequired
34
45
  otp = get_otp
35
46
  auth_token = authorize_with_otp otp
47
+ rescue Octokit::Unauthorized
48
+ puts '---'
49
+ puts '---'
50
+ puts '---'
51
+ puts 'Username or password was incorrect'
52
+ exit
36
53
  end
37
54
 
38
55
  write_auth_token auth_token
39
- login_with_oauth auth_token
56
+ auth_token
40
57
  end
41
58
 
42
59
  private
@@ -72,14 +89,12 @@ class Client
72
89
  :note => 'gripst',
73
90
  :headers => { 'X-GitHub-OTP' => token }
74
91
  response[:token]
75
- rescue Octokit::UnprocessableEntity => e
76
- raise "422 error: #{e}"
77
- end
78
-
79
- def login_with_oauth(oauth_token)
80
- client = Octokit::Client.new :access_token => oauth_token
81
- client.user.login
82
- client
92
+ rescue Octokit::UnprocessableEntity
93
+ puts '---'
94
+ puts '---'
95
+ puts '---'
96
+ puts 'Unable to create personal access token on github. Is the gripst application already set? https://github.com/settings/tokens'
97
+ exit
83
98
  end
84
99
 
85
100
  def write_auth_token(oauth_token)
data/lib/gripst/gripst.rb CHANGED
@@ -44,13 +44,7 @@ module Gripst
44
44
  private
45
45
 
46
46
  def client
47
- @client ||= create_client
48
- end
49
-
50
- def create_client
51
- client = Octokit::Client.new :access_token => "#{auth_token}"
52
- client.user.login
53
- client
47
+ @client ||= Client.login_with_oauth auth_token
54
48
  end
55
49
 
56
50
  def loop_through_lines_of_a_gist(regex, param_obj)
@@ -1,3 +1,3 @@
1
1
  module Gripst
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gripst
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Beizer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-02 00:00:00.000000000 Z
11
+ date: 2015-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit