gist 4.2.1 → 4.3.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/README.md +5 -0
- data/bin/gist +14 -0
- data/build/gist +74 -2
- data/build/gist.1 +7 -1
- data/lib/gist.rb +60 -2
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7a304fb9f742996cc0bca4b5a3d62c8ca52abba
|
4
|
+
data.tar.gz: 24bcae03f00c4e4241f4dea50aae4bf64850a140
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb0f2608a1bb78e0cc359d9d4f2793ebfbf33e846fca649f91ffa48125c44ce59114b8adb84d886f6d8cf94b87a2622f8a234695b6ca04b3be4fd42d96737bbc
|
7
|
+
data.tar.gz: 5bbbe8d45b08eb54ec5f659d9e23b83313ff3abf9b2475f408d44c117e62d7eb9604d0c8d26bbfe11fe313d71671e12ba696c09fc8d1d92a692909fca5fa7de6
|
data/README.md
CHANGED
@@ -64,6 +64,11 @@ upload content to https://gist.github.com/.
|
|
64
64
|
|
65
65
|
gist -o <a.rb
|
66
66
|
|
67
|
+
To list (public gists or all gists for authed user) gists for user
|
68
|
+
|
69
|
+
gist -l : all gists for authed user
|
70
|
+
gist -l defunkt : list defunkt's public gists
|
71
|
+
|
67
72
|
See `gist --help` for more detail.
|
68
73
|
|
69
74
|
## Login
|
data/bin/gist
CHANGED
@@ -110,6 +110,10 @@ Usage: #{executable_name} [-o|-c|-e] [-p] [-s] [-R] [-d DESC] [-a] [-u URL] [-P]
|
|
110
110
|
options[:raw] = true
|
111
111
|
end
|
112
112
|
|
113
|
+
opts.on("-l", "--list [USER]", "List all gists for user") do |user|
|
114
|
+
options[:list] = user
|
115
|
+
end
|
116
|
+
|
113
117
|
opts.on_tail("-h","--help", "Show this message.") do
|
114
118
|
puts opts
|
115
119
|
exit
|
@@ -139,6 +143,15 @@ begin
|
|
139
143
|
|
140
144
|
options[:public] = Gist.should_be_public?(options)
|
141
145
|
|
146
|
+
if options.key? :list
|
147
|
+
if options[:list]
|
148
|
+
Gist.list_gists(options[:list])
|
149
|
+
else
|
150
|
+
Gist.list_gists
|
151
|
+
end
|
152
|
+
exit
|
153
|
+
end
|
154
|
+
|
142
155
|
if options[:paste]
|
143
156
|
puts Gist.gist(Gist.paste, options)
|
144
157
|
else
|
@@ -160,6 +173,7 @@ begin
|
|
160
173
|
|
161
174
|
puts Gist.multi_gist(files, options)
|
162
175
|
end
|
176
|
+
|
163
177
|
rescue Gist::Error => e
|
164
178
|
puts "Error: #{e.message}"
|
165
179
|
exit 1
|
data/build/gist
CHANGED
@@ -1318,7 +1318,7 @@ end
|
|
1318
1318
|
module Gist
|
1319
1319
|
extend self
|
1320
1320
|
|
1321
|
-
VERSION = '4.
|
1321
|
+
VERSION = '4.3.0'
|
1322
1322
|
|
1323
1323
|
# A list of clipboard commands with copy and paste support.
|
1324
1324
|
CLIPBOARD_COMMANDS = {
|
@@ -1346,6 +1346,13 @@ module Gist
|
|
1346
1346
|
end
|
1347
1347
|
class ClipboardError < RuntimeError; include Error end
|
1348
1348
|
|
1349
|
+
# auth token for authentication
|
1350
|
+
#
|
1351
|
+
# @return [String] string value of access token or `nil`, if not found
|
1352
|
+
def auth_token
|
1353
|
+
@token ||= File.read(auth_token_file) rescue nil
|
1354
|
+
end
|
1355
|
+
|
1349
1356
|
# Upload a gist to https://gist.github.com
|
1350
1357
|
#
|
1351
1358
|
# @param [String] content the code you'd like to gist
|
@@ -1396,7 +1403,7 @@ module Gist
|
|
1396
1403
|
if options[:anonymous]
|
1397
1404
|
access_token = nil
|
1398
1405
|
else
|
1399
|
-
access_token = (options[:access_token] ||
|
1406
|
+
access_token = (options[:access_token] || auth_token())
|
1400
1407
|
end
|
1401
1408
|
|
1402
1409
|
url = "#{base_path}/gists"
|
@@ -1426,6 +1433,57 @@ module Gist
|
|
1426
1433
|
raise e.extend Error
|
1427
1434
|
end
|
1428
1435
|
|
1436
|
+
# List all gists(private also) for authenticated user
|
1437
|
+
# otherwise list public gists for given username (optional argument)
|
1438
|
+
#
|
1439
|
+
# @param [String] user
|
1440
|
+
#
|
1441
|
+
# see https://developer.github.com/v3/gists/#list-gists
|
1442
|
+
def list_gists(user = "")
|
1443
|
+
url = "#{base_path}"
|
1444
|
+
|
1445
|
+
if user == ""
|
1446
|
+
access_token = auth_token()
|
1447
|
+
if access_token.to_s != ''
|
1448
|
+
url << "/gists?access_token=" << CGI.escape(access_token)
|
1449
|
+
|
1450
|
+
request = Net::HTTP::Get.new(url)
|
1451
|
+
response = http(api_url, request)
|
1452
|
+
|
1453
|
+
pretty_gist(response)
|
1454
|
+
|
1455
|
+
else
|
1456
|
+
raise Error, "Not authenticated. Use 'gist --login' to login or 'gist -l username' to view public gists."
|
1457
|
+
end
|
1458
|
+
|
1459
|
+
else
|
1460
|
+
url << "/users/#{user}/gists"
|
1461
|
+
|
1462
|
+
request = Net::HTTP::Get.new(url)
|
1463
|
+
response = http(api_url, request)
|
1464
|
+
|
1465
|
+
pretty_gist(response)
|
1466
|
+
end
|
1467
|
+
end
|
1468
|
+
|
1469
|
+
# return prettified string result of response body for all gists
|
1470
|
+
#
|
1471
|
+
# @params [Net::HTTPResponse] response
|
1472
|
+
# @return [String] prettified result of listing all gists
|
1473
|
+
#
|
1474
|
+
# see https://developer.github.com/v3/gists/#response
|
1475
|
+
def pretty_gist(response)
|
1476
|
+
body = JSON.parse(response.body)
|
1477
|
+
if response.code == '200'
|
1478
|
+
body.each do |gist|
|
1479
|
+
puts "#{gist['html_url']} #{gist['description'] || gist['files'].keys.join(" ")} #{gist['public'] ? '' : '(secret)'}\n"
|
1480
|
+
end
|
1481
|
+
|
1482
|
+
else
|
1483
|
+
raise Error, body['message']
|
1484
|
+
end
|
1485
|
+
end
|
1486
|
+
|
1429
1487
|
# Convert long github urls into short git.io ones
|
1430
1488
|
#
|
1431
1489
|
# @param [String] url
|
@@ -1821,6 +1879,10 @@ Usage: #{executable_name} [-o|-c|-e] [-p] [-s] [-R] [-d DESC] [-a] [-u URL] [-P]
|
|
1821
1879
|
options[:raw] = true
|
1822
1880
|
end
|
1823
1881
|
|
1882
|
+
opts.on("-l", "--list [USER]", "List all gists for user") do |user|
|
1883
|
+
options[:list] = user
|
1884
|
+
end
|
1885
|
+
|
1824
1886
|
opts.on_tail("-h","--help", "Show this message.") do
|
1825
1887
|
puts opts
|
1826
1888
|
exit
|
@@ -1850,6 +1912,15 @@ begin
|
|
1850
1912
|
|
1851
1913
|
options[:public] = Gist.should_be_public?(options)
|
1852
1914
|
|
1915
|
+
if options.key? :list
|
1916
|
+
if options[:list]
|
1917
|
+
Gist.list_gists(options[:list])
|
1918
|
+
else
|
1919
|
+
Gist.list_gists
|
1920
|
+
end
|
1921
|
+
exit
|
1922
|
+
end
|
1923
|
+
|
1853
1924
|
if options[:paste]
|
1854
1925
|
puts Gist.gist(Gist.paste, options)
|
1855
1926
|
else
|
@@ -1871,6 +1942,7 @@ begin
|
|
1871
1942
|
|
1872
1943
|
puts Gist.multi_gist(files, options)
|
1873
1944
|
end
|
1945
|
+
|
1874
1946
|
rescue Gist::Error => e
|
1875
1947
|
puts "Error: #{e.message}"
|
1876
1948
|
exit 1
|
data/build/gist.1
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
.\" generated with Ronn/v0.7.3
|
2
2
|
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
3
|
.
|
4
|
-
.TH "GIST" "1" "
|
4
|
+
.TH "GIST" "1" "August 2014" "" "Gist manual"
|
5
5
|
.
|
6
6
|
.SH "NAME"
|
7
7
|
\fBgist\fR \- upload code to https://gist\.github\.com
|
@@ -94,6 +94,12 @@ And you can just ask gist to open a browser window directly with \fB\-o\fR\.
|
|
94
94
|
gist \-o <a\.rb
|
95
95
|
.
|
96
96
|
.IP "\(bu" 4
|
97
|
+
To list (public gists or all gists for authed user) gists for user
|
98
|
+
.
|
99
|
+
.IP
|
100
|
+
gist \-l : all gists for authed user gist \-l defunkt : list defunkt\'s public gists
|
101
|
+
.
|
102
|
+
.IP "\(bu" 4
|
97
103
|
See \fBgist \-\-help\fR for more detail\.
|
98
104
|
.
|
99
105
|
.IP "" 0
|
data/lib/gist.rb
CHANGED
@@ -12,7 +12,7 @@ end
|
|
12
12
|
module Gist
|
13
13
|
extend self
|
14
14
|
|
15
|
-
VERSION = '4.
|
15
|
+
VERSION = '4.3.0'
|
16
16
|
|
17
17
|
# A list of clipboard commands with copy and paste support.
|
18
18
|
CLIPBOARD_COMMANDS = {
|
@@ -40,6 +40,13 @@ module Gist
|
|
40
40
|
end
|
41
41
|
class ClipboardError < RuntimeError; include Error end
|
42
42
|
|
43
|
+
# auth token for authentication
|
44
|
+
#
|
45
|
+
# @return [String] string value of access token or `nil`, if not found
|
46
|
+
def auth_token
|
47
|
+
@token ||= File.read(auth_token_file) rescue nil
|
48
|
+
end
|
49
|
+
|
43
50
|
# Upload a gist to https://gist.github.com
|
44
51
|
#
|
45
52
|
# @param [String] content the code you'd like to gist
|
@@ -90,7 +97,7 @@ module Gist
|
|
90
97
|
if options[:anonymous]
|
91
98
|
access_token = nil
|
92
99
|
else
|
93
|
-
access_token = (options[:access_token] ||
|
100
|
+
access_token = (options[:access_token] || auth_token())
|
94
101
|
end
|
95
102
|
|
96
103
|
url = "#{base_path}/gists"
|
@@ -120,6 +127,57 @@ module Gist
|
|
120
127
|
raise e.extend Error
|
121
128
|
end
|
122
129
|
|
130
|
+
# List all gists(private also) for authenticated user
|
131
|
+
# otherwise list public gists for given username (optional argument)
|
132
|
+
#
|
133
|
+
# @param [String] user
|
134
|
+
#
|
135
|
+
# see https://developer.github.com/v3/gists/#list-gists
|
136
|
+
def list_gists(user = "")
|
137
|
+
url = "#{base_path}"
|
138
|
+
|
139
|
+
if user == ""
|
140
|
+
access_token = auth_token()
|
141
|
+
if access_token.to_s != ''
|
142
|
+
url << "/gists?access_token=" << CGI.escape(access_token)
|
143
|
+
|
144
|
+
request = Net::HTTP::Get.new(url)
|
145
|
+
response = http(api_url, request)
|
146
|
+
|
147
|
+
pretty_gist(response)
|
148
|
+
|
149
|
+
else
|
150
|
+
raise Error, "Not authenticated. Use 'gist --login' to login or 'gist -l username' to view public gists."
|
151
|
+
end
|
152
|
+
|
153
|
+
else
|
154
|
+
url << "/users/#{user}/gists"
|
155
|
+
|
156
|
+
request = Net::HTTP::Get.new(url)
|
157
|
+
response = http(api_url, request)
|
158
|
+
|
159
|
+
pretty_gist(response)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
# return prettified string result of response body for all gists
|
164
|
+
#
|
165
|
+
# @params [Net::HTTPResponse] response
|
166
|
+
# @return [String] prettified result of listing all gists
|
167
|
+
#
|
168
|
+
# see https://developer.github.com/v3/gists/#response
|
169
|
+
def pretty_gist(response)
|
170
|
+
body = JSON.parse(response.body)
|
171
|
+
if response.code == '200'
|
172
|
+
body.each do |gist|
|
173
|
+
puts "#{gist['html_url']} #{gist['description'] || gist['files'].keys.join(" ")} #{gist['public'] ? '' : '(secret)'}\n"
|
174
|
+
end
|
175
|
+
|
176
|
+
else
|
177
|
+
raise Error, body['message']
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
123
181
|
# Convert long github urls into short git.io ones
|
124
182
|
#
|
125
183
|
# @param [String] url
|
metadata
CHANGED
@@ -1,70 +1,70 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Conrad Irwin
|
8
|
-
- ☈king
|
8
|
+
- "☈king"
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-08-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rspec
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: webmock
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: ronn
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
description: Provides a single function (Gist.gist) that uploads a gist.
|
@@ -76,8 +76,8 @@ executables:
|
|
76
76
|
extensions: []
|
77
77
|
extra_rdoc_files: []
|
78
78
|
files:
|
79
|
-
- .gitignore
|
80
|
-
- .rspec
|
79
|
+
- ".gitignore"
|
80
|
+
- ".rspec"
|
81
81
|
- Gemfile
|
82
82
|
- LICENSE.MIT
|
83
83
|
- README.md
|
@@ -105,17 +105,17 @@ require_paths:
|
|
105
105
|
- lib
|
106
106
|
required_ruby_version: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
112
|
requirements:
|
113
|
-
- -
|
113
|
+
- - ">="
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: '0'
|
116
116
|
requirements: []
|
117
117
|
rubyforge_project:
|
118
|
-
rubygems_version: 2.
|
118
|
+
rubygems_version: 2.2.2
|
119
119
|
signing_key:
|
120
120
|
specification_version: 4
|
121
121
|
summary: Just allows you to upload gists
|