aub-gemfeed 0.1.0 → 0.1.3
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/gemfeed.rb +20 -16
- metadata +1 -1
data/lib/gemfeed.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Gemfeed
|
2
2
|
|
3
|
-
GEMFEED_URL = 'http://
|
3
|
+
GEMFEED_URL = 'http://gemfeed.com'
|
4
4
|
|
5
5
|
class GemfeedLoginError < StandardError; end;
|
6
6
|
|
@@ -61,23 +61,27 @@ module Gemfeed
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def self.make_request(url, req, gem_name, &block)
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
64
|
+
begin
|
65
|
+
res = Net::HTTP.new(url.host, url.port).start { |http| http.request(req) }
|
66
|
+
case res
|
67
|
+
when Net::HTTPSuccess
|
68
|
+
block.call(res.body)
|
69
|
+
when Net::HTTPUnauthorized:
|
70
|
+
print_unauthorized_error
|
71
|
+
when Net::HTTPClientError:
|
72
|
+
doc = REXML::Document.new(res.body)
|
73
|
+
doc.elements.each('errors/error') do |error|
|
74
|
+
if error.text == 'User has already been taken'
|
75
|
+
puts "!!! You are already subscribed to #{gem_name} on gemfeed."
|
76
|
+
elsif error.text == 'Package can\'t be blank'
|
77
|
+
puts "!!! Gemfeed cannot find the gem #{gem_name}"
|
78
|
+
end
|
77
79
|
end
|
80
|
+
else
|
81
|
+
puts '!!! There was a server error while subscribing you to this gem on gemfeed.'
|
78
82
|
end
|
79
|
-
|
80
|
-
puts '!!! There was
|
83
|
+
rescue Errno::ECONNREFUSED
|
84
|
+
puts '!!! There was an error when connecting to the server.'
|
81
85
|
end
|
82
86
|
end
|
83
87
|
|