google_set 0.1.0 → 0.2.0

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/README.rdoc CHANGED
@@ -4,9 +4,14 @@ Simple API for {Google Sets}[http://labs.google.com/sets]
4
4
 
5
5
  == Usage
6
6
 
7
+ >> require 'google_set'
7
8
  >> GoogleSet.for("orange", "apple")
8
9
  => ["apple", "orange", "chocolate", "strawberry", "cherry", "lemon", "vanilla", "sweet", "banana", "blended", "raspberry", "grape", "pear", "cinnamon", "caramel", "lime", "mint", "coconut", "blueberry", "almond", "assorted", "peanut", "mango", "blackberry", "apricot", "organic", "peach", "pineapple", "dry", "chipped", "watermelon", "kiwi", "papaya", "soy", "roasted", "pomegranate", "salted", "lychee", "citrus", "tamarind"]
9
10
 
11
+ == Installation
12
+
13
+ sudo gem install google_set
14
+
10
15
  == Acknowledgements
11
16
  Based on {bjeanes}[http://github.com/bjeanes] similar gem {google_sets}[http://github.com/bjeanes/google-sets/]
12
17
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
data/google_set.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{google_set}
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Daniel Cadenas"]
12
- s.date = %q{2010-01-22}
12
+ s.date = %q{2010-02-20}
13
13
  s.description = %q{Simple API for Google Sets}
14
14
  s.email = %q{dev+dcadenas@cuboxsa.com}
15
15
  s.extra_rdoc_files = [
data/lib/google_set.rb CHANGED
@@ -1,14 +1,24 @@
1
1
  require 'open-uri'
2
2
  require 'cgi'
3
-
3
+
4
4
  class GoogleSet
5
+ class Error < StandardError
6
+ attr_accessor :wrapped_exception
7
+ def initialize(ex)
8
+ @wrapped_exception = ex
9
+ set_backtrace(ex.backtrace)
10
+ end
11
+ end
12
+
5
13
  def self.for(*terms)
6
14
  path = "http://labs.google.com/sets?&#{query_string(*terms)}"
7
15
  result = open(path).read
8
16
  result.scan(%r{<a href="http://www\.google\.com/search\?hl=en&amp;q=[^"]+">(.*?)</a>}).map {|i| i.to_s}
17
+ rescue StandardError => e
18
+ raise GoogleSet::Error.new(e)
9
19
  end
10
20
 
11
- private
21
+ private
12
22
  def self.query_string(*terms)
13
23
  params = terms.inject({}) do |hash, term|
14
24
  hash["q#{hash.size + 1}"] = term
@@ -8,4 +8,9 @@ describe "GoogleSet" do
8
8
  it "should return nothing if no elements are specified" do
9
9
  GoogleSet.for().should be_empty
10
10
  end
11
+
12
+ it "should raise a GoogleSet::Error exception on failure to read from google sets" do
13
+ GoogleSet.stub!(:open).and_raise(StandardError)
14
+ lambda{GoogleSet.for("apple", "orange")}.should raise_error GoogleSet::Error
15
+ end
11
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_set
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Cadenas
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-22 00:00:00 -02:00
12
+ date: 2010-02-20 00:00:00 -02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency