searchbing 0.0.8 → 0.0.9
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 +8 -8
- data/lib/searchbing.rb +9 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YmE2ZWI1ZDU2YTU4ODZlMWEwMzM2MzQ4OWM1Nzc5NjA2MDRiMGI1ZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzI4Njc4ZjMxNGU1NGY0YTMxNmIyODNjYWJlYmRjNWZjZDUwNTMyOA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmVkMmU5MjU5MjRiYjlkYjM5NjgyMjMxYjExY2M2NmJhMWM0NjMxMmI5ZDQz
|
10
|
+
MDY1MTdjNTdmMGQwZDM4ZDAwY2YxNjgzZTdjZWVjMDIwYzFlNTkzZTU2YjZl
|
11
|
+
NjdkYTUyZjZmOTMyOGZiZTcwODQ5OWM1ZDRhMWIwMThhNjlkZDg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MTA4Yjc5ZWRmMjE3YjE4ZmY0MzA2MjJiYmRhYjY5ZDhhM2M1YjAyNmYzN2Mw
|
14
|
+
YzQwOWI5ZTA4NTk3ZDY0MzJjMmUwZGNmYjRiMjU5MzRiNzA1ZDI2MGU5YWE1
|
15
|
+
Zjk4OTgxYjlkYmFmODZmOWM2ZmMwNjA5ZDZlNGU3MzczYzQzNWM=
|
data/lib/searchbing.rb
CHANGED
@@ -1,27 +1,28 @@
|
|
1
|
+
# The Bing Class provides the ability to connect to the bing search api hosted on the windows azure marketplace.
|
2
|
+
# Before proceeding you will need an account key, which can be obtained by registering an accout at http://windows.microsoft.com/en-US/windows-live/sign-in-what-is-microsoft-account
|
1
3
|
class Bing
|
2
4
|
# Create a new object of the bing class
|
3
5
|
# >> animals = Bing.new('your_account_key_goes_here', 10, 'Image')
|
4
|
-
# => #<Bing:0x9d9b9f4 @
|
6
|
+
# => #<Bing:0x9d9b9f4 @account_key="your_account_key", @num_results=10, @type="Image">
|
5
7
|
# Arguments:
|
6
8
|
# account_key: (String)
|
7
9
|
# num_results: (Integer)
|
8
10
|
# type: (String)
|
9
11
|
|
10
|
-
def initialize(
|
12
|
+
def initialize(account_key, num_results, type)
|
11
13
|
|
12
|
-
@
|
14
|
+
@account_key = account_key
|
13
15
|
@num_results = num_results
|
14
16
|
@type = type
|
15
17
|
end
|
16
18
|
|
17
|
-
attr_accessor :
|
19
|
+
attr_accessor :account_key, :num_results, :type
|
18
20
|
|
19
21
|
# Search for a term
|
20
22
|
# >> animals.search("lion")
|
21
|
-
# =>
|
23
|
+
# => "{\"d\":{\"results\":[{\"__metadata\":{\"uri\":\"https://api.datamarket....
|
22
24
|
# Arguments:
|
23
25
|
# search_term: (String)
|
24
|
-
# => "{\"d\":{\"results\":[{\"__metadata\":{\"uri\":\"https://api.datamarket....
|
25
26
|
|
26
27
|
def search(search_term)
|
27
28
|
|
@@ -33,12 +34,13 @@ class Bing
|
|
33
34
|
|
34
35
|
uri = URI(full_address)
|
35
36
|
req = Net::HTTP::Get.new(uri.request_uri)
|
36
|
-
req.basic_auth user,
|
37
|
+
req.basic_auth user, account_key
|
37
38
|
|
38
39
|
res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https'){|http|
|
39
40
|
http.request(req)
|
40
41
|
}
|
41
42
|
|
42
43
|
res.body
|
44
|
+
|
43
45
|
end
|
44
46
|
end
|