gisty 0.0.17 → 0.0.18
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gisty.rb +26 -3
- metadata +4 -4
data/lib/gisty.rb
CHANGED
@@ -7,7 +7,7 @@ require 'nokogiri'
|
|
7
7
|
require 'net/https'
|
8
8
|
|
9
9
|
class Gisty
|
10
|
-
VERSION = '0.0.
|
10
|
+
VERSION = '0.0.18'
|
11
11
|
GIST_URL = 'https://gist.github.com/'
|
12
12
|
GISTY_URL = 'http://github.com/swdyh/gisty/tree/master'
|
13
13
|
|
@@ -26,7 +26,7 @@ class Gisty
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.extract url
|
29
|
-
doc = Nokogiri::HTML
|
29
|
+
doc = Nokogiri::HTML read_by_url(url)
|
30
30
|
{
|
31
31
|
:id => url.split('/').last,
|
32
32
|
:author => doc.css('#owner a').inner_text,
|
@@ -58,7 +58,7 @@ class Gisty
|
|
58
58
|
path = "/mine?page=1"
|
59
59
|
loop do
|
60
60
|
url = base_url + path + "&#{@auth_query}"
|
61
|
-
page =
|
61
|
+
page = read_by_url(url)
|
62
62
|
result << yield(url, page)
|
63
63
|
path = next_link page
|
64
64
|
break unless path
|
@@ -194,6 +194,29 @@ class Gisty
|
|
194
194
|
post params.merge(auth)
|
195
195
|
end
|
196
196
|
|
197
|
+
def read_by_url url
|
198
|
+
if @ssl_ca
|
199
|
+
url = URI.parse(url)
|
200
|
+
req = Net::HTTP::Get.new url.request_uri
|
201
|
+
https = Net::HTTP.new(url.host, url.port)
|
202
|
+
https.use_ssl = true
|
203
|
+
https.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
204
|
+
https.verify_depth = 5
|
205
|
+
https.ca_file = @ssl_ca
|
206
|
+
res = https.start {|http| http.request(req) }
|
207
|
+
case res
|
208
|
+
when Net::HTTPSuccess
|
209
|
+
res.body
|
210
|
+
when Net::HTTPRedirection
|
211
|
+
read_by_url res['Location']
|
212
|
+
else
|
213
|
+
raise 'get failure'
|
214
|
+
end
|
215
|
+
else
|
216
|
+
open(url).read
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
197
220
|
# `figlet -f contributed/bdffonts/clb8x8.flf gisty`.gsub('#', 'm')
|
198
221
|
AA = <<-EOS
|
199
222
|
mm mm
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gisty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 18
|
10
|
+
version: 0.0.18
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- swdyh
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-01-24 00:00:00 +09:00
|
19
19
|
default_executable: gisty
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|