gist 2.0.2 → 2.0.3.pre

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.
Files changed (3) hide show
  1. data/lib/gist.rb +23 -8
  2. data/lib/gist/version.rb +1 -1
  3. metadata +12 -9
data/lib/gist.rb CHANGED
@@ -120,12 +120,19 @@ module Gist
120
120
 
121
121
  http.use_ssl = true
122
122
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
123
- http.cert = OpenSSL::X509::Certificate.new(ca_cert)
123
+ http.ca_file = ca_cert
124
124
 
125
125
  req = Net::HTTP::Post.new(url.path)
126
126
  req.form_data = data(files, private_gist)
127
127
 
128
- http.start{|h| h.request(req) }['Location']
128
+ response = http.start{|h| h.request(req) }
129
+ case response
130
+ when Net::HTTPRedirection
131
+ response['Location']
132
+ else
133
+ puts "Creating gist failed: #{response.code} #{response.message}"
134
+ exit(false)
135
+ end
129
136
  end
130
137
 
131
138
  # Given a gist id, returns its content.
@@ -182,7 +189,11 @@ private
182
189
  user = config("github.user")
183
190
  token = config("github.token")
184
191
 
185
- user.to_s.empty? ? {} : { :login => user, :token => token }
192
+ if user.to_s.empty? || token.to_s.empty?
193
+ {}
194
+ else
195
+ { :login => user, :token => token }
196
+ end
186
197
  end
187
198
 
188
199
  # Returns default values based on settings in your gitconfig. See
@@ -237,12 +248,16 @@ private
237
248
  end
238
249
 
239
250
  def ca_cert
240
- cert_path = File.join(File.dirname(__FILE__), "gist", "cacert.pem")
241
-
242
- if File.exists? cert_path
243
- File.read(cert_path)
251
+ cert_file = File.expand_path("../gist/cacert.pem", __FILE__)
252
+ if File.exist?(cert_file)
253
+ cert_file
254
+ elsif defined?(DATA)
255
+ require 'tempfile'
256
+ t = Tempfile.new("ca_cert")
257
+ t << DATA.read.split("__CACERT__").last
258
+ t.path
244
259
  else
245
- DATA.read.split("__CACERT__").last
260
+ raise "Couldn't find any CA certificates (tried #{cert_file})"
246
261
  end
247
262
  end
248
263
  end
data/lib/gist/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gist
2
- VERSION = Version = '2.0.2'
2
+ VERSION = Version = '2.0.3.pre'
3
3
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gist
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
5
- prerelease: false
4
+ hash: 961916008
5
+ prerelease: true
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
- - 2
10
- version: 2.0.2
9
+ - 3
10
+ - pre
11
+ version: 2.0.3.pre
11
12
  platform: ruby
12
13
  authors:
13
14
  - Chris Wanstrath
@@ -16,7 +17,7 @@ autorequire:
16
17
  bindir: bin
17
18
  cert_chain: []
18
19
 
19
- date: 2011-04-09 00:00:00 -07:00
20
+ date: 2011-04-28 00:00:00 -07:00
20
21
  default_executable:
21
22
  dependencies: []
22
23
 
@@ -62,12 +63,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
62
63
  required_rubygems_version: !ruby/object:Gem::Requirement
63
64
  none: false
64
65
  requirements:
65
- - - ">="
66
+ - - ">"
66
67
  - !ruby/object:Gem::Version
67
- hash: 3
68
+ hash: 25
68
69
  segments:
69
- - 0
70
- version: "0"
70
+ - 1
71
+ - 3
72
+ - 1
73
+ version: 1.3.1
71
74
  requirements: []
72
75
 
73
76
  rubyforge_project: