Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

cleanup/style from pull

  • Loading branch information...
commit 9b28c3c612b48cd9e71085e2b29cdd70d728e8af 1 parent 4c08485
Wesley Beary authored
Showing with 10 additions and 10 deletions.
  1. +1 −1  lib/googleajax.rb
  2. +9 −9 lib/googleajax/parser.rb
View
2  lib/googleajax.rb
@@ -2,7 +2,7 @@
require 'open-uri'
require 'ostruct'
require 'rubygems'
-require 'json' unless defined? Rails
+require 'json' unless defined?(Rails)
require 'googleajax/feed'
require 'googleajax/language'
View
18 lib/googleajax/parser.rb
@@ -2,16 +2,16 @@ class GoogleAjax
class Parser
def self.parse(api, method, data)
if defined? Rails
- data = ActiveSupport::JSON::decode(data)
+ data = ActiveSupport::JSON::decode(data)
else
- data = JSON.parse(data)
+ data = JSON.parse(data)
end
Errors.process(data)
parser = Parser::PARSERS[api][method]
parser.process(data['responseData'])
end
end
-
+
class FeedFind < Parser#:nodoc:
def self.process(data)
data['entries'].collect {|data| GoogleAjax::Feed::Feed.new(data)} if data
@@ -27,7 +27,7 @@ def self.process(data)
GoogleAjax::Feed::Feed.new(data) if data
end
end
-
+
class LanguageDetect < Parser#:nodoc
def self.process(data)
GoogleAjax::Language::Language.new(data) if data
@@ -38,7 +38,7 @@ def self.process(data)
GoogleAjax::Language::Translation.new(data) if data
end
end
-
+
class SearchBlogs < Parser#:nodoc
def self.process(data)
GoogleAjax::Search::Results.new(data) if data
@@ -53,7 +53,7 @@ class SearchImages < Parser#:nodoc
def self.process(data)
GoogleAjax::Search::Results.new(data) if data
end
- end
+ end
class SearchLocal < Parser#:nodoc
def self.process(data)
GoogleAjax::Search::Results.new(data) if data
@@ -63,7 +63,7 @@ class SearchNews < Parser#:nodoc
def self.process(data)
GoogleAjax::Search::Results.new(data) if data
end
- end
+ end
class SearchVideo < Parser#:nodoc
def self.process(data)
GoogleAjax::Search::Results.new(data) if data
@@ -74,7 +74,7 @@ def self.process(data)
GoogleAjax::Search::Results.new(data) if data
end
end
-
+
class Parser
PARSERS = {
:feed => { :find => FeedFind, :load => FeedLoad, :lookup => FeedLookup },
@@ -82,7 +82,7 @@ class Parser
:search => { :blogs => SearchBlogs, :books => SearchBooks, :images => SearchImages, :local => SearchLocal, :news => SearchNews, :video => SearchVideo, :web => SearchWeb }
}
end
-
+
class Errors
def self.process(data)
status = data['responseStatus']
Please sign in to comment.
Something went wrong with that request. Please try again.