bingo 0.1.0
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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/README.md +83 -0
- data/Rakefile +9 -0
- data/bingo.gemspec +27 -0
- data/circle.yml +3 -0
- data/lib/bingo.rb +41 -0
- data/lib/bingo/version.rb +3 -0
- metadata +136 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6810a3626179e295830bfa6bbb82ca1c416c88bf
|
4
|
+
data.tar.gz: c03dcdc2bdaee7e00207b19427da0510a4a4704a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1b77b2cba60c4c5bb26c405420fd9159b36bd70f3014a29c40c87a2bf36290abacfc85e8a84400c1451e5a746744cffd95b3801de4acdbe857187645951673f2
|
7
|
+
data.tar.gz: 5ef695979c488e7ed836db5052c349ef615786c15f54a8c1fa8ff08cb3369db17265bc1c858d1cc452330103129a7cd52a9f240c826718abea8c845859386c57
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# Bingo
|
2
|
+
|
3
|
+
[](https://circleci.com/gh/tomoya55/bingo/tree/master)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'bingo'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install bingo
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```
|
24
|
+
$ Bingo.search('your_account_key', 'ruby')
|
25
|
+
#=>
|
26
|
+
{
|
27
|
+
"d": {
|
28
|
+
"results": [
|
29
|
+
{
|
30
|
+
"__metadata": {
|
31
|
+
"uri": "https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/v1/Web?Query='ruby'&$skip=0&$top=1",
|
32
|
+
"type": "WebResult"
|
33
|
+
},
|
34
|
+
"ID": "4e17655c-00e0-4ef1-8337-609f11530507",
|
35
|
+
"Title": "Ruby - Wikipedia, la enciclopedia libre",
|
36
|
+
"Description": "Ruby es un lenguaje de programación interpretado , reflexivo y orientado a objetos , creado por el programador japonés Yukihiro \"Matz\" Matsumoto , quien comenzó a ...",
|
37
|
+
"DisplayUrl": "es.wikipedia.org/wiki/Ruby",
|
38
|
+
"Url": "http://es.wikipedia.org/wiki/Ruby"
|
39
|
+
}
|
40
|
+
...
|
41
|
+
]
|
42
|
+
}
|
43
|
+
}
|
44
|
+
```
|
45
|
+
|
46
|
+
## Current Development status
|
47
|
+
|
48
|
+
### API
|
49
|
+
|
50
|
+
Simple Bing Search API Client for Ruby.
|
51
|
+
Currently [Bing Search API – Web Results Only](https://datamarket.azure.com/dataset/bing/searchweb#schema) is supported, but is planned to support [Bing Search API](https://datamarket.azure.com/dataset/5BA839F1-12CE-4CCE-BF57-A49D98D29A44) as well.
|
52
|
+
|
53
|
+
### Response format
|
54
|
+
|
55
|
+
Only JSON is available. ATOM(XML) is planned to be supported before v1.0.0.
|
56
|
+
|
57
|
+
## Getting Account Key on Microsoft Windows Azure Marketplace
|
58
|
+
|
59
|
+
(TBD)
|
60
|
+
|
61
|
+
## Development
|
62
|
+
|
63
|
+
### Setup
|
64
|
+
|
65
|
+
```
|
66
|
+
git clone https://github.com/tomoya55/bingo.git
|
67
|
+
cd bingo
|
68
|
+
bundle
|
69
|
+
```
|
70
|
+
|
71
|
+
### Run test
|
72
|
+
|
73
|
+
```
|
74
|
+
bundle exec rake test
|
75
|
+
```
|
76
|
+
|
77
|
+
## Contributing
|
78
|
+
|
79
|
+
1. Fork it ( https://github.com/[my-github-username]/bingo/fork )
|
80
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
81
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
82
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
83
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bingo.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bingo/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bingo"
|
8
|
+
spec.version = Bingo::VERSION
|
9
|
+
spec.authors = ["Tomoya Hirano"]
|
10
|
+
spec.email = ["tomoya@nicecabbage.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Microsoft Bing Search API Client}
|
13
|
+
spec.description = %q{Bing Search API Client on Windows Azure Marketplace}
|
14
|
+
spec.homepage = "http://github.com/tomoya55/bingo"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_runtime_dependency "http", "~> 0.8"
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
|
24
|
+
spec.add_development_dependency "minitest"
|
25
|
+
spec.add_development_dependency "minitest-power_assert"
|
26
|
+
spec.add_development_dependency "webmock"
|
27
|
+
end
|
data/circle.yml
ADDED
data/lib/bingo.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require "bingo/version"
|
2
|
+
require "logger"
|
3
|
+
require "http"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module Bingo
|
7
|
+
def self.search(account_key, query, size: 20, from: 0)
|
8
|
+
BingoClient.new(account_key).search(query, from: from, size: size)
|
9
|
+
end
|
10
|
+
|
11
|
+
class BingoClient
|
12
|
+
API_ENDPOINT = "https://api.datamarket.azure.com/Bing/SearchWeb/v1/Web".freeze
|
13
|
+
|
14
|
+
attr_reader :user, :account_key, :logger
|
15
|
+
|
16
|
+
def initialize(account_key, logger = ::Logger.new('/dev/null'))
|
17
|
+
@user = ''
|
18
|
+
@account_key = account_key
|
19
|
+
@logger = logger
|
20
|
+
end
|
21
|
+
|
22
|
+
def search(query, options = {})
|
23
|
+
response = perform_search(query, options)
|
24
|
+
json = JSON.parse(response.body)
|
25
|
+
json["d"]["results"]
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def perform_search(query, options = {})
|
31
|
+
HTTP.
|
32
|
+
basic_auth(user: user, pass: account_key).
|
33
|
+
get(API_ENDPOINT, params: {
|
34
|
+
"Query" => "'#{query}'",
|
35
|
+
"$format" => "json",
|
36
|
+
"$top" => options[:size] || 10,
|
37
|
+
"$skip" => options[:from] || 0
|
38
|
+
})
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bingo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tomoya Hirano
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: http
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.8'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.9'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.9'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest-power_assert
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webmock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Bing Search API Client on Windows Azure Marketplace
|
98
|
+
email:
|
99
|
+
- tomoya@nicecabbage.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- Gemfile
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
109
|
+
- bingo.gemspec
|
110
|
+
- circle.yml
|
111
|
+
- lib/bingo.rb
|
112
|
+
- lib/bingo/version.rb
|
113
|
+
homepage: http://github.com/tomoya55/bingo
|
114
|
+
licenses: []
|
115
|
+
metadata: {}
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
require_paths:
|
119
|
+
- lib
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
requirements: []
|
131
|
+
rubyforge_project:
|
132
|
+
rubygems_version: 2.4.5
|
133
|
+
signing_key:
|
134
|
+
specification_version: 4
|
135
|
+
summary: Microsoft Bing Search API Client
|
136
|
+
test_files: []
|