swdyh-gisty 0.0.11 → 0.0.12
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.
- data/lib/gisty.rb +10 -3
- data/test/gisty_test.rb +10 -0
- metadata +3 -2
data/lib/gisty.rb
CHANGED
@@ -5,7 +5,7 @@ require 'rubygems'
|
|
5
5
|
require 'nokogiri'
|
6
6
|
|
7
7
|
class Gisty
|
8
|
-
VERSION = '0.0.
|
8
|
+
VERSION = '0.0.12'
|
9
9
|
GIST_URL = 'http://gist.github.com/'
|
10
10
|
GISTY_URL = 'http://github.com/swdyh/gisty/tree/master'
|
11
11
|
|
@@ -15,6 +15,9 @@ class Gisty
|
|
15
15
|
class InvalidFileException < Exception
|
16
16
|
end
|
17
17
|
|
18
|
+
class PostFailureException < Exception
|
19
|
+
end
|
20
|
+
|
18
21
|
def self.extract_ids str
|
19
22
|
doc = Nokogiri::HTML str
|
20
23
|
doc.css('.file .info a').map { |i| i['href'].sub('/', '') }
|
@@ -146,8 +149,12 @@ class Gisty
|
|
146
149
|
|
147
150
|
def post params
|
148
151
|
url = URI.parse('http://gist.github.com/gists')
|
149
|
-
|
150
|
-
|
152
|
+
res = Net::HTTP.post_form(url, params)
|
153
|
+
if res['Location']
|
154
|
+
res['Location']
|
155
|
+
else
|
156
|
+
raise PostFailureException, res.inspect
|
157
|
+
end
|
151
158
|
end
|
152
159
|
|
153
160
|
def build_params paths
|
data/test/gisty_test.rb
CHANGED
@@ -161,5 +161,15 @@ class GistyTest < Test::Unit::TestCase
|
|
161
161
|
path2 = File.join('test', 'fixtures', 'bar.user.js')
|
162
162
|
@gisty.create [path1, path2]
|
163
163
|
end
|
164
|
+
|
165
|
+
def test_post_failure
|
166
|
+
stub(Net::HTTP).post_form do |uri, opt|
|
167
|
+
Net::HTTPClientError.new 'foo', 'bar', 'baz'
|
168
|
+
end
|
169
|
+
path = File.join('test', 'fixtures', 'foo.user.js')
|
170
|
+
assert_raise Gisty::PostFailureException do
|
171
|
+
@gisty.create path
|
172
|
+
end
|
173
|
+
end
|
164
174
|
end
|
165
175
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swdyh-gisty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- swdyh
|
@@ -9,11 +9,12 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-05-08 00:00:00 -07:00
|
13
13
|
default_executable: gisty
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|
17
|
+
type: :runtime
|
17
18
|
version_requirement:
|
18
19
|
version_requirements: !ruby/object:Gem::Requirement
|
19
20
|
requirements:
|