overlord 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +3 -3
- data/VERSION +1 -1
- data/lib/overlord/google_base.rb +18 -3
- data/overlord.gemspec +2 -2
- data/test/rails_root/config/global_config.yml +1 -1
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -16,7 +16,7 @@ In case it doesn't install dependencies:
|
|
16
16
|
|
17
17
|
=== Settings
|
18
18
|
This gem requires some configuration before it will work in your Rails application:
|
19
|
-
You will need a global_config file with 'google_ajax_api_key' and '
|
19
|
+
You will need a global_config file with 'google_ajax_api_key' and 'request_referer' defined. You can set it up thus:
|
20
20
|
|
21
21
|
# Load a global constant so the initializers can use them
|
22
22
|
require 'ostruct'
|
@@ -42,11 +42,11 @@ Then in global_config.yml:
|
|
42
42
|
|
43
43
|
# Google related
|
44
44
|
google_ajax_api_key: # Google ajax api key
|
45
|
-
|
45
|
+
request_referer: # Website making the request. Required by Google.
|
46
46
|
show_google_search: true # Determines whether or not a google search is displayed on the topic page
|
47
47
|
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
|
48
48
|
combine_feeds_on_server: false # Combines feeds loaded on the server
|
49
|
-
|
49
|
+
|
50
50
|
production:
|
51
51
|
<<: *DEFAULT
|
52
52
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.7
|
data/lib/overlord/google_base.rb
CHANGED
@@ -27,13 +27,20 @@ module Overlord
|
|
27
27
|
query_options[:key] = key if key
|
28
28
|
query_options
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
|
+
# Gets and parses json from a given url
|
32
|
+
# uri: Uri from which to obtain json
|
33
|
+
# options: Options to be sent
|
34
|
+
# :query - query
|
35
|
+
# :headers - headers
|
31
36
|
def self.get(uri, options)
|
32
37
|
header_params = { "UserAgent" => "Ruby/#{RUBY_VERSION}" }
|
33
|
-
ref = self.referer || GlobalConfig.
|
38
|
+
ref = self.referer || GlobalConfig.request_referer rescue nil
|
34
39
|
header_params["Referer"] = ref if ref
|
40
|
+
header_params = header_params.merge(options[:headers]) if options[:headers]
|
35
41
|
# to_params comes from the httparty gem
|
36
|
-
|
42
|
+
params = "?#{options[:query].to_params}" if options[:query]
|
43
|
+
buffer = open("#{uri}#{params}", header_params).read
|
37
44
|
|
38
45
|
# Try the standard parser
|
39
46
|
begin
|
@@ -52,6 +59,14 @@ module Overlord
|
|
52
59
|
{}
|
53
60
|
end
|
54
61
|
|
62
|
+
def self.parse_name(name)
|
63
|
+
return '' if name.blank?
|
64
|
+
names = name.split(' ')
|
65
|
+
return '' if names.length <= 0
|
66
|
+
return [names[0], names[0]] if names.length == 1
|
67
|
+
[names[0], names.slice(1, names.length).join(' ')]
|
68
|
+
end
|
69
|
+
|
55
70
|
end
|
56
71
|
|
57
72
|
|
data/overlord.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
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.7"
|
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-23}
|
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 = [
|
@@ -15,7 +15,7 @@ default: &DEFAULT
|
|
15
15
|
|
16
16
|
# Google related
|
17
17
|
google_ajax_api_key: # A google ajax api key - http://code.google.com/apis/ajaxsearch/signup.html
|
18
|
-
|
18
|
+
request_referer: # The url of the site making the request.
|
19
19
|
show_google_search: true # Determines whether or not a google search is displayed on the topic page
|
20
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
|
21
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Ball
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-12-
|
13
|
+
date: 2009-12-23 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|