overlord 0.1.4 → 0.1.5
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/LICENSE +1 -1
- data/README.rdoc +10 -4
- data/Rakefile +2 -1
- data/VERSION +1 -1
- data/lib/overlord.rb +4 -1
- data/lib/overlord/google_base.rb +43 -0
- data/lib/overlord/google_feed_request.rb +3 -19
- data/lib/overlord/google_search_request.rb +1 -17
- data/overlord.gemspec +12 -7
- data/test/rails_root/config/environment.rb +1 -0
- data/test/rails_root/config/global_config.yml +2 -1
- metadata +14 -3
data/LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -1,13 +1,18 @@
|
|
1
1
|
= overlord
|
2
2
|
|
3
3
|
Talk to the Google ajax apis and render the results. This gem contains several method calls and partials to call
|
4
|
-
out to the Google Ajax Apis (http://code.google.com/apis/ajax/).
|
4
|
+
out to the Google Ajax Apis (http://code.google.com/apis/ajax/). This gem is designed to work in Ruby on Rails and
|
5
|
+
currently won't work outside that framework.
|
5
6
|
|
6
7
|
== Usage
|
7
8
|
|
9
|
+
=== Installation
|
10
|
+
Installing the gem should install the dependencies
|
11
|
+
sudo gem install overlord
|
12
|
+
|
8
13
|
=== Settings
|
9
14
|
This gem requires some configuration before it will work in your Rails application:
|
10
|
-
You will need a global_config file with 'google_ajax_api_key' defined. You can set it up thus:
|
15
|
+
You will need a global_config file with 'google_ajax_api_key' and 'google_ajax_referer' defined. You can set it up thus:
|
11
16
|
|
12
17
|
# Load a global constant so the initializers can use them
|
13
18
|
require 'ostruct'
|
@@ -32,7 +37,8 @@ Then in global_config.yml:
|
|
32
37
|
session_secret: 882585c5d472d21e832965410ab233be541ea626e50ed0eb68a00a2f49b59073480e58599404e3dc62105a803ee42d67872e3f95eb48e2d6508b42038436abd6
|
33
38
|
|
34
39
|
# Google related
|
35
|
-
google_ajax_api_key:
|
40
|
+
google_ajax_api_key: # Google ajax api key
|
41
|
+
google_ajax_referer: # Website making the request. Required by Google.
|
36
42
|
show_google_search: true # Determines whether or not a google search is displayed on the topic page
|
37
43
|
load_feeds_on_server: false # Determines whether feeds on a topic page are loaded on the server or the client. Loading on the server can take a while
|
38
44
|
combine_feeds_on_server: false # Combines feeds loaded on the server
|
@@ -113,4 +119,4 @@ inside of the test directory for more information on how to create these classes
|
|
113
119
|
|
114
120
|
== Copyright
|
115
121
|
|
116
|
-
Copyright (c) 2009 Tatemae. See LICENSE for details.
|
122
|
+
Copyright (c) 2009 Tatemae.com. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -12,7 +12,8 @@ begin
|
|
12
12
|
gem.email = "justin@tatemae.com"
|
13
13
|
gem.homepage = "http://github.com/jbasdf/overlord"
|
14
14
|
gem.authors = ["Justin Ball", "Joel Duffin"]
|
15
|
-
gem.
|
15
|
+
gem.add_dependency "httparty"
|
16
|
+
gem.add_development_dependency "shoulda"
|
16
17
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
18
|
end
|
18
19
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
data/lib/overlord.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'json'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'overlord/google_base'
|
4
|
+
require 'overlord/google_search_request'
|
2
5
|
require 'overlord/google_feed_request'
|
3
6
|
|
4
7
|
I18n.load_path += Dir[ File.join(File.dirname(__FILE__), '..', 'locales', '*.{rb,yml}') ]
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Overlord
|
2
|
+
|
3
|
+
class GoogleBase
|
4
|
+
|
5
|
+
# api_key_id: Valid Google access key (optional)
|
6
|
+
def self.api_key_id=(val)
|
7
|
+
@api_key_id = val
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.api_key_id
|
11
|
+
@api_key_id
|
12
|
+
end
|
13
|
+
|
14
|
+
# referer: Url of the website making request. Required by Google.
|
15
|
+
def self.referer=(val)
|
16
|
+
@referer = val
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.referer
|
20
|
+
@referer
|
21
|
+
end
|
22
|
+
|
23
|
+
# Add standard items to the google query
|
24
|
+
def self.build_google_query(query_options)
|
25
|
+
key = self.api_key_id || GlobalConfig.google_ajax_api_key rescue ''
|
26
|
+
query_options[:v] = '1.0'
|
27
|
+
query_options[:key] = key if key
|
28
|
+
query_options
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.get(uri, options)
|
32
|
+
header_params = { "UserAgent" => "Ruby/#{RUBY_VERSION}" }
|
33
|
+
ref = self.referer || GlobalConfig.google_ajax_referer rescue nil
|
34
|
+
header_params["Referer"] = ref if ref
|
35
|
+
# to_params comes from the httparty gem
|
36
|
+
buffer = open("#{uri}?#{options[:query].to_params}", header_params).read
|
37
|
+
JSON.parse(buffer)
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
end
|
@@ -5,17 +5,8 @@ module Overlord
|
|
5
5
|
# Google code playground:
|
6
6
|
# http://code.google.com/apis/ajax/playground/?exp=search#load_feed
|
7
7
|
#
|
8
|
-
class GoogleFeedRequest
|
9
|
-
|
10
|
-
format :json
|
11
|
-
|
12
|
-
# Initialize Google Request.
|
13
|
-
# Parameters:
|
14
|
-
# api_key_id: Valid Google access key (optional)
|
15
|
-
def initialize(api_key_id = nil)
|
16
|
-
@api_key_id = api_key_id
|
17
|
-
end
|
18
|
-
|
8
|
+
class GoogleFeedRequest < GoogleBase
|
9
|
+
|
19
10
|
# Lookup a given feed.
|
20
11
|
def self.lookup_feed(uri)
|
21
12
|
get('http://ajax.googleapis.com/ajax/services/feed/lookup', :query => build_google_query({:q => uri}))
|
@@ -104,13 +95,6 @@ module Overlord
|
|
104
95
|
:service_id => Service.find_service_by_uri(google_feed['link']).id)
|
105
96
|
end
|
106
97
|
end
|
107
|
-
|
108
|
-
# Add standard items to the google query
|
109
|
-
def self.build_google_query(query_options)
|
110
|
-
query_options[:v] = '1.0'
|
111
|
-
query_options[:key] = GlobalConfig.google_ajax_api_key if GlobalConfig.google_ajax_api_key
|
112
|
-
query_options
|
113
|
-
end
|
114
|
-
|
98
|
+
|
115
99
|
end
|
116
100
|
end
|
@@ -5,16 +5,7 @@ module Overlord
|
|
5
5
|
# Google code playground:
|
6
6
|
# http://code.google.com/apis/ajax/playground
|
7
7
|
#
|
8
|
-
class GoogleSearchRequest
|
9
|
-
include HTTParty
|
10
|
-
format :json
|
11
|
-
|
12
|
-
# Initialize Google Request.
|
13
|
-
# Parameters:
|
14
|
-
# api_key_id: Valid Google access key (optional)
|
15
|
-
def initialize(api_key_id = nil)
|
16
|
-
@api_key_id = api_key_id
|
17
|
-
end
|
8
|
+
class GoogleSearchRequest < GoogleBase
|
18
9
|
|
19
10
|
# Run a local search
|
20
11
|
# Google docs:
|
@@ -73,13 +64,6 @@ module Overlord
|
|
73
64
|
end
|
74
65
|
end
|
75
66
|
end
|
76
|
-
|
77
|
-
# Add standard items to the google query
|
78
|
-
def self.build_google_query(query_options)
|
79
|
-
query_options[:v] = '1.0'
|
80
|
-
query_options[:key] = GlobalConfig.google_ajax_api_key if GlobalConfig.google_ajax_api_key
|
81
|
-
query_options
|
82
|
-
end
|
83
67
|
|
84
68
|
end
|
85
69
|
end
|
data/overlord.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{overlord}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Justin Ball", "Joel Duffin"]
|
12
|
-
s.date = %q{2009-12-
|
12
|
+
s.date = %q{2009-12-08}
|
13
13
|
s.description = %q{Code to interact with the google ajax apis on the server and the client.}
|
14
14
|
s.email = %q{justin@tatemae.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -34,6 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
"app/views/google/_search.html.erb",
|
35
35
|
"app/views/google/_slide_show.html.erb",
|
36
36
|
"lib/overlord.rb",
|
37
|
+
"lib/overlord/google_base.rb",
|
37
38
|
"lib/overlord/google_feed_request.rb",
|
38
39
|
"lib/overlord/google_search_request.rb",
|
39
40
|
"locales/ar.yml",
|
@@ -680,11 +681,15 @@ Gem::Specification.new do |s|
|
|
680
681
|
s.specification_version = 3
|
681
682
|
|
682
683
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
683
|
-
s.
|
684
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0"])
|
685
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
684
686
|
else
|
685
|
-
s.add_dependency(%q<
|
687
|
+
s.add_dependency(%q<httparty>, [">= 0"])
|
688
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
686
689
|
end
|
687
690
|
else
|
688
|
-
s.add_dependency(%q<
|
691
|
+
s.add_dependency(%q<httparty>, [">= 0"])
|
692
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
689
693
|
end
|
690
694
|
end
|
695
|
+
|
@@ -14,7 +14,8 @@ default: &DEFAULT
|
|
14
14
|
session_secret: 882585c5d472d21e832965410ab233be541ea626e50ed0eb68a00a2f49b59073480e58599404e3dc62105a803ee42d67872e3f95eb48e2d6508b42038436abd6
|
15
15
|
|
16
16
|
# Google related
|
17
|
-
google_ajax_api_key:
|
17
|
+
google_ajax_api_key: # A google ajax api key - http://code.google.com/apis/ajaxsearch/signup.html
|
18
|
+
google_ajax_referer: # The url of the site making the request.
|
18
19
|
show_google_search: true # Determines whether or not a google search is displayed on the topic page
|
19
20
|
load_feeds_on_server: false # Determines whether feeds on a topic page are loaded on the server or the client. Loading on the server can take a while
|
20
21
|
combine_feeds_on_server: false # Combines feeds loaded on the server
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: overlord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Ball
|
@@ -10,11 +10,21 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-12-
|
13
|
+
date: 2009-12-08 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
|
-
name:
|
17
|
+
name: httparty
|
18
|
+
type: :runtime
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
version:
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: shoulda
|
18
28
|
type: :development
|
19
29
|
version_requirement:
|
20
30
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -50,6 +60,7 @@ files:
|
|
50
60
|
- app/views/google/_search.html.erb
|
51
61
|
- app/views/google/_slide_show.html.erb
|
52
62
|
- lib/overlord.rb
|
63
|
+
- lib/overlord/google_base.rb
|
53
64
|
- lib/overlord/google_feed_request.rb
|
54
65
|
- lib/overlord/google_search_request.rb
|
55
66
|
- locales/ar.yml
|