gripst 0.1.0 → 0.2.0
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 +4 -4
- data/bin/gripst +0 -1
- data/lib/gripst/client.rb +26 -11
- data/lib/gripst/gripst.rb +1 -7
- data/lib/gripst/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bb89d2f6444d0fb62f56a817cf023ac014f787da
|
|
4
|
+
data.tar.gz: 5a1f9b26616c8d476e493efc1a06eacf384d81fc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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 ||=
|
|
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)
|
data/lib/gripst/version.rb
CHANGED
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.
|
|
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-
|
|
11
|
+
date: 2015-08-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: octokit
|