binged 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.md
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ ## PROJECT::GENERAL
2
+ coverage
3
+ rdoc
4
+ pkg
5
+
6
+ ## PROJECT::SPECIFIC
7
+ doc
8
+ .yardoc
data/HISTORY ADDED
File without changes
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Kevin Faustino
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,52 @@
1
+ # Overview
2
+
3
+ ## About Binged
4
+
5
+ A Ruby wrapper for the Bing API
6
+
7
+ ## Installation
8
+
9
+ [sudo] gem install binged
10
+
11
+ ### Get Your Bing API key
12
+
13
+ To use binged, you will require a Bing API key. Create one at: [http://www.bing.com/developers/createapp.aspx](http://www.bing.com/developers/createapp.aspx)
14
+
15
+ ## Usage
16
+
17
+ ### Instantiate a client
18
+ binged = Binged::Client.new(:api_key => 'binged')
19
+
20
+ ### Ruby on Rails
21
+
22
+ Binged allows for configuration to be done once using a configure block. To use binged in your Ruby on Rails project, configure it globally in an initializer.
23
+
24
+ # config/initializers/binged.rb
25
+ Binged.configure do |config|
26
+ config.api_key = 'api_key'
27
+ end
28
+
29
+ # Client initialization
30
+ binged = Binged::Client.new
31
+
32
+ ### Web Search Example
33
+
34
+ Web search utilizes a criteria based query interface inspired by jnunemaker's [Twitter Gem](http://github.com/jnunemaker/twitter) Search API wrapper.
35
+
36
+ # Find 30 results for ruby from site http://www.ruby-lang.org
37
+ web_search = Binged::Client.new.web
38
+ web_search.containing('ruby').from_site('www.ruby-lang.org').per_page(30).each {|result| puts result.title }
39
+
40
+ ## Note on Patches/Pull Requests
41
+
42
+ * Fork the project.
43
+ * Make your feature addition or bug fix.
44
+ * Add tests for it. This is important so I don't break it in a
45
+ future version unintentionally.
46
+ * Commit, do not mess with rakefile, version, or history.
47
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
48
+ * Send me a pull request. Bonus points for topic branches.
49
+
50
+ ## Copyright
51
+
52
+ Copyright (c) 2010 Kevin Faustino. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,48 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "binged"
8
+ gem.summary = %Q{A wrapper for the bing api}
9
+ gem.description = %Q{A wrapper for the bing api}
10
+ gem.email = "kevin.faustino@gmail.com"
11
+ gem.homepage = "http://github.com/kfaustino/binged"
12
+ gem.authors = ["Kevin Faustino"]
13
+ gem.add_dependency "hashie", "~>0.1.0"
14
+ gem.add_dependency "crack", ">=0.1.6"
15
+ gem.add_development_dependency "rspec", ">= 1.3.0"
16
+ gem.add_development_dependency "fakeweb", ">=1.2.8"
17
+ gem.add_development_dependency "yard", ">= 0"
18
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
19
+ end
20
+ Jeweler::GemcutterTasks.new
21
+ rescue LoadError
22
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
23
+ end
24
+
25
+ require 'spec/rake/spectask'
26
+ Spec::Rake::SpecTask.new(:spec) do |spec|
27
+ spec.libs << 'lib' << 'spec'
28
+ spec.spec_files = FileList['spec/**/*_spec.rb']
29
+ end
30
+
31
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
32
+ spec.libs << 'lib' << 'spec'
33
+ spec.pattern = 'spec/**/*_spec.rb'
34
+ spec.rcov = true
35
+ end
36
+
37
+ task :spec => :check_dependencies
38
+
39
+ task :default => :spec
40
+
41
+ begin
42
+ require 'yard'
43
+ YARD::Rake::YardocTask.new
44
+ rescue LoadError
45
+ task :yardoc do
46
+ abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
47
+ end
48
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/binged.gemspec ADDED
@@ -0,0 +1,76 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{binged}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Kevin Faustino"]
12
+ s.date = %q{2010-03-07}
13
+ s.description = %q{A wrapper for the bing api}
14
+ s.email = %q{kevin.faustino@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "HISTORY",
23
+ "LICENSE",
24
+ "README.md",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "binged.gemspec",
28
+ "lib/binged.rb",
29
+ "lib/binged/client.rb",
30
+ "lib/binged/hashie_extensions.rb",
31
+ "lib/binged/search.rb",
32
+ "lib/binged/search/base.rb",
33
+ "lib/binged/search/web.rb",
34
+ "spec/binged/search/web_spec.rb",
35
+ "spec/binged_spec.rb",
36
+ "spec/fixtures/web.json",
37
+ "spec/spec.opts",
38
+ "spec/spec_helper.rb"
39
+ ]
40
+ s.homepage = %q{http://github.com/kfaustino/binged}
41
+ s.rdoc_options = ["--charset=UTF-8"]
42
+ s.require_paths = ["lib"]
43
+ s.rubygems_version = %q{1.3.6}
44
+ s.summary = %q{A wrapper for the bing api}
45
+ s.test_files = [
46
+ "spec/binged/search/web_spec.rb",
47
+ "spec/binged_spec.rb",
48
+ "spec/spec_helper.rb"
49
+ ]
50
+
51
+ if s.respond_to? :specification_version then
52
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
53
+ s.specification_version = 3
54
+
55
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
56
+ s.add_runtime_dependency(%q<hashie>, ["~> 0.1.0"])
57
+ s.add_runtime_dependency(%q<crack>, [">= 0.1.6"])
58
+ s.add_development_dependency(%q<rspec>, [">= 1.3.0"])
59
+ s.add_development_dependency(%q<fakeweb>, [">= 1.2.8"])
60
+ s.add_development_dependency(%q<yard>, [">= 0"])
61
+ else
62
+ s.add_dependency(%q<hashie>, ["~> 0.1.0"])
63
+ s.add_dependency(%q<crack>, [">= 0.1.6"])
64
+ s.add_dependency(%q<rspec>, [">= 1.3.0"])
65
+ s.add_dependency(%q<fakeweb>, [">= 1.2.8"])
66
+ s.add_dependency(%q<yard>, [">= 0"])
67
+ end
68
+ else
69
+ s.add_dependency(%q<hashie>, ["~> 0.1.0"])
70
+ s.add_dependency(%q<crack>, [">= 0.1.6"])
71
+ s.add_dependency(%q<rspec>, [">= 1.3.0"])
72
+ s.add_dependency(%q<fakeweb>, [">= 1.2.8"])
73
+ s.add_dependency(%q<yard>, [">= 0"])
74
+ end
75
+ end
76
+
@@ -0,0 +1,23 @@
1
+ module Binged
2
+
3
+ # A client which encapsulates the Bing API
4
+ class Client
5
+
6
+ attr_accessor :api_key
7
+
8
+ # @param [Hash] options the options to create a client with.
9
+ # @option options [String] :api_key The Bing API key used to make all API calls.
10
+ def initialize(options = {})
11
+ @api_key = options[:api_key] || Binged.api_key
12
+ end
13
+
14
+ # Create a web search through Bing
15
+ #
16
+ # @param [String] query The search term to be sent to Bing
17
+ def web(query='')
18
+ Search::Web.new(self,query)
19
+ end
20
+
21
+ end
22
+
23
+ end
@@ -0,0 +1,11 @@
1
+ # Ensures all Hash keys follow ruby idioms
2
+ # @private
3
+ module Hashie
4
+ class Mash < Hashie::Hash
5
+ protected
6
+ def convert_key(key) #:nodoc:
7
+ key.to_s.gsub(/([a-z\d])([A-Z])/,'\1_\2').
8
+ downcase
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,58 @@
1
+ module Binged
2
+ module Search
3
+
4
+ # @abstract Subclass and override {#fetch} to implement a custom Searchable class
5
+ class Base
6
+ include Enumerable
7
+ attr_reader :client, :query, :source
8
+
9
+ BASE_URI = 'http://api.bing.net/json.aspx?'
10
+
11
+ # @param [Binged::Client] client
12
+ def initialize(client)
13
+ @client = client
14
+ reset_query
15
+ end
16
+
17
+ # Clears all filters to perform a new search
18
+ def clear
19
+ @fetch = nil
20
+ reset_query
21
+ self
22
+ end
23
+
24
+ def fetch
25
+ end
26
+
27
+ # Performs a GET call to Bing API
28
+ #
29
+ # @return [Hash] Hash of Bing API response
30
+ def perform
31
+ url = URI.parse BASE_URI
32
+ query = @query.dup
33
+ query[:Query] = query[:Query].join(' ')
34
+ query[:Sources] = self.source
35
+ query_options = default_options.merge(query).to_params
36
+ url.query = query_options
37
+ response = Net::HTTP.get(url)
38
+ Crack::JSON.parse(response)
39
+ end
40
+
41
+ # @yieldreturn [Hash] A result from a Bing query
42
+ def each
43
+ fetch().results.each { |r| yield r }
44
+ end
45
+
46
+ private
47
+
48
+ def default_options
49
+ {:AppId => @client.api_key, :JsonType => 'raw', :Version => '2.2' }
50
+ end
51
+
52
+ def reset_query
53
+ @query = { :Query => [] }
54
+ end
55
+ end
56
+
57
+ end
58
+ end
@@ -0,0 +1,88 @@
1
+ module Binged
2
+ module Search
3
+
4
+ # A class that encapsulated the Bing Web Search source
5
+ # @todo Add support for adult and market filtering
6
+ class Web < Base
7
+
8
+ SUPPORTED_FILE_TYPES = [:doc, :dwf, :feed, :htm, :html, :pdf, :ppt, :ps, :rtf, :text, :txt, :xls]
9
+
10
+ # @param [Binged::Client] client
11
+ # @param [String] query The search term to be sent to Bing
12
+ # @param [Hash] options
13
+ def initialize(client, query=nil, options={})
14
+ super(client)
15
+ @source = :web
16
+ per_page(20).page(1)
17
+ containing(query) if query && query.strip != ''
18
+ end
19
+
20
+ # Add query to search
21
+ #
22
+ # @param [String] query The search term to be sent to Bing
23
+ # @return [self]
24
+ def containing(query)
25
+ @query[:Query] << query
26
+ self
27
+ end
28
+
29
+ # Retrieve results of the web search
30
+ #
31
+ # @return [Hash] A hash of the results returned from Bing
32
+ def fetch
33
+ if @fetch.nil?
34
+ response = perform
35
+ @fetch = Hashie::Mash.new(response["SearchResponse"]["Web"]) if response
36
+ end
37
+
38
+ @fetch || []
39
+ end
40
+
41
+ # Add filtering based on a file type
42
+ #
43
+ # @example
44
+ # web_search.file_type(:pdf) # Isolate search to PDF files
45
+ #
46
+ # @param [Symbol] type A symbol of a {SUPPORTED_FILE_TYPES}
47
+ # @return [self]
48
+ # @see http://msdn.microsoft.com/en-us/library/dd250876.aspx Description of all supported file types
49
+ def file_type(type)
50
+ @query['Web.FileType'] = type if SUPPORTED_FILE_TYPES.include?(type)
51
+ self
52
+ end
53
+
54
+ # Isolate search results to a specific site
55
+ #
56
+ # @example
57
+ # web_search.from_site('www.ruby-lang.org')
58
+ #
59
+ # @param [String] site Web site address to limit search results to
60
+ # @return [self]
61
+ def from_site(site)
62
+ @query[:Query] << "site:#{site}"
63
+ self
64
+ end
65
+
66
+ # Set the page number of the results to display
67
+ #
68
+ # @param [Fixnum] num The page number of the search results
69
+ # @return [self]
70
+ def page(num=1)
71
+ offset = num - 1
72
+ @query['Web.Offset'] = @results_per_page * offset
73
+ self
74
+ end
75
+
76
+ # The amount of results to display per page. Initialized to 20 per page.
77
+ #
78
+ # @param [Fixnum] num The number of results per page
79
+ # @return [self]
80
+ def per_page(num)
81
+ @results_per_page = num
82
+ @query['Web.Count'] = @results_per_page
83
+ self
84
+ end
85
+
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,9 @@
1
+ module Binged
2
+ # A module containing Bing search sources
3
+ module Search
4
+
5
+ autoload :Base, "binged/search/base"
6
+ autoload :Web, "binged/search/web"
7
+
8
+ end
9
+ end
data/lib/binged.rb ADDED
@@ -0,0 +1,35 @@
1
+ require 'crack'
2
+ require 'hashie'
3
+ require 'net/http'
4
+ require 'uri'
5
+
6
+ Hash.send :include, Hashie::HashExtensions
7
+ require 'binged/hashie_extensions'
8
+
9
+ # The module that contains everything Binged related
10
+ #
11
+ # * {Binged::Client} is used to interact with the Bing API
12
+ # * {Binged::Search} contains different Bing search sources
13
+ module Binged
14
+ autoload :Client, "binged/client"
15
+ autoload :Search, "binged/search"
16
+
17
+ # Configure global options for Binged
18
+ #
19
+ # For example:
20
+ #
21
+ # Binged.configure do |config|
22
+ # config.api_key = 'api_key'
23
+ # end
24
+ def self.configure
25
+ yield self
26
+ true
27
+ end
28
+
29
+ class << self
30
+ attr_accessor :api_key
31
+ end
32
+
33
+ end
34
+
35
+
@@ -0,0 +1,83 @@
1
+ require 'spec_helper'
2
+
3
+ module Binged
4
+ module Search
5
+
6
+ describe "Web" do
7
+
8
+ before(:each) do
9
+ @client = Binged::Client.new(:api_key => 'binged')
10
+ @search = Web.new(@client)
11
+ end
12
+
13
+ it "should initialize with a search term" do
14
+ Web.new(@client, 'binged').query[:Query].should include('binged')
15
+ end
16
+
17
+ it "should be able to specify a site to limit searches to" do
18
+ @search.from_site('adventuresincoding.com')
19
+ @search.query[:Query].should include('site:adventuresincoding.com')
20
+ end
21
+
22
+ it "should be able to specify the number of results per page" do
23
+ @search.per_page(10)
24
+ @search.query['Web.Count'].should == 10
25
+ end
26
+
27
+ it "should be able to specify the page number" do
28
+ @search.page(3)
29
+ @search.query['Web.Offset'].should == 20 * 2
30
+ end
31
+
32
+ it "should be able to set a file type" do
33
+ @search.file_type(:pdf)
34
+ @search.query['Web.FileType'].should == :pdf
35
+ end
36
+
37
+ context "fetching" do
38
+
39
+ before(:each) do
40
+ stub_get("http://api.bing.net/json.aspx?Web.Offset=0&Sources=web&AppId=binged&Query=ruby&JsonType=raw&Version=2.2&Web.Count=20", 'web.json')
41
+ @search.containing("ruby")
42
+ @response = @search.fetch
43
+ end
44
+
45
+ it "should cache fetch to eliminate multiple calls to the api" do
46
+ Web.should_not_receive(:perform)
47
+ @search.fetch
48
+ end
49
+
50
+ it "should return the results of the search" do
51
+ @response.results.size.should == 20
52
+ end
53
+
54
+ it "should support dot notation" do
55
+ result = @response.results.first
56
+ result.title.should == "Ruby Programming Language"
57
+ result.description.should == "Ruby is… A dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is ..."
58
+ result.url.should == "http://www.ruby-lang.org/en/"
59
+ end
60
+
61
+ end
62
+
63
+ context "iterating over results" do
64
+
65
+ before(:each) do
66
+ stub_get("http://api.bing.net/json.aspx?Web.Offset=0&Sources=Web&AppId=binged&Query=ruby&JsonType=raw&Version=2.2&Web.Count=20", 'web.json')
67
+ @search.containing("ruby")
68
+ end
69
+
70
+ it "should be able to iterate over results" do
71
+ @search.respond_to?(:each).should be_true
72
+ end
73
+
74
+ it "should have items" do
75
+ @search.each {|item| item.should_not be_nil }
76
+ end
77
+
78
+ end
79
+
80
+ end
81
+
82
+ end
83
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Binged" do
4
+
5
+ it "should configure the api_key for easy access" do
6
+ Binged.configure do |config|
7
+ config.api_key = 'api_key'
8
+ end
9
+
10
+ client = Binged::Client.new
11
+ client.api_key.should == 'api_key'
12
+ end
13
+
14
+ it "should provide a simple interface to web search" do
15
+ client = Binged::Client.new
16
+ client.web.should be_instance_of(Binged::Search::Web)
17
+ end
18
+
19
+ end
@@ -0,0 +1 @@
1
+ {"SearchResponse":{"Version":"2.2","Query":{"SearchTerms":"ruby"},"Web":{"Total":29600000,"Offset":0,"Results":[{"Title":"Ruby Programming Language","Description":"Ruby is… A dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is ...","Url":"http:\/\/www.ruby-lang.org\/en\/","CacheUrl":"http:\/\/cc.bingj.com\/cache.aspx?q=ruby&d=4627410722949096&w=54f314e7,2e58cc30","DisplayUrl":"www.ruby-lang.org\/en","DateTime":"2010-03-03T17:14:36Z","DeepLinks":[{"Title":"Downloads","Url":"http:\/\/www.ruby-lang.org\/en\/downloads\/"},{"Title":"Documentation","Url":"http:\/\/www.ruby-lang.org\/en\/documentation\/"},{"Title":"About Ruby","Url":"http:\/\/www.ruby-lang.org\/en\/about\/"},{"Title":"Ruby in Twenty Minutes","Url":"http:\/\/www.ruby-lang.org\/en\/documentation\/quickstart\/"},{"Title":"Libraries","Url":"http:\/\/www.ruby-lang.org\/en\/libraries\/"},{"Title":"Ruby from Other Languages","Url":"http:\/\/www.ruby-lang.org\/en\/documentation\/ruby-from-other-languages\/"},{"Title":"Community","Url":"http:\/\/www.ruby-lang.org\/en\/community\/"},{"Title":"Ruby Core","Url":"http:\/\/www.ruby-lang.org\/en\/community\/ruby-core\/"},{"Title":"News","Url":"http:\/\/www.ruby-lang.org\/en\/news\/"},{"Title":"Issue Tracking","Url":"http:\/\/redmine.ruby-lang.org\/"},{"Title":"Weblogs","Url":"http:\/\/www.ruby-lang.org\/en\/community\/weblogs\/"},{"Title":"Mailing Lists","Url":"http:\/\/www.ruby-lang.org\/en\/community\/mailing-lists"},{"Title":"Security","Url":"http:\/\/www.ruby-lang.org\/en\/security\/"}]},{"Title":"Ruby - Wikipedia, the free encyclopedia","Description":"A ruby is a pink to blood-red gemstone, a variety of the mineral corundum (aluminium oxide). The red color is caused mainly by the presence of the element chromium.","Url":"http:\/\/en.wikipedia.org\/wiki\/Ruby","CacheUrl":"http:\/\/cc.bingj.com\/cache.aspx?q=ruby&d=661775063422&w=78e1f24a,3a2d897e","DisplayUrl":"en.wikipedia.org\/wiki\/Ruby","DateTime":"2010-02-27T07:18:03Z","DeepLinks":[{"Title":"Main page","Url":"http:\/\/en.wikipedia.org\/wiki\/Main_Page"},{"Title":"Random article","Url":"http:\/\/en.wikipedia.org\/wiki\/Special:Random"},{"Title":"Contents","Url":"http:\/\/en.wikipedia.org\/wiki\/Portal:Contents"},{"Title":"Current events","Url":"http:\/\/en.wikipedia.org\/wiki\/Portal:Current_events"},{"Title":"Featured content","Url":"http:\/\/en.wikipedia.org\/wiki\/Portal:Featured_content"},{"Title":"Wikipedia:About","Url":"http:\/\/en.wikipedia.org\/wiki\/Wikipedia:About"},{"Title":"Citation Needed","Url":"http:\/\/en.wikipedia.org\/wiki\/Wikipedia:Citation_needed"},{"Title":"Sapphire","Url":"http:\/\/en.wikipedia.org\/wiki\/Sapphire"},{"Title":"Diamond","Url":"http:\/\/en.wikipedia.org\/wiki\/Diamond"},{"Title":"Ruby disambiguation","Url":"http:\/\/en.wikipedia.org\/wiki\/ruby_(disambiguation)"},{"Title":"Pakistan","Url":"http:\/\/en.wikipedia.org\/wiki\/Pakistan"},{"Title":"Birthstone","Url":"http:\/\/en.wikipedia.org\/wiki\/Birthstone"},{"Title":"Community portal","Url":"http:\/\/en.wikipedia.org\/wiki\/Wikipedia:Community_portal"}]},{"Title":"Ruby - The Inspirational Weight Loss Journey on the Style Network ...","Description":"Inspirational weight loss and weight loss exercises from the show Ruby on the Style Network","Url":"http:\/\/www.mystyle.com\/mystyle\/shows\/ruby\/index.jsp","CacheUrl":"http:\/\/cc.bingj.com\/cache.aspx?q=ruby&d=5041767689816463&w=bbeb6738,92443868","DisplayUrl":"www.mystyle.com\/mystyle\/shows\/ruby\/index.jsp","DateTime":"2010-03-03T17:50:23Z","DeepLinks":[{"Title":"Fashion DUI","Url":"http:\/\/www.mystyle.com\/mystyle\/photos\/gallery.jsp?galleryUUID=bae9c59a-3236-426d-8eb6-33db1a459c31"},{"Title":"Top Steals of the Week","Url":"http:\/\/www.mystyle.com\/mystyle\/photos\/gallery.jsp?galleryUUID=a02cc651-c811-4148-900a-fff42c858eb5"},{"Title":"Weight Loss Message Boards","Url":"http:\/\/www.mystyle.com\/mystyle\/community\/forums\/index.jsp"},{"Title":"Clean House Before & After","Url":"http:\/\/www.mystyle.com\/mystyle\/photos\/gallery.jsp?galleryUUID=49b46faf-a336-4645-8d2b-e325a6d5e3a2"},{"Title":"Clean House","Url":"http:\/\/www.mystyle.com\/mystyle\/shows\/cleanhouse\/index.jsp"},{"Title":"Dress My Nest Before & After","Url":"http:\/\/www.mystyle.com\/mystyle\/photos\/gallery.jsp?galleryUUID=9a4f89fc-e947-401b-ab9f-62f918b341a3"},{"Title":"Style Shout-Out","Url":"http:\/\/www.mystyle.com\/mystyle\/photos\/gallery.jsp?galleryUUID=cee27be1-f8f4-44e8-a3b5-87da66c1412d"},{"Title":"Healthy Weight Loss","Url":"http:\/\/www.mystyle.com\/mystyle\/shows\/ruby\/gettinghealthy\/index.jsp"},{"Title":"Giuliana & Bill","Url":"http:\/\/www.mystyle.com\/mystyle\/shows\/giulianaandbill\/index.jsp"},{"Title":"Whose Wedding Is It Anyway?","Url":"http:\/\/www.mystyle.com\/mystyle\/shows\/whosewedding\/index.jsp"},{"Title":"How Do I Look?","Url":"http:\/\/www.mystyle.com\/mystyle\/shows\/howdoilook\/index.jsp"},{"Title":"Photo Galleries","Url":"http:\/\/www.mystyle.com\/mystyle\/photos\/index.jsp"},{"Title":"mystyle Quiz","Url":"http:\/\/www.mystyle.com\/mystyle\/games\/index.jsp?game=mystylequiz&navSection=fashion,beauty"}]},{"Title":"Ruby (programming language) - Wikipedia, the free encyclopedia","Description":"Ruby is a dynamic, reflective, general purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features.","Url":"http:\/\/en.wikipedia.org\/wiki\/Ruby_(programming_language)","CacheUrl":"http:\/\/cc.bingj.com\/cache.aspx?q=ruby&d=5003684216244711&w=b7f38fb8,ccc1c0aa","DisplayUrl":"en.wikipedia.org\/wiki\/Ruby_(programming_language)","DateTime":"2010-03-04T11:36:58Z","DeepLinks":[{"Title":"Main page","Url":"http:\/\/en.wikipedia.org\/wiki\/Main_Page"},{"Title":"Random article","Url":"http:\/\/en.wikipedia.org\/wiki\/Special:Random"},{"Title":"Current events","Url":"http:\/\/en.wikipedia.org\/wiki\/Portal:Current_events"},{"Title":"Contents","Url":"http:\/\/en.wikipedia.org\/wiki\/Portal:Contents"},{"Title":"Featured content","Url":"http:\/\/en.wikipedia.org\/wiki\/Portal:Featured_content"},{"Title":"About Wikipedia","Url":"http:\/\/en.wikipedia.org\/wiki\/Wikipedia:About"},{"Title":"Japan","Url":"http:\/\/en.wikipedia.org\/wiki\/Japan"},{"Title":"Recent changes","Url":"http:\/\/en.wikipedia.org\/wiki\/Special:RecentChanges"},{"Title":"Community portal","Url":"http:\/\/en.wikipedia.org\/wiki\/Wikipedia:Community_portal"},{"Title":"Contact Wikipedia","Url":"http:\/\/en.wikipedia.org\/wiki\/Wikipedia:Contact_us"},{"Title":"Upload file","Url":"http:\/\/en.wikipedia.org\/wiki\/Wikipedia:Upload"},{"Title":"Special pages","Url":"http:\/\/en.wikipedia.org\/wiki\/Special:SpecialPages"},{"Title":"Microsoft Windows","Url":"http:\/\/en.wikipedia.org\/wiki\/Microsoft_Windows"}]},{"Title":"Ruby - english","Description":"Ruby Which colour would you spontaneously associate with love and vivacity, passion and power? It's obvious, isn't it? Red. Red is the colour of love.","Url":"http:\/\/www.gemstone.org\/gem-by-gem\/english\/ruby.html","CacheUrl":"http:\/\/cc.bingj.com\/cache.aspx?q=ruby&d=4700979218418228&w=71813540,94f5edb5","DisplayUrl":"www.gemstone.org\/gem-by-gem\/english\/ruby.html","DateTime":"2010-03-03T16:31:39Z"},{"Title":"Ruby Meetup Groups - Ruby Meetups","Description":"Helps groups of people with shared interests plan meetings and form offline clubs in local communities around the world about Ruby","Url":"http:\/\/ruby.meetup.com\/","CacheUrl":"http:\/\/cc.bingj.com\/cache.aspx?q=ruby&d=695343056075&w=73bd8912,24d17d8f","DisplayUrl":"ruby.meetup.com","DateTime":"2010-03-03T21:25:08Z"},{"Title":"Ruby (1992)","Description":"Directed by John Mackenzie. With Danny Aiello, Sherilyn Fenn, Arliss Howard. Visit IMDb for Photos, Showtimes, Cast, Crew, Reviews, Plot Summary, Comments, Discussions, Taglines ...","Url":"http:\/\/www.imdb.com\/title\/tt0105291\/","CacheUrl":"http:\/\/cc.bingj.com\/cache.aspx?q=ruby&d=4821474522039504&w=5143f877,76ab7637","DisplayUrl":"www.imdb.com\/title\/tt0105291","DateTime":"2010-02-04T07:59:38Z"},{"Title":"[Ruby-Doc.org: Documenting the Ruby Language]","Description":"Ruby documentation project: links and downloads of programming information, on many aspects of Ruby.","Url":"http:\/\/www.ruby-doc.org\/","CacheUrl":"http:\/\/cc.bingj.com\/cache.aspx?q=ruby&d=4998165183923249&w=ea8f6d25,95b1875e","DisplayUrl":"www.ruby-doc.org","DateTime":"2010-03-04T16:59:06Z","DeepLinks":[{"Title":"Standard API","Url":"http:\/\/www.ruby-doc.org\/stdlib\/"},{"Title":"Programming Ruby","Url":"http:\/\/www.ruby-doc.org\/docs\/ProgrammingRuby\/"},{"Title":"Files","Url":"http:\/\/www.ruby-doc.org\/core"},{"Title":"Getting Started","Url":"http:\/\/www.ruby-doc.org\/gettingstarted\/index.html"},{"Title":"Additional Documents","Url":"http:\/\/www.ruby-doc.org\/docs"},{"Title":"This","Url":"http:\/\/www.ruby-doc.org\/documentation-guidelines.html"},{"Title":"Standard Library","Url":"http:\/\/spec.ruby-doc.org\/wiki\/Ruby_Standard_Library"},{"Title":"Methods","Url":"http:\/\/www.ruby-doc.org\/core-1.8.7\/index.html"},{"Title":"Downloads","Url":"http:\/\/www.ruby-doc.org\/downloads\/"},{"Title":"Why Ruby","Url":"http:\/\/www.ruby-doc.org\/whyruby"},{"Title":"Ruby Spec: Core","Url":"http:\/\/spec.ruby-doc.org\/wiki\/Ruby_Core"},{"Title":"Ruby-Doc Docbar","Url":"http:\/\/www.ruby-doc.org\/docbar\/"},{"Title":"Status Report","Url":"http:\/\/www.ruby-doc.org\/stdlib\/status.html"}]},{"Title":"Ruby: Ruby mineral information and data.","Description":"A red, gem variety of Corundum. The red colour is caused by minor amounts of trivalent Cr replacing Al in the crystal structure. Pure Cr2O3 occurs in nature as the mineral <M ...","Url":"http:\/\/www.mindat.org\/min-3473.html","CacheUrl":"http:\/\/cc.bingj.com\/cache.aspx?q=ruby&d=4952668595489458&w=b55008d0,e8c4ddb4","DisplayUrl":"www.mindat.org\/min-3473.html","DateTime":"2010-02-28T21:43:01Z"},{"Title":"Ruby\/Ruby on Rails programming tutorials2 - Meshplex","Description":"Ruby for complete beginners: Ruby Introduction: What can I use RoR for? Reasons for choosing RoR over other popular programming languages such as php or asp.net .What makes Ruby so ...","Url":"http:\/\/www.meshplex.org\/wiki\/Ruby\/Ruby_on_Rails_programming_tutorials","CacheUrl":"http:\/\/cc.bingj.com\/cache.aspx?q=ruby&d=4741832947336861&w=2d9d5b96,9eaf0e4c","DisplayUrl":"www.meshplex.org\/wiki\/Ruby\/Ruby_on_Rails_programming_tutorials","DateTime":"2010-03-04T05:10:25Z"},{"Title":"Jack Ruby","Description":"Was Jack Ruby a mobster, a spook, or merely an emotional wannabe who expected public acclaim for killing Oswald?","Url":"http:\/\/mcadams.posc.mu.edu\/ruby.htm","CacheUrl":"http:\/\/cc.bingj.com\/cache.aspx?q=ruby&d=4935828028785085&w=a5cf0783,391d1a03","DisplayUrl":"mcadams.posc.mu.edu\/ruby.htm","DateTime":"2010-03-04T14:50:15Z"},{"Title":"Ruby-On-Rails","Description":"Ruby-On-Rails Developer's Journal ... Maximizing the Business Value of Virtualization in Enterprise and Cloud Computing Environments","Url":"http:\/\/ruby.sys-con.com\/","CacheUrl":"http:\/\/cc.bingj.com\/cache.aspx?q=ruby&d=4881479511180793&w=f0c3ddf5,73535976","DisplayUrl":"ruby.sys-con.com","DateTime":"2010-03-05T02:38:55Z"},{"Title":"The gemstone ruby","Description":"Ruby is distinguished and known by all for its fiery red color. Beside for its color, it is a most desirable gem due to its hardness, durability, luster, and rarity.","Url":"http:\/\/www.minerals.net\/gemstone\/gemstone\/ruby\/ruby.htm","CacheUrl":"http:\/\/cc.bingj.com\/cache.aspx?q=ruby&d=4621165840434460&w=ae21eda2,87c0c587","DisplayUrl":"www.minerals.net\/gemstone\/gemstone\/ruby\/ruby.htm","DateTime":"2010-03-05T02:53:14Z"},{"Title":"NetBeans IDE - Ruby and Ruby on Rails Development","Description":"NetBeans IDE - Integrated tools for Ruby and Ruby on Rails developers","Url":"http:\/\/netbeans.org\/features\/ruby\/index.html","CacheUrl":"http:\/\/cc.bingj.com\/cache.aspx?q=ruby&d=5027053135464027&w=d7848996,8be8650","DisplayUrl":"netbeans.org\/features\/ruby\/index.html","DateTime":"2010-03-04T03:37:22Z"},{"Title":"RubyForge: Ruby: Project Info","Description":"Tracker - Bugs ( 338 open \/ 809 total ) Bug Tracking System - Patches ( 69 open \/ 116 total ) Patch Tracking System - 1.9.1 showstoppers ( 0 open \/ 12 total )","Url":"http:\/\/rubyforge.org\/projects\/ruby\/","CacheUrl":"http:\/\/cc.bingj.com\/cache.aspx?q=ruby&d=4713537701086745&w=53c417ed,1ba0970c","DisplayUrl":"rubyforge.org\/projects\/ruby","DateTime":"2010-03-04T04:13:10Z"},{"Title":"Ruby - The Official Website | Coming Soon!","Description":"Ruby's Official Website ... Hey all, welcome to my official website. Here you find all my news, images, video clips & up-to-date information, the website is under construction so ...","Url":"http:\/\/rubymania.com\/","CacheUrl":"http:\/\/cc.bingj.com\/cache.aspx?q=ruby&d=5043382597191621&w=72b61cb5,7046900c","DisplayUrl":"rubymania.com","DateTime":"2010-03-04T17:42:03Z"},{"Title":"CSS3 Ruby Module","Description":"Abstract \"Ruby\" are short runs of text alongside the base text, typically used in East Asian documents to indicate pronunciation or to provide a short annotation.","Url":"http:\/\/www.w3.org\/TR\/css3-ruby\/","CacheUrl":"http:\/\/cc.bingj.com\/cache.aspx?q=ruby&d=4740681895184188&w=de16472f,c7ece477","DisplayUrl":"www.w3.org\/TR\/css3-ruby","DateTime":"2010-03-04T03:08:44Z"},{"Title":"Ruby Andrascik's Manotick Lifestyles","Description":"Sales representative in Manotick area. Recent sales, current listings, area information.","Url":"http:\/\/manoticklifestyles.com\/","CacheUrl":"http:\/\/cc.bingj.com\/cache.aspx?q=ruby&d=4985666828699639&w=6efb6d3f,50da2b69","DisplayUrl":"manoticklifestyles.com","DateTime":"2010-03-03T20:35:02Z"},{"Title":"Ruby","Description":"Abstract. The HyperText Markup Language (HTML) is a simple markup language used to create hypertext documents that are portable from one platform to another.","Url":"http:\/\/www.w3.org\/TR\/1999\/WD-ruby-19990924\/","CacheUrl":"http:\/\/cc.bingj.com\/cache.aspx?q=ruby&d=4820207509702663&w=8102eac9,23f9553","DisplayUrl":"www.w3.org\/TR\/1999\/WD-ruby-19990924","DateTime":"2010-03-05T07:32:24Z"},{"Title":"ruby - Wiktionary","Description":"This page was last modified on 10 February 2010, at 16:50. Text is available under the Creative Commons Attribution\/Share-Alike License; additional terms may apply.","Url":"http:\/\/en.wiktionary.org\/wiki\/ruby","CacheUrl":"http:\/\/cc.bingj.com\/cache.aspx?q=ruby&d=4826869002143668&w=81c2b50f,9ecab98e","DisplayUrl":"en.wiktionary.org\/wiki\/ruby","DateTime":"2010-03-04T22:57:01Z"}]}}}
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,29 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'rubygems'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+ require 'fakeweb'
7
+ require 'binged'
8
+
9
+ FakeWeb.allow_net_connect = false
10
+
11
+ Spec::Runner.configure do |config|
12
+
13
+ end
14
+
15
+ def bing_url(url)
16
+ "http://api.bing.net/json.aspx#{url}&Version=2.2&JsonType=raw&AppId=binged"
17
+ end
18
+
19
+ def fixture_file(filename)
20
+ return '' if filename == ''
21
+ file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
22
+ File.read(file_path)
23
+ end
24
+
25
+ def stub_get(url, filename, options={})
26
+ fakeweb_options = {:body => fixture_file(filename)}.merge(options)
27
+ FakeWeb.register_uri(:get, url, fakeweb_options)
28
+ end
29
+
metadata ADDED
@@ -0,0 +1,150 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: binged
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Kevin Faustino
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-03-07 00:00:00 -05:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: hashie
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 1
30
+ - 0
31
+ version: 0.1.0
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: crack
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ - 1
44
+ - 6
45
+ version: 0.1.6
46
+ type: :runtime
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: rspec
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 1
57
+ - 3
58
+ - 0
59
+ version: 1.3.0
60
+ type: :development
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: fakeweb
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 1
71
+ - 2
72
+ - 8
73
+ version: 1.2.8
74
+ type: :development
75
+ version_requirements: *id004
76
+ - !ruby/object:Gem::Dependency
77
+ name: yard
78
+ prerelease: false
79
+ requirement: &id005 !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ segments:
84
+ - 0
85
+ version: "0"
86
+ type: :development
87
+ version_requirements: *id005
88
+ description: A wrapper for the bing api
89
+ email: kevin.faustino@gmail.com
90
+ executables: []
91
+
92
+ extensions: []
93
+
94
+ extra_rdoc_files:
95
+ - LICENSE
96
+ - README.md
97
+ files:
98
+ - .document
99
+ - .gitignore
100
+ - HISTORY
101
+ - LICENSE
102
+ - README.md
103
+ - Rakefile
104
+ - VERSION
105
+ - binged.gemspec
106
+ - lib/binged.rb
107
+ - lib/binged/client.rb
108
+ - lib/binged/hashie_extensions.rb
109
+ - lib/binged/search.rb
110
+ - lib/binged/search/base.rb
111
+ - lib/binged/search/web.rb
112
+ - spec/binged/search/web_spec.rb
113
+ - spec/binged_spec.rb
114
+ - spec/fixtures/web.json
115
+ - spec/spec.opts
116
+ - spec/spec_helper.rb
117
+ has_rdoc: true
118
+ homepage: http://github.com/kfaustino/binged
119
+ licenses: []
120
+
121
+ post_install_message:
122
+ rdoc_options:
123
+ - --charset=UTF-8
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ segments:
131
+ - 0
132
+ version: "0"
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ segments:
138
+ - 0
139
+ version: "0"
140
+ requirements: []
141
+
142
+ rubyforge_project:
143
+ rubygems_version: 1.3.6
144
+ signing_key:
145
+ specification_version: 3
146
+ summary: A wrapper for the bing api
147
+ test_files:
148
+ - spec/binged/search/web_spec.rb
149
+ - spec/binged_spec.rb
150
+ - spec/spec_helper.rb