gist 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/gist.rb +12 -4
  2. data/lib/gist/version.rb +1 -1
  3. metadata +3 -3
@@ -141,8 +141,9 @@ module Gist
141
141
  req = Net::HTTP::Post.new(url.path)
142
142
  req.body = JSON.generate(data(files, private_gist, description))
143
143
 
144
- if auth_header = auth()
145
- req.add_field('Authorization', auth_header)
144
+ user, password = auth()
145
+ if user && password
146
+ req.basic_auth(user, password)
146
147
  end
147
148
 
148
149
  response = http.start{|h| h.request(req) }
@@ -212,15 +213,22 @@ private
212
213
 
213
214
  # Returns a basic auth string of the user's GitHub credentials if set.
214
215
  # http://github.com/guides/local-github-config
216
+ #
217
+ # Returns an Array of Strings if auth is found: [user, password]
218
+ # Returns nil if no auth is found.
215
219
  def auth
216
220
  user = config("github.user")
217
221
  password = config("github.password")
218
222
 
223
+ token = config("github.token")
224
+ if password.to_s.empty? && !token.to_s.empty?
225
+ abort "Please set GITHUB_PASSWORD or github.password instead of using a token."
226
+ end
227
+
219
228
  if user.to_s.empty? || password.to_s.empty?
220
229
  nil
221
230
  else
222
- auth_str = Base64.encode64("#{user}:#{password}")
223
- "Basic #{auth_str}"
231
+ [ user, password ]
224
232
  end
225
233
  end
226
234
 
@@ -1,3 +1,3 @@
1
1
  module Gist
2
- VERSION = Version = '3.0.0'
2
+ VERSION = Version = '3.0.1'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gist
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
- - 0
10
- version: 3.0.0
9
+ - 1
10
+ version: 3.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Chris Wanstrath