tags4free 0.1.1 → 0.1.2

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/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ === 0.1.2 / 2008-10-10
2
+
3
+ * Bugfix release
4
+
5
+ * Error handling corrected.
6
+
1
7
  === 0.1.1 / 2008-10-10
2
8
 
3
9
  * Minor Bugfix release
data/lib/tags_4_free.rb CHANGED
@@ -1,11 +1,12 @@
1
1
  module Tags4Free
2
2
  require 'rubygems'
3
+ require 'net/http'
3
4
  require 'httparty'
4
5
  include HTTParty
5
6
 
6
- VERSION = '0.1.1'
7
+ VERSION = '0.1.2'
7
8
 
8
- class YahooApiError < ArgumentError; end
9
+ class YahooApiError < StandardError; end
9
10
 
10
11
  class YahooApiFormatError < ArgumentError
11
12
  def initialize(content, result_set)
@@ -23,9 +24,12 @@ module Tags4Free
23
24
  #
24
25
  # tags = Tags4Free.for('The content that should be tagged')
25
26
  def self.for(content)
26
- result_set = get(SERVICE_URL, :query => {:appid => APPID, :context => content})
27
-
28
- raise YahooApiError.new(result_set['Error']['Message']) if result_set['Error']
27
+ begin
28
+ result_set = get(SERVICE_URL, :query => {:appid => APPID, :context => content})
29
+ rescue Net::HTTPServerException => e
30
+ raise YahooApiError
31
+ end
32
+
29
33
  raise YahooApiFormatError.new(content, result_set) unless result_set['ResultSet']
30
34
 
31
35
  result_set['ResultSet']['Result'] || []
data/spec/spec_helper.rb CHANGED
@@ -6,4 +6,4 @@ rescue LoadError
6
6
  require 'spec'
7
7
  end
8
8
 
9
- require File.join(File.dirname(__FILE__), '..', 'lib', 'tags4_free')
9
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'tags_4_free')
@@ -8,12 +8,13 @@ describe Tags4Free do
8
8
  end
9
9
 
10
10
  it "should raise an exception if Yahoo! reports an error" do
11
- Tags4Free.should_receive(:get).and_return({"Error"=>{"Message"=>"invalid value: context", "xmlns"=>"urn:yahoo:api"}})
11
+ def Tags4Free.get(*args)
12
+ raise Net::HTTPForbidden.new(403,'Forbidden','').error!
13
+ end
12
14
 
13
15
  begin
14
16
  Tags4Free.for("Erroneous content")
15
17
  rescue Tags4Free::YahooApiError => e
16
- e.message.should include('invalid value: context')
17
18
  else
18
19
  violated('YahooApiError should be raised!')
19
20
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tags4free
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Thorben Schr\xC3\xB6der"
metadata.gz.sig CHANGED
Binary file