gist 5.0.0 → 5.1.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
- SHA1:
3
- metadata.gz: '009c779d5fc272fe71b6a1f8ae44d110f91bcfe1'
4
- data.tar.gz: d57f1f9e76c336d05a0145b7f0f31904049567c2
2
+ SHA256:
3
+ metadata.gz: b81d6d7f5378a97ea2110a82b03f703ef3e288ac038c233428e0413149b5bb34
4
+ data.tar.gz: 2f01fcdd837e72af4a7ed7c53120b1605ad73fd15d15a4e8d4dd709d43775f7e
5
5
  SHA512:
6
- metadata.gz: f0fad7991139e0848e8c3e884c0b16fec18f1097dffc08d5e76842f80367c1af621ef3ca04f2b970084cdca16630b47fcb31025ba415125d0e1497151a6647c9
7
- data.tar.gz: 386a013bfc9c25e5453944d4c71cdf5e913772dc3574bbd0b3b8eb227f1d55e987b21e83c7ab7b9554edbfcec0b19569d1f6dc479e338463b1d3146c47e61e14
6
+ metadata.gz: b5c0ae73ff4b52e917a485ad0e95b4a5520ba8212b39557a82ccc3cc8bf309a34ddfceedc67fe24222069ffd485fa857776238b05a57fc0c52ec7a215c6ca297
7
+ data.tar.gz: 9ded7356c613f6130bbb9b3c8859723c12a0c897073c6c6149c37038d3d3dd285a98dd2b773ba7dc036ba520e4b8440eec76c9468a22ff8a0213e70e0d8ddc52
data/README.md CHANGED
@@ -21,6 +21,11 @@ upload content to https://gist.github.com/.
21
21
 
22
22
  brew install gist
23
23
 
24
+ ‌For FreeBSD, gist lives in ports
25
+
26
+ pkg install gist
27
+
28
+
24
29
  ## Command
25
30
 
26
31
  ‌To upload the contents of `a.rb` just:
@@ -84,7 +89,7 @@ with gist. It doesn't store your username and password, it just uses them to get
84
89
  an OAuth2 token (with the "gist" permission).
85
90
 
86
91
  gist --login
87
- Obtaining OAuth2 access_token from github.
92
+ Obtaining OAuth2 access_token from GitHub.
88
93
  GitHub username: ConradIrwin
89
94
  GitHub password:
90
95
  2-factor auth code:
@@ -94,22 +99,20 @@ This token is stored in `~/.gist` and used for all future gisting. If you need t
94
99
  you can revoke it from https://github.com/settings/tokens, or just delete the
95
100
  file.
96
101
 
97
- ‌After you've done this, you can still upload gists anonymously with `-a`.
98
-
99
- gist -a a.rb
100
-
101
102
  #### Password-less login
102
103
 
103
104
  If you have a complicated authorization requirement you can manually create a
104
- token file by pasting a Github token with only the `gist` permission into a
105
+ token file by pasting a GitHub token with only the `gist` permission into a
105
106
  file called `~/.gist`. You can create one from https://github.com/settings/tokens
106
107
 
107
108
  This file should contain only the token (~40 hex characters), and to make it
108
- easier to edit, can optionally have a final newline (\n or \r\n).
109
+ easier to edit, can optionally have a final newline (`\n` or `\r\n`).
109
110
 
110
111
  For example, one way to create this file would be to run:
111
112
 
112
- echo MY_SECRET_TOKEN > ~/.gist
113
+ (umask 0077 && echo MY_SECRET_TOKEN > ~/.gist)
114
+
115
+ The `umask` ensures that the file is only accessible from your user account.
113
116
 
114
117
  ### GitHub Enterprise
115
118
 
@@ -119,7 +122,7 @@ you need to export the `GITHUB_URL` environment variable (usually done in your `
119
122
  export GITHUB_URL=http://github.internal.example.com/
120
123
 
121
124
  Once you've done this and restarted your terminal (or run `source ~/.bashrc`), gist will
122
- automatically use github enterprise instead of the public github.com
125
+ automatically use GitHub Enterprise instead of the public github.com
123
126
 
124
127
  Your token for GitHub Enterprise will be stored in `.gist.<protocol>.<server.name>[.<port>]` (e.g.
125
128
  `~/.gist.http.github.internal.example.com` for the GITHUB_URL example above) instead of `~/.gist`.
@@ -150,7 +153,6 @@ If you need more advanced features you can also pass:
150
153
  * `:public` if you want your gist to have a guessable url.
151
154
  * `:description` to add a description to your gist.
152
155
  * `:update` to update an existing gist (can be a URL or an id).
153
- * `:anonymous` to submit an anonymous gist (default is false).
154
156
  * `:copy` to copy the resulting URL to the clipboard (default is false).
155
157
  * `:open` to open the resulting URL in a browser (default is false).
156
158
 
data/bin/gist CHANGED
@@ -25,7 +25,7 @@ filenames can be overridden by repeating the "-f" flag. The most useful reason
25
25
  to do this is to change the syntax highlighting.
26
26
 
27
27
  All gists must to be associated with a GitHub account, so you will need to login with
28
- `gist --login` to obtain an Oauth2 access token. This is stored and used by gist in the future.
28
+ `gist --login` to obtain an OAuth2 access token. This is stored and used by gist in the future.
29
29
 
30
30
  Private gists do not have guessable URLs and can be created with "-p", you can
31
31
  also set the description at the top of the gist by passing "-d".
@@ -142,7 +142,7 @@ end.parse!
142
142
  begin
143
143
  if Gist.auth_token.nil?
144
144
  puts 'Please log in with `gist --login`. ' \
145
- '(Github now requires credentials to gist https://bit.ly/2GBBxKw)'
145
+ '(GitHub now requires credentials to gist https://bit.ly/2GBBxKw)'
146
146
  exit(1)
147
147
  end
148
148
 
data/build/gist CHANGED
@@ -1318,7 +1318,7 @@ end
1318
1318
  module Gist
1319
1319
  extend self
1320
1320
 
1321
- VERSION = '5.0.0'
1321
+ VERSION = '5.1.0'
1322
1322
 
1323
1323
  # A list of clipboard commands with copy and paste support.
1324
1324
  CLIPBOARD_COMMANDS = {
@@ -1416,7 +1416,7 @@ module Gist
1416
1416
  def multi_gist(files, options={})
1417
1417
  if options[:anonymous]
1418
1418
  raise 'Anonymous gists are no longer supported. Please log in with `gist --login`. ' \
1419
- '(Github now requires credentials to gist https://bit.ly/2GBBxKw)'
1419
+ '(GitHub now requires credentials to gist https://bit.ly/2GBBxKw)'
1420
1420
  else
1421
1421
  access_token = (options[:access_token] || auth_token())
1422
1422
  end
@@ -1442,9 +1442,9 @@ module Gist
1442
1442
 
1443
1443
  url = "#{base_path}/gists"
1444
1444
  url << "/" << CGI.escape(existing_gist) if existing_gist.to_s != ''
1445
- url << "?access_token=" << CGI.escape(access_token) if access_token.to_s != ''
1446
1445
 
1447
1446
  request = Net::HTTP::Post.new(url)
1447
+ request['Authorization'] = "token #{access_token}" if access_token.to_s != ''
1448
1448
  request.body = JSON.dump(json)
1449
1449
  request.content_type = 'application/json'
1450
1450
 
@@ -1480,9 +1480,10 @@ module Gist
1480
1480
  if user == ""
1481
1481
  access_token = auth_token()
1482
1482
  if access_token.to_s != ''
1483
- url << "/gists?access_token=" << CGI.escape(access_token)
1483
+ url << "/gists"
1484
1484
 
1485
1485
  request = Net::HTTP::Get.new(url)
1486
+ request['Authorization'] = "token #{access_token}"
1486
1487
  response = http(api_url, request)
1487
1488
 
1488
1489
  pretty_gist(response)
@@ -1507,8 +1508,8 @@ module Gist
1507
1508
  if user == ""
1508
1509
  access_token = auth_token()
1509
1510
  if access_token.to_s != ''
1510
- url << "/gists?per_page=100&access_token=" << CGI.escape(access_token)
1511
- get_gist_pages(url)
1511
+ url << "/gists?per_page=100"
1512
+ get_gist_pages(url, access_token)
1512
1513
  else
1513
1514
  raise Error, "Not authenticated. Use 'gist --login' to login or 'gist -l username' to view public gists."
1514
1515
  end
@@ -1524,11 +1525,9 @@ module Gist
1524
1525
  url = "#{base_path}/gists/#{id}"
1525
1526
 
1526
1527
  access_token = auth_token()
1527
- if access_token.to_s != ''
1528
- url << "?access_token=" << CGI.escape(access_token)
1529
- end
1530
1528
 
1531
1529
  request = Net::HTTP::Get.new(url)
1530
+ request['Authorization'] = "token #{access_token}" if access_token.to_s != ''
1532
1531
  response = http(api_url, request)
1533
1532
 
1534
1533
  if response.code == '200'
@@ -1554,9 +1553,8 @@ module Gist
1554
1553
 
1555
1554
  access_token = auth_token()
1556
1555
  if access_token.to_s != ''
1557
- url << "?access_token=" << CGI.escape(access_token)
1558
-
1559
1556
  request = Net::HTTP::Delete.new(url)
1557
+ request["Authorization"] = "token #{access_token}"
1560
1558
  response = http(api_url, request)
1561
1559
  else
1562
1560
  raise Error, "Not authenticated. Use 'gist --login' to login."
@@ -1569,9 +1567,10 @@ module Gist
1569
1567
  end
1570
1568
  end
1571
1569
 
1572
- def get_gist_pages(url)
1570
+ def get_gist_pages(url, access_token = "")
1573
1571
 
1574
1572
  request = Net::HTTP::Get.new(url)
1573
+ request['Authorization'] = "token #{access_token}" if access_token.to_s != ''
1575
1574
  response = http(api_url, request)
1576
1575
  pretty_gist(response)
1577
1576
 
@@ -1579,7 +1578,7 @@ module Gist
1579
1578
 
1580
1579
  if link_header
1581
1580
  links = Hash[ link_header.gsub(/(<|>|")/, "").split(',').map { |link| link.split('; rel=') } ].invert
1582
- get_gist_pages(links['next']) if links['next']
1581
+ get_gist_pages(links['next'], access_token) if links['next']
1583
1582
  end
1584
1583
 
1585
1584
  end
@@ -1652,7 +1651,7 @@ module Gist
1652
1651
  # @option credentials [String] :password
1653
1652
  # @see http://developer.github.com/v3/oauth/
1654
1653
  def login!(credentials={})
1655
- puts "Obtaining OAuth2 access_token from github."
1654
+ puts "Obtaining OAuth2 access_token from GitHub."
1656
1655
  loop do
1657
1656
  print "GitHub username: "
1658
1657
  username = credentials[:username] || $stdin.gets.strip
@@ -1906,7 +1905,7 @@ filenames can be overridden by repeating the "-f" flag. The most useful reason
1906
1905
  to do this is to change the syntax highlighting.
1907
1906
 
1908
1907
  All gists must to be associated with a GitHub account, so you will need to login with
1909
- `gist --login` to obtain an Oauth2 access token. This is stored and used by gist in the future.
1908
+ `gist --login` to obtain an OAuth2 access token. This is stored and used by gist in the future.
1910
1909
 
1911
1910
  Private gists do not have guessable URLs and can be created with "-p", you can
1912
1911
  also set the description at the top of the gist by passing "-d".
@@ -2023,7 +2022,7 @@ end.parse!
2023
2022
  begin
2024
2023
  if Gist.auth_token.nil?
2025
2024
  puts 'Please log in with `gist --login`. ' \
2026
- '(Github now requires credentials to gist https://bit.ly/2GBBxKw)'
2025
+ '(GitHub now requires credentials to gist https://bit.ly/2GBBxKw)'
2027
2026
  exit(1)
2028
2027
  end
2029
2028
 
data/lib/gist.rb CHANGED
@@ -12,7 +12,7 @@ end
12
12
  module Gist
13
13
  extend self
14
14
 
15
- VERSION = '5.0.0'
15
+ VERSION = '5.1.0'
16
16
 
17
17
  # A list of clipboard commands with copy and paste support.
18
18
  CLIPBOARD_COMMANDS = {
@@ -110,7 +110,7 @@ module Gist
110
110
  def multi_gist(files, options={})
111
111
  if options[:anonymous]
112
112
  raise 'Anonymous gists are no longer supported. Please log in with `gist --login`. ' \
113
- '(Github now requires credentials to gist https://bit.ly/2GBBxKw)'
113
+ '(GitHub now requires credentials to gist https://bit.ly/2GBBxKw)'
114
114
  else
115
115
  access_token = (options[:access_token] || auth_token())
116
116
  end
@@ -136,9 +136,9 @@ module Gist
136
136
 
137
137
  url = "#{base_path}/gists"
138
138
  url << "/" << CGI.escape(existing_gist) if existing_gist.to_s != ''
139
- url << "?access_token=" << CGI.escape(access_token) if access_token.to_s != ''
140
139
 
141
140
  request = Net::HTTP::Post.new(url)
141
+ request['Authorization'] = "token #{access_token}" if access_token.to_s != ''
142
142
  request.body = JSON.dump(json)
143
143
  request.content_type = 'application/json'
144
144
 
@@ -174,9 +174,10 @@ module Gist
174
174
  if user == ""
175
175
  access_token = auth_token()
176
176
  if access_token.to_s != ''
177
- url << "/gists?access_token=" << CGI.escape(access_token)
177
+ url << "/gists"
178
178
 
179
179
  request = Net::HTTP::Get.new(url)
180
+ request['Authorization'] = "token #{access_token}"
180
181
  response = http(api_url, request)
181
182
 
182
183
  pretty_gist(response)
@@ -201,8 +202,8 @@ module Gist
201
202
  if user == ""
202
203
  access_token = auth_token()
203
204
  if access_token.to_s != ''
204
- url << "/gists?per_page=100&access_token=" << CGI.escape(access_token)
205
- get_gist_pages(url)
205
+ url << "/gists?per_page=100"
206
+ get_gist_pages(url, access_token)
206
207
  else
207
208
  raise Error, "Not authenticated. Use 'gist --login' to login or 'gist -l username' to view public gists."
208
209
  end
@@ -218,11 +219,9 @@ module Gist
218
219
  url = "#{base_path}/gists/#{id}"
219
220
 
220
221
  access_token = auth_token()
221
- if access_token.to_s != ''
222
- url << "?access_token=" << CGI.escape(access_token)
223
- end
224
222
 
225
223
  request = Net::HTTP::Get.new(url)
224
+ request['Authorization'] = "token #{access_token}" if access_token.to_s != ''
226
225
  response = http(api_url, request)
227
226
 
228
227
  if response.code == '200'
@@ -248,9 +247,8 @@ module Gist
248
247
 
249
248
  access_token = auth_token()
250
249
  if access_token.to_s != ''
251
- url << "?access_token=" << CGI.escape(access_token)
252
-
253
250
  request = Net::HTTP::Delete.new(url)
251
+ request["Authorization"] = "token #{access_token}"
254
252
  response = http(api_url, request)
255
253
  else
256
254
  raise Error, "Not authenticated. Use 'gist --login' to login."
@@ -263,9 +261,10 @@ module Gist
263
261
  end
264
262
  end
265
263
 
266
- def get_gist_pages(url)
264
+ def get_gist_pages(url, access_token = "")
267
265
 
268
266
  request = Net::HTTP::Get.new(url)
267
+ request['Authorization'] = "token #{access_token}" if access_token.to_s != ''
269
268
  response = http(api_url, request)
270
269
  pretty_gist(response)
271
270
 
@@ -273,7 +272,7 @@ module Gist
273
272
 
274
273
  if link_header
275
274
  links = Hash[ link_header.gsub(/(<|>|")/, "").split(',').map { |link| link.split('; rel=') } ].invert
276
- get_gist_pages(links['next']) if links['next']
275
+ get_gist_pages(links['next'], access_token) if links['next']
277
276
  end
278
277
 
279
278
  end
@@ -346,7 +345,7 @@ module Gist
346
345
  # @option credentials [String] :password
347
346
  # @see http://developer.github.com/v3/oauth/
348
347
  def login!(credentials={})
349
- puts "Obtaining OAuth2 access_token from github."
348
+ puts "Obtaining OAuth2 access_token from GitHub."
350
349
  loop do
351
350
  print "GitHub username: "
352
351
  username = credentials[:username] || $stdin.gets.strip
data/spec/rawify_spec.rb CHANGED
@@ -11,7 +11,7 @@ describe '...' do
11
11
 
12
12
  it 'should raise an error when trying to do operations without being logged in' do
13
13
  error_msg = 'Anonymous gists are no longer supported. Please log in with `gist --login`. ' \
14
- '(Github now requires credentials to gist https://bit.ly/2GBBxKw)'
14
+ '(GitHub now requires credentials to gist https://bit.ly/2GBBxKw)'
15
15
 
16
16
  expect do
17
17
  Gist.gist("Test gist", output: :raw_url, anonymous: true)
data/spec/shorten_spec.rb CHANGED
@@ -15,7 +15,7 @@ describe '...' do
15
15
 
16
16
  it 'should raise an error when trying to get short urls without being logged in' do
17
17
  error_msg = 'Anonymous gists are no longer supported. Please log in with `gist --login`. ' \
18
- '(Github now requires credentials to gist https://bit.ly/2GBBxKw)'
18
+ '(GitHub now requires credentials to gist https://bit.ly/2GBBxKw)'
19
19
 
20
20
  expect do
21
21
  Gist.gist("Test gist", output: :short_url, anonymous: true)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gist
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Conrad Irwin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-05-23 00:00:00.000000000 Z
12
+ date: 2020-02-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -115,8 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  requirements: []
118
- rubyforge_project:
119
- rubygems_version: 2.6.11
118
+ rubygems_version: 3.0.3
120
119
  signing_key:
121
120
  specification_version: 4
122
121
  summary: Just allows you to upload gists