marauder 0.1.1.1
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/CHANGELOG +0 -0
- data/Manifest +5 -0
- data/README.rdoc +25 -0
- data/Rakefile +15 -0
- data/lib/marauder.rb +59 -0
- data/marauder.gemspec +31 -0
- metadata +81 -0
data/CHANGELOG
ADDED
|
File without changes
|
data/Manifest
ADDED
data/README.rdoc
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
== Marauder
|
|
2
|
+
|
|
3
|
+
Wrapper for the Google Base product search API.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
== Install
|
|
7
|
+
|
|
8
|
+
gem install samueljamesbell-marauder --source http://gems.github.com
|
|
9
|
+
|
|
10
|
+
If you're using rails, create a file named marauder_config.yml the config directory, including the following:
|
|
11
|
+
|
|
12
|
+
api_key: YOUR GOOGLE BASE KEY
|
|
13
|
+
|
|
14
|
+
If not, create the config file anyway, and edit line 7 of marauder.rb to point to your config file.
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
== Getting Started
|
|
18
|
+
|
|
19
|
+
require 'Marauder'
|
|
20
|
+
|
|
21
|
+
Marauder.search(query)
|
|
22
|
+
|
|
23
|
+
Returns an array of OpenStruct objects with getters for all data provided by the Google Base.
|
|
24
|
+
|
|
25
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'rake'
|
|
3
|
+
require 'echoe'
|
|
4
|
+
|
|
5
|
+
Echoe.new('marauder', '0.1.1.1') do |p|
|
|
6
|
+
p.description = "Wrapper for the Google Base product search API."
|
|
7
|
+
p.url = "http://github.com/samueljamesbell/marauder"
|
|
8
|
+
p.author = "Sam Bell"
|
|
9
|
+
p.email = "samueljamesbell@gmail.com"
|
|
10
|
+
p.ignore_pattern = ["tmp/*", "script/*"]
|
|
11
|
+
p.development_dependencies = []
|
|
12
|
+
p.install_message = "Thanks for installing Marauder. Check the docs to get started."
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
data/lib/marauder.rb
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
module Marauder
|
|
2
|
+
require 'net/http'
|
|
3
|
+
require 'rexml/document'
|
|
4
|
+
require 'ostruct'
|
|
5
|
+
|
|
6
|
+
def self.search(query)
|
|
7
|
+
formatted_query = query.gsub(/[ ]/, '+')
|
|
8
|
+
url = "http://www.google.com/base/feeds/snippets?bq=#{formatted_query}"
|
|
9
|
+
xml_data = Net::HTTP.get_response(URI.parse(url)).body
|
|
10
|
+
|
|
11
|
+
doc = REXML::Document.new(xml_data)
|
|
12
|
+
|
|
13
|
+
entries = []
|
|
14
|
+
doc.elements.each('feed/entry') {|element| entries << element}
|
|
15
|
+
|
|
16
|
+
results = []
|
|
17
|
+
entries.each do |entry|
|
|
18
|
+
r = OpenStruct.new
|
|
19
|
+
entry.elements.each do |element|
|
|
20
|
+
if element.name == 'id'
|
|
21
|
+
r.google_id = entry.elements['id'].text
|
|
22
|
+
elsif element.name.gsub(/g:/,'') == 'author'
|
|
23
|
+
r.author_name = entry.elements['author'].elements['name'].text
|
|
24
|
+
else
|
|
25
|
+
m = element.name.gsub(/g:/,'').to_s
|
|
26
|
+
method = m + "="
|
|
27
|
+
r.send method.to_sym, element.text
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
results << r
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
return results
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.find_by_google_id(google_id)
|
|
37
|
+
xml_data = Net::HTTP.get_response(URI.parse(google_id)).body
|
|
38
|
+
doc = REXML::Document.new(xml_data)
|
|
39
|
+
|
|
40
|
+
r = OpenStruct.new
|
|
41
|
+
|
|
42
|
+
entry = doc.elements['entry']
|
|
43
|
+
|
|
44
|
+
entry.elements.each do |element|
|
|
45
|
+
if element.name == 'id'
|
|
46
|
+
r.google_id = entry.elements['id'].text
|
|
47
|
+
elsif element.name.gsub(/g:/,'') == 'author'
|
|
48
|
+
r.author_name = element.elements['name'].text
|
|
49
|
+
else
|
|
50
|
+
m = element.name.gsub(/g:/,'').to_s
|
|
51
|
+
method = m + "="
|
|
52
|
+
r.send method.to_sym, element.text
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
return r
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
end
|
data/marauder.gemspec
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |s|
|
|
4
|
+
s.name = %q{marauder}
|
|
5
|
+
s.version = "0.1.1.1"
|
|
6
|
+
|
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
|
8
|
+
s.authors = ["Sam Bell"]
|
|
9
|
+
s.date = %q{2010-07-21}
|
|
10
|
+
s.description = %q{Wrapper for the Google Base product search API.}
|
|
11
|
+
s.email = %q{samueljamesbell@gmail.com}
|
|
12
|
+
s.extra_rdoc_files = ["CHANGELOG", "README.rdoc", "lib/marauder.rb"]
|
|
13
|
+
s.files = ["CHANGELOG", "README.rdoc", "Rakefile", "lib/marauder.rb", "Manifest", "marauder.gemspec"]
|
|
14
|
+
s.homepage = %q{http://github.com/samueljamesbell/marauder}
|
|
15
|
+
s.post_install_message = %q{Thanks for installing Marauder. Check the docs to get started.}
|
|
16
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Marauder", "--main", "README.rdoc"]
|
|
17
|
+
s.require_paths = ["lib"]
|
|
18
|
+
s.rubyforge_project = %q{marauder}
|
|
19
|
+
s.rubygems_version = %q{1.3.7}
|
|
20
|
+
s.summary = %q{Wrapper for the Google Base product search API.}
|
|
21
|
+
|
|
22
|
+
if s.respond_to? :specification_version then
|
|
23
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
24
|
+
s.specification_version = 3
|
|
25
|
+
|
|
26
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
27
|
+
else
|
|
28
|
+
end
|
|
29
|
+
else
|
|
30
|
+
end
|
|
31
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: marauder
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
hash: 65
|
|
5
|
+
prerelease: false
|
|
6
|
+
segments:
|
|
7
|
+
- 0
|
|
8
|
+
- 1
|
|
9
|
+
- 1
|
|
10
|
+
- 1
|
|
11
|
+
version: 0.1.1.1
|
|
12
|
+
platform: ruby
|
|
13
|
+
authors:
|
|
14
|
+
- Sam Bell
|
|
15
|
+
autorequire:
|
|
16
|
+
bindir: bin
|
|
17
|
+
cert_chain: []
|
|
18
|
+
|
|
19
|
+
date: 2010-07-21 00:00:00 +01:00
|
|
20
|
+
default_executable:
|
|
21
|
+
dependencies: []
|
|
22
|
+
|
|
23
|
+
description: Wrapper for the Google Base product search API.
|
|
24
|
+
email: samueljamesbell@gmail.com
|
|
25
|
+
executables: []
|
|
26
|
+
|
|
27
|
+
extensions: []
|
|
28
|
+
|
|
29
|
+
extra_rdoc_files:
|
|
30
|
+
- CHANGELOG
|
|
31
|
+
- README.rdoc
|
|
32
|
+
- lib/marauder.rb
|
|
33
|
+
files:
|
|
34
|
+
- CHANGELOG
|
|
35
|
+
- README.rdoc
|
|
36
|
+
- Rakefile
|
|
37
|
+
- lib/marauder.rb
|
|
38
|
+
- Manifest
|
|
39
|
+
- marauder.gemspec
|
|
40
|
+
has_rdoc: true
|
|
41
|
+
homepage: http://github.com/samueljamesbell/marauder
|
|
42
|
+
licenses: []
|
|
43
|
+
|
|
44
|
+
post_install_message: Thanks for installing Marauder. Check the docs to get started.
|
|
45
|
+
rdoc_options:
|
|
46
|
+
- --line-numbers
|
|
47
|
+
- --inline-source
|
|
48
|
+
- --title
|
|
49
|
+
- Marauder
|
|
50
|
+
- --main
|
|
51
|
+
- README.rdoc
|
|
52
|
+
require_paths:
|
|
53
|
+
- lib
|
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
55
|
+
none: false
|
|
56
|
+
requirements:
|
|
57
|
+
- - ">="
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
hash: 3
|
|
60
|
+
segments:
|
|
61
|
+
- 0
|
|
62
|
+
version: "0"
|
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
|
+
none: false
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
hash: 11
|
|
69
|
+
segments:
|
|
70
|
+
- 1
|
|
71
|
+
- 2
|
|
72
|
+
version: "1.2"
|
|
73
|
+
requirements: []
|
|
74
|
+
|
|
75
|
+
rubyforge_project: marauder
|
|
76
|
+
rubygems_version: 1.3.7
|
|
77
|
+
signing_key:
|
|
78
|
+
specification_version: 3
|
|
79
|
+
summary: Wrapper for the Google Base product search API.
|
|
80
|
+
test_files: []
|
|
81
|
+
|