bing-helper 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +9 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +36 -0
- data/LICENSE +20 -0
- data/README.md +36 -0
- data/Rakefile +10 -0
- data/bing-helper.gemspec +27 -0
- data/lib/bing-helper.rb +2 -0
- data/lib/bing-helper/bing.rb +102 -0
- data/lib/bing-helper/response.rb +26 -0
- data/lib/bing-helper/version.rb +3 -0
- data/spec/bing_helper_bing_spec.rb +55 -0
- data/spec/bing_helper_response_spec.rb +352 -0
- data/spec/spec_helper.rb +5 -0
- metadata +106 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
bing-helper (0.0.1)
|
5
|
+
faraday (>= 0.7.5)
|
6
|
+
yajl-ruby (~> 1.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.2.6)
|
12
|
+
diff-lcs (1.1.3)
|
13
|
+
faraday (0.7.5)
|
14
|
+
addressable (~> 2.2.6)
|
15
|
+
multipart-post (~> 1.1.3)
|
16
|
+
rack (>= 1.1.0, < 2)
|
17
|
+
multipart-post (1.1.4)
|
18
|
+
rack (1.3.5)
|
19
|
+
rake (0.9.2.2)
|
20
|
+
rspec (2.7.0)
|
21
|
+
rspec-core (~> 2.7.0)
|
22
|
+
rspec-expectations (~> 2.7.0)
|
23
|
+
rspec-mocks (~> 2.7.0)
|
24
|
+
rspec-core (2.7.1)
|
25
|
+
rspec-expectations (2.7.0)
|
26
|
+
diff-lcs (~> 1.1.2)
|
27
|
+
rspec-mocks (2.7.0)
|
28
|
+
yajl-ruby (1.1.0)
|
29
|
+
|
30
|
+
PLATFORMS
|
31
|
+
ruby
|
32
|
+
|
33
|
+
DEPENDENCIES
|
34
|
+
bing-helper!
|
35
|
+
rake
|
36
|
+
rspec
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 VarioLabs, Inc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# bing-helper - WORK IN PROGRESS
|
2
|
+
|
3
|
+
Thin wrapper for bing API options. Needed a flexible library that would let me plug in different HTTP options seamlessly while being eminently lazy. The gem has two primary purposes:
|
4
|
+
|
5
|
+
1. Build the query string & URL
|
6
|
+
2. Parse the response
|
7
|
+
|
8
|
+
That's all I need, and that's what it does.
|
9
|
+
|
10
|
+
Portions taken from our fork of Mike Demers's RBing library.
|
11
|
+
|
12
|
+
This client is for non-map API calls for now.
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
It's a pretty simple client:
|
17
|
+
|
18
|
+
@bing = BingHelper::Bing.new("YOUR API KEY")
|
19
|
+
results = @bing.web("ruby")
|
20
|
+
puts "Got #{results["SearchResponse"]["Web"]["Results"].length} results"
|
21
|
+
|
22
|
+
## Testing Notes
|
23
|
+
|
24
|
+
To test this, please create a `spec/test-key.rb` file that looks like
|
25
|
+
this:
|
26
|
+
|
27
|
+
module BingHelper
|
28
|
+
TEST_KEY="<YOUR BING API KEY HERE>"
|
29
|
+
end
|
30
|
+
|
31
|
+
You need your Bing API key in order to execute some of the tests. This
|
32
|
+
way, the key doesn't need to be checked in.
|
33
|
+
|
34
|
+
----
|
35
|
+
|
36
|
+
See the LICENSE file for licensing details.
|
data/Rakefile
ADDED
data/bing-helper.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "bing-helper/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "bing-helper"
|
7
|
+
s.version = BingHelper::VERSION
|
8
|
+
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.authors = ["Sujal Shah"]
|
11
|
+
s.email = ["codesujal@gmail.com"]
|
12
|
+
s.homepage = "https://github.com/VarioLabs/bing-helper"
|
13
|
+
s.summary = "Bing search API client for EM-Synchrony using Faraday"
|
14
|
+
s.description = s.summary
|
15
|
+
s.rubyforge_project = "bing-helper"
|
16
|
+
|
17
|
+
s.add_dependency "faraday", ">= 0.7.5"
|
18
|
+
s.add_dependency 'yajl-ruby', '~> 1.0'
|
19
|
+
|
20
|
+
s.add_development_dependency "rspec"
|
21
|
+
s.add_development_dependency "rake"
|
22
|
+
|
23
|
+
s.files = `git ls-files`.split("\n")
|
24
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
25
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
26
|
+
s.require_paths = ["lib"]
|
27
|
+
end
|
data/lib/bing-helper.rb
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'yajl'
|
2
|
+
require 'faraday'
|
3
|
+
|
4
|
+
module BingHelper
|
5
|
+
class Bing
|
6
|
+
|
7
|
+
attr_accessor :instance_options
|
8
|
+
attr_reader :faraday_client
|
9
|
+
attr_reader :base_url
|
10
|
+
|
11
|
+
API_URL="http://api.search.live.net/json.aspx"
|
12
|
+
|
13
|
+
BASE_OPTIONS = [:version, :market, :adult, :query, :appid, :sources]
|
14
|
+
|
15
|
+
# Query Keywords: <http://help.live.com/help.aspx?project=wl_searchv1&market=en-US&querytype=keyword&query=redliub&tmt=&domain=www.bing.com:80>
|
16
|
+
#
|
17
|
+
QUERY_KEYWORDS = [:site, :language, :contains, :filetype, :inanchor, :inbody, :intitle, :ip, :loc, :location, :prefer, :feed, :hasfeed, :url]
|
18
|
+
|
19
|
+
# Source Types: <http://msdn.microsoft.com/en-us/library/dd250847.aspx>
|
20
|
+
#
|
21
|
+
SOURCES = %w(Ad Image InstantAnswer News Phonebook RelatedSearch Spell Web)
|
22
|
+
|
23
|
+
# Set up methods for each search source:
|
24
|
+
# +ad+, +image+, +instant_answer+, +news+, +phonebook+, +related_search+,
|
25
|
+
# +spell+ and +web+
|
26
|
+
#
|
27
|
+
# Example:
|
28
|
+
#
|
29
|
+
# bing = RBing.new(YOUR_APP_ID)
|
30
|
+
# bing.web("ruby gems", :count => 10)
|
31
|
+
#
|
32
|
+
SOURCES.each do |source|
|
33
|
+
fn = source.to_s.gsub(/[a-z][A-Z]/) {|c| "#{c[0,1]}_#{c[1,1]}" }.downcase
|
34
|
+
class_eval "def #{fn}(query, options={}) ; search('#{source}', query, options) ; end"
|
35
|
+
class_eval "def #{fn}_search_url(query, options={}) ; query_params_for('#{source}', query, options) ; end"
|
36
|
+
end
|
37
|
+
|
38
|
+
def search(source, query, options={})
|
39
|
+
response = self.faraday_client.get do |req|
|
40
|
+
req.url "", query_params_for(source, query, options)
|
41
|
+
end
|
42
|
+
begin
|
43
|
+
Response.new(Yajl::Parser.new.parse(response.body))
|
44
|
+
rescue
|
45
|
+
nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def query_params_for(source, query, options)
|
50
|
+
|
51
|
+
final_options = self.instance_options.merge({:sources=>source, :query=>build_query(query, options)})
|
52
|
+
final_options.merge(clean_options(options))
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
def initialize(app_id, options={})
|
57
|
+
self.instance_options = options.merge(:AppId=>app_id)
|
58
|
+
end
|
59
|
+
|
60
|
+
def faraday_client
|
61
|
+
@faraday_client ||= Faraday.new(:url => API_URL) do |builder|
|
62
|
+
builder.request :url_encoded
|
63
|
+
builder.request :json
|
64
|
+
builder.response :logger if ENV["RACK_ENV"] && ENV["RACK_ENV"] == 'development'
|
65
|
+
builder.adapter ((defined?(EM::Synchrony) && EM.reactor_running? ) ? :em_synchrony : :net_http)
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
def base_url
|
71
|
+
return API_URL
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def clean_options(options)
|
78
|
+
options.select do |k,v|
|
79
|
+
k != :query && k != :sources && BASE_OPTIONS.include?(k)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# constructs a query string for the given
|
84
|
+
# +query+ and the optional query +options+
|
85
|
+
#
|
86
|
+
def build_query(query, options={})
|
87
|
+
queries = []
|
88
|
+
QUERY_KEYWORDS.each do |kw|
|
89
|
+
next unless options[kw]
|
90
|
+
if options[kw].is_a? Array
|
91
|
+
kw_query = options[kw].map {|s| "#{kw}:#{s}".strip }.join(" OR ")
|
92
|
+
queries << " (#{kw_query})"
|
93
|
+
else
|
94
|
+
queries << " #{kw}:#{options[kw]}"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
"#{query} #{queries.join(' ')}".strip
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module BingHelper
|
2
|
+
class Response
|
3
|
+
|
4
|
+
attr_reader :raw_response
|
5
|
+
|
6
|
+
BingHelper::Bing::SOURCES.each do |source|
|
7
|
+
fn = source.to_s.gsub(/[a-z][A-Z]/) {|c| "#{c[0,1]}_#{c[1,1]}" }.downcase
|
8
|
+
class_eval "def #{fn}_results; @#{fn}_results ||= raw_response['SearchResponse']['#{source}']['Results']; end"
|
9
|
+
class_eval "def #{fn}_results_offset; @#{fn}_results_offset ||= raw_response['SearchResponse']['#{source}']['Offset']; end"
|
10
|
+
class_eval "def #{fn}_total; @#{fn}_total ||= raw_response['SearchResponse']['#{source}']['Total']; end"
|
11
|
+
end
|
12
|
+
|
13
|
+
def version
|
14
|
+
@version ||= raw_response["SearchResponse"]["Version"]
|
15
|
+
end
|
16
|
+
|
17
|
+
def query
|
18
|
+
@query ||= raw_response["SearchResponse"]["Query"]
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(response)
|
22
|
+
@raw_response = response
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BingHelper::Bing do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@bing = BingHelper::Bing.new(BingHelper::TEST_KEY)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should provide an ad search method" do
|
10
|
+
@bing.should respond_to(:ad)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should provide an image search method" do
|
14
|
+
@bing.should respond_to(:image)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should provide an instant_answer search method" do
|
18
|
+
@bing.should respond_to(:instant_answer)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should provide a news search method" do
|
22
|
+
@bing.should respond_to(:news)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should provide a phonebook search method" do
|
26
|
+
@bing.should respond_to(:phonebook)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should provide a related_search method" do
|
30
|
+
@bing.should respond_to(:related_search)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should provide an spell method" do
|
34
|
+
@bing.should respond_to(:spell)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should provide a web search method" do
|
38
|
+
@bing.should respond_to(:web)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should return a Hash object" do
|
42
|
+
@bing.web("ruby").should be_a(BingHelper::Response)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should return search results" do
|
46
|
+
@bing.web("ruby").web_results.should_not be_empty
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should return a proper query hash for a basic query" do
|
50
|
+
@bing.web_search_url("ruby").should == {:AppId=>"677F875FA3B101E68C6D516EFFF88B95444E63E1", :sources=>"Web", :query=>"ruby"}
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,352 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe BingHelper::Response do
|
5
|
+
|
6
|
+
it "should have properly line up a web response" do
|
7
|
+
@web_response.web_total.should == 1830000
|
8
|
+
@web_response.web_results.should_not be_empty
|
9
|
+
@web_response.web_results.length.should == 1
|
10
|
+
@web_response.web_results_offset.should == 0
|
11
|
+
@web_response.version.should == "2.2"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have properly line up a image response" do
|
15
|
+
@image_response.image_total.should == 1980000
|
16
|
+
@image_response.image_results.should_not be_empty
|
17
|
+
@image_response.image_results.length.should == 1
|
18
|
+
@image_response.image_results_offset.should == 0
|
19
|
+
@image_response.version.should == "2.2"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should have properly line up a news response" do
|
23
|
+
@news_response.news_total.should == 65900
|
24
|
+
@news_response.news_results.should_not be_empty
|
25
|
+
@news_response.news_results.length.should == 2
|
26
|
+
@news_response.news_results_offset.should == 0
|
27
|
+
@news_response.version.should == "2.2"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should have properly line up a related_search response" do
|
31
|
+
@related_response.related_search_total.should be_nil
|
32
|
+
@related_response.related_search_results.should_not be_empty
|
33
|
+
@related_response.related_search_results.length.should == 8
|
34
|
+
@related_response.related_search_results_offset.should be_nil
|
35
|
+
@related_response.version.should == "2.2"
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
before :all do
|
42
|
+
@news_json = <<END_NEWS
|
43
|
+
{
|
44
|
+
"SearchResponse":
|
45
|
+
{
|
46
|
+
"News":
|
47
|
+
{
|
48
|
+
"Offset": 0,
|
49
|
+
"Results":
|
50
|
+
[
|
51
|
+
{
|
52
|
+
"BreakingNews": 0,
|
53
|
+
"Date": "2011-12-01T03:55:00Z",
|
54
|
+
"Snippet":"At 4-7, the Seahawks are rebuilding while the Philadelphia Eagles are reeling and those two story lines provide the most compelling tension for Thursday's prime-time intersection. For Seattle, there is still a question of what these Seahawks ...",
|
55
|
+
"Source":"Seattle Times",
|
56
|
+
"Title":"Seahawks, Eagles are similar only in their 4-7 records",
|
57
|
+
"Url":"http:\/\/seattletimes.nwsource.com\/html\/seahawks\/2016900763_hawk01.html"
|
58
|
+
},
|
59
|
+
{
|
60
|
+
"BreakingNews": 0,
|
61
|
+
"Date":"2011-12-01T02:14:47Z",
|
62
|
+
"NewsCollections":[
|
63
|
+
{
|
64
|
+
"Name":"RelatedTextArticles",
|
65
|
+
"NewsArticles":[
|
66
|
+
{
|
67
|
+
"Date":"2011-11-29T01:12:44Z",
|
68
|
+
"Snippet":"PHILADELPHIA (AP) - Fans are calling for Andy Reid's dismissal more vehemently than ever. Assistant coaches are arguing on the sideline. A disgruntled star player isn't giving his best effort. There's no saving the Philadelphia Eagles this season. The best ...",
|
69
|
+
"Source":"NBC Sports",
|
70
|
+
"Title":"Eagles, Reid left to pick up the pieces",
|
71
|
+
"Url":"http:\/\/nbcsports.msnbc.com\/id\/45470523"
|
72
|
+
},
|
73
|
+
{
|
74
|
+
"Date":"2011-11-30T13:00:13Z",
|
75
|
+
"Snippet":"Eagles Pro Bowl WR\/PR DeSean Jackson will return to the starting lineup Thursday night in Seattle. The rest of his future is far murkier. Jackson is in the final year of his rookie deal, which pays him $600,000 in 2011, but isn't playing or behaving like ...",
|
76
|
+
"Source":"USA Today",
|
77
|
+
"Title":"Vote: What should the Eagles do with DeSean Jackson?",
|
78
|
+
"Url":"http:\/\/content.usatoday.com\/communities\/thehuddle\/post\/2011\/11\/vote-what-should-the-eagles-do-with-desean-jackson\/1"
|
79
|
+
}
|
80
|
+
]
|
81
|
+
}
|
82
|
+
],
|
83
|
+
"Snippet":"As the Philadelphia Eagles did the quick turnaround this week to prepare for their cross-country trek to play the Seahawks, they readily admitted that things don't look so good right now. It would be hard to argue otherwise, particularly after ...",
|
84
|
+
"Source":"News-Democrat",
|
85
|
+
"Title":"As the Eagles' soap opera turns ...",
|
86
|
+
"Url":"http:\/\/www.bnd.com\/2011\/11\/30\/v-print\/1962085\/as-the-eagles-soap-opera-turns.html"
|
87
|
+
}
|
88
|
+
],
|
89
|
+
"Total": 65900
|
90
|
+
},
|
91
|
+
"Query":
|
92
|
+
{
|
93
|
+
"SearchTerms": "eagles"
|
94
|
+
},
|
95
|
+
"Version": "2.2"
|
96
|
+
}
|
97
|
+
}
|
98
|
+
END_NEWS
|
99
|
+
|
100
|
+
@web_json = <<END_WEB
|
101
|
+
{
|
102
|
+
"SearchResponse":
|
103
|
+
{
|
104
|
+
"Query":
|
105
|
+
{
|
106
|
+
"SearchTerms":
|
107
|
+
"eagles"
|
108
|
+
},
|
109
|
+
"Version":
|
110
|
+
"2.2",
|
111
|
+
"Web":
|
112
|
+
{
|
113
|
+
"Offset":
|
114
|
+
0,
|
115
|
+
"Results":
|
116
|
+
[
|
117
|
+
{
|
118
|
+
"CacheUrl":
|
119
|
+
"http:\/\/cc.bingj.com\/cache.aspx?q=eagles&d=5015774834000721&mkt=en-US&w=401ef524,5c68a585",
|
120
|
+
"DateTime":
|
121
|
+
"2011-11-28T08:33:00Z",
|
122
|
+
"DeepLinks":
|
123
|
+
[
|
124
|
+
{
|
125
|
+
"Title":
|
126
|
+
"Schedule",
|
127
|
+
"Url":
|
128
|
+
"http:\/\/www.philadelphiaeagles.com\/gameday\/schedule.html"
|
129
|
+
},
|
130
|
+
{
|
131
|
+
"Title":
|
132
|
+
"News",
|
133
|
+
"Url":
|
134
|
+
"http:\/\/www.philadelphiaeagles.com\/news\/"
|
135
|
+
},
|
136
|
+
{
|
137
|
+
"Title":
|
138
|
+
"Roster",
|
139
|
+
"Url":
|
140
|
+
"http:\/\/www.philadelphiaeagles.com\/team\/roster.html"
|
141
|
+
},
|
142
|
+
{
|
143
|
+
"Title":
|
144
|
+
"Bloghead",
|
145
|
+
"Url":
|
146
|
+
"http:\/\/www.philadelphiaeagles.com\/Bloghead\/"
|
147
|
+
},
|
148
|
+
{
|
149
|
+
"Title":
|
150
|
+
"Shop",
|
151
|
+
"Url":
|
152
|
+
"http:\/\/store.philadelphiaeagles.com\/"
|
153
|
+
},
|
154
|
+
{
|
155
|
+
"Title":
|
156
|
+
"Discussion Boards",
|
157
|
+
"Url":
|
158
|
+
"http:\/\/boards.philadelphiaeagles.com\/"
|
159
|
+
},
|
160
|
+
{
|
161
|
+
"Title":
|
162
|
+
"Transactions",
|
163
|
+
"Url":
|
164
|
+
"http:\/\/www.philadelphiaeagles.com\/team\/transactions.html"
|
165
|
+
},
|
166
|
+
{
|
167
|
+
"Title":
|
168
|
+
"Eagles Media Guide",
|
169
|
+
"Url":
|
170
|
+
"http:\/\/legacy.philadelphiaeagles.com\/eagles_files\/html\/depth_chart_rosters_1.html"
|
171
|
+
},
|
172
|
+
{
|
173
|
+
"Title":
|
174
|
+
"On The Inside",
|
175
|
+
"Url":
|
176
|
+
"http:\/\/www.philadelphiaeagles.com\/news\/OnTheInside.html"
|
177
|
+
},
|
178
|
+
{
|
179
|
+
"Title":
|
180
|
+
"Gameday",
|
181
|
+
"Url":
|
182
|
+
"http:\/\/www.philadelphiaeagles.com\/gameday\/"
|
183
|
+
},
|
184
|
+
{
|
185
|
+
"Title":
|
186
|
+
"Sold Out",
|
187
|
+
"Url":
|
188
|
+
"http:\/\/www.philadelphiaeagles.com\/news\/article-1\/Sold-Out\/4ad51057-0c6d-40d2-b262-9bff6d04a75d"
|
189
|
+
},
|
190
|
+
{
|
191
|
+
"Title":
|
192
|
+
"Media",
|
193
|
+
"Url":
|
194
|
+
"http:\/\/www.philadelphiaeagles.com\/multimedia\/"
|
195
|
+
},
|
196
|
+
{
|
197
|
+
"Title":
|
198
|
+
"Eagles' Team Needs",
|
199
|
+
"Url":
|
200
|
+
"http:\/\/www.philadelphiaeagles.com\/multimedia\/videos\/Eagles-Team-Needs\/48242ace-5c2c-4112-a094-829358470bef"
|
201
|
+
}
|
202
|
+
],
|
203
|
+
"Description":
|
204
|
+
"Official team site. Roster, team news, history, youth programs, and ticket information.",
|
205
|
+
"DisplayUrl":
|
206
|
+
"www.philadelphiaeagles.com",
|
207
|
+
"Title":
|
208
|
+
"Philadelphia Eagles",
|
209
|
+
"Url":
|
210
|
+
"http:\/\/www.philadelphiaeagles.com\/"
|
211
|
+
}
|
212
|
+
],
|
213
|
+
"Total":
|
214
|
+
1830000
|
215
|
+
}
|
216
|
+
}
|
217
|
+
}
|
218
|
+
END_WEB
|
219
|
+
|
220
|
+
@image_json = <<END_IMAGE
|
221
|
+
{
|
222
|
+
"SearchResponse":
|
223
|
+
{
|
224
|
+
"Image":
|
225
|
+
{
|
226
|
+
"Offset":
|
227
|
+
0,
|
228
|
+
"Results":
|
229
|
+
[
|
230
|
+
{
|
231
|
+
"ContentType":
|
232
|
+
"image\/jpeg",
|
233
|
+
"DisplayUrl":
|
234
|
+
"http:\/\/lyrics.wikia.com\/Eagles",
|
235
|
+
"FileSize":
|
236
|
+
26463,
|
237
|
+
"Height":
|
238
|
+
419,
|
239
|
+
"MediaUrl":
|
240
|
+
"http:\/\/images.wikia.com\/lyricwiki\/images\/5\/59\/The_Eagles.jpg",
|
241
|
+
"Thumbnail":
|
242
|
+
{
|
243
|
+
"ContentType":
|
244
|
+
"image\/jpeg",
|
245
|
+
"FileSize":
|
246
|
+
3812,
|
247
|
+
"Height":
|
248
|
+
134,
|
249
|
+
"Url":
|
250
|
+
"http:\/\/ts1.mm.bing.net\/images\/thumbnail.aspx?q=1310066356354&id=c6cbd98af9fe635fe49b49c43e17ff72",
|
251
|
+
"Width":
|
252
|
+
160
|
253
|
+
},
|
254
|
+
"Title":
|
255
|
+
"Eagles Lyrics - Lyric Wiki - song lyrics, music lyrics",
|
256
|
+
"Url":
|
257
|
+
"http:\/\/lyrics.wikia.com\/Eagles",
|
258
|
+
"Width":
|
259
|
+
500
|
260
|
+
}
|
261
|
+
],
|
262
|
+
"Total":
|
263
|
+
1980000
|
264
|
+
},
|
265
|
+
"Query":
|
266
|
+
{
|
267
|
+
"SearchTerms":
|
268
|
+
"eagles"
|
269
|
+
},
|
270
|
+
"Version":
|
271
|
+
"2.2"
|
272
|
+
}
|
273
|
+
}
|
274
|
+
END_IMAGE
|
275
|
+
|
276
|
+
@related_json = <<END_INSTANT
|
277
|
+
{
|
278
|
+
"SearchResponse":
|
279
|
+
{
|
280
|
+
"Query":
|
281
|
+
{
|
282
|
+
"SearchTerms":
|
283
|
+
"Joe Scarborough"
|
284
|
+
},
|
285
|
+
"RelatedSearch":
|
286
|
+
{
|
287
|
+
"Results":
|
288
|
+
[
|
289
|
+
{
|
290
|
+
"Title":
|
291
|
+
"Joe Scarborough Affair",
|
292
|
+
"Url":
|
293
|
+
"http:\/\/www.bing.com\/search?q=Joe+Scarborough+Affair"
|
294
|
+
},
|
295
|
+
{
|
296
|
+
"Title":
|
297
|
+
"Joe Scarborough Wife",
|
298
|
+
"Url":
|
299
|
+
"http:\/\/www.bing.com\/search?q=Joe+Scarborough+Wife"
|
300
|
+
},
|
301
|
+
{
|
302
|
+
"Title":
|
303
|
+
"Joe Scarborough Baby",
|
304
|
+
"Url":
|
305
|
+
"http:\/\/www.bing.com\/search?q=Joe+Scarborough+Baby"
|
306
|
+
},
|
307
|
+
{
|
308
|
+
"Title":
|
309
|
+
"Joe Scarborough Scandal",
|
310
|
+
"Url":
|
311
|
+
"http:\/\/www.bing.com\/search?q=Joe+Scarborough+Scandal"
|
312
|
+
},
|
313
|
+
{
|
314
|
+
"Title":
|
315
|
+
"Joe Scarborough and Mika",
|
316
|
+
"Url":
|
317
|
+
"http:\/\/www.bing.com\/search?q=Joe+Scarborough+and+Mika"
|
318
|
+
},
|
319
|
+
{
|
320
|
+
"Title":
|
321
|
+
"Joe Scarborough Biography",
|
322
|
+
"Url":
|
323
|
+
"http:\/\/www.bing.com\/search?q=Joe+Scarborough+Biography"
|
324
|
+
},
|
325
|
+
{
|
326
|
+
"Title":
|
327
|
+
"Joe Scarborough Radio Show",
|
328
|
+
"Url":
|
329
|
+
"http:\/\/www.bing.com\/search?q=Joe+Scarborough+Radio+Show"
|
330
|
+
},
|
331
|
+
{
|
332
|
+
"Title":
|
333
|
+
"Email Joe Scarborough at MSNBC",
|
334
|
+
"Url":
|
335
|
+
"http:\/\/www.bing.com\/search?q=Email+Joe+Scarborough+at+MSNBC"
|
336
|
+
}
|
337
|
+
]
|
338
|
+
},
|
339
|
+
"Version":
|
340
|
+
"2.2"
|
341
|
+
}
|
342
|
+
}
|
343
|
+
END_INSTANT
|
344
|
+
|
345
|
+
@web_response = BingHelper::Response.new(Yajl::Parser.new.parse(@web_json))
|
346
|
+
@image_response = BingHelper::Response.new(Yajl::Parser.new.parse(@image_json))
|
347
|
+
@news_response = BingHelper::Response.new(Yajl::Parser.new.parse(@news_json))
|
348
|
+
@related_response = BingHelper::Response.new(Yajl::Parser.new.parse(@related_json))
|
349
|
+
|
350
|
+
end
|
351
|
+
|
352
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bing-helper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Sujal Shah
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-12-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: faraday
|
16
|
+
requirement: &70263401470540 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.7.5
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70263401470540
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: yajl-ruby
|
27
|
+
requirement: &70263401469980 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '1.0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70263401469980
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
requirement: &70263401469400 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70263401469400
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: &70263401468740 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70263401468740
|
58
|
+
description: Bing search API client for EM-Synchrony using Faraday
|
59
|
+
email:
|
60
|
+
- codesujal@gmail.com
|
61
|
+
executables: []
|
62
|
+
extensions: []
|
63
|
+
extra_rdoc_files: []
|
64
|
+
files:
|
65
|
+
- .gitignore
|
66
|
+
- Gemfile
|
67
|
+
- Gemfile.lock
|
68
|
+
- LICENSE
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- bing-helper.gemspec
|
72
|
+
- lib/bing-helper.rb
|
73
|
+
- lib/bing-helper/bing.rb
|
74
|
+
- lib/bing-helper/response.rb
|
75
|
+
- lib/bing-helper/version.rb
|
76
|
+
- spec/bing_helper_bing_spec.rb
|
77
|
+
- spec/bing_helper_response_spec.rb
|
78
|
+
- spec/spec_helper.rb
|
79
|
+
homepage: https://github.com/VarioLabs/bing-helper
|
80
|
+
licenses: []
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ! '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project: bing-helper
|
99
|
+
rubygems_version: 1.8.11
|
100
|
+
signing_key:
|
101
|
+
specification_version: 3
|
102
|
+
summary: Bing search API client for EM-Synchrony using Faraday
|
103
|
+
test_files:
|
104
|
+
- spec/bing_helper_bing_spec.rb
|
105
|
+
- spec/bing_helper_response_spec.rb
|
106
|
+
- spec/spec_helper.rb
|