searchbing 0.0.7 → 0.0.8

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.
Files changed (3) hide show
  1. checksums.yaml +8 -8
  2. data/lib/searchbing.rb +21 -4
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- M2JmYmVhZGRhYTJlMjQ3N2UzMTI2NWY0YjBmNDI4YjI0OTNlNGNmMw==
4
+ OGU0NzM5ODZkNmMyOTA2YjBiZDEyMzY4OTUzMDIxZWMxYjkxNzI4NQ==
5
5
  data.tar.gz: !binary |-
6
- ODhjM2RiYTAzNTJhNWQzYTlhYmM3NTFmZWM2NjZjODRjODU5ZGM2OA==
6
+ N2I1NzUyOWEyNzIxNGI2Y2VmMmZjOWNjNmQzMjNlODc0NjVhM2M0Yg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YWM2MmYwYWYzYTA5MjdlOGMzMjJmODY1NmQ5MjVjOGFhMTkwZWNhYmZjODNj
10
- MTk4YzBhNGMxNDlkMWI4ZmEzZTA5YzFmY2Y4OThlOWE1YTgxYjVkYjAxYzgz
11
- NWM4ZjFkMWU0YWM2YTRhOGNiM2FhZjMwMmI4N2Y5Y2VjM2I5NDc=
9
+ ZjlmZDY1NDE5NTM5YjRjZDNkMGRmZTQwOWQ3MTczZDUwMzFkNWU5NmI1ZTJl
10
+ ZmI0MWQwZGJiYjMwMzI2MWY2YWRkYThhZWEwZGRlOTJjNzE1YzQwZjYyY2Jj
11
+ YzYyNTJlOTNkODQzYjYyMGFkZjM5MGVjMjg1ODdjMzNmNDg2NmQ=
12
12
  data.tar.gz: !binary |-
13
- NzNhYTE0ZWQ5ZTAxYjBjNjJmOTAwMGMxNDcwMDRjYThiOGIzMTY5ZjBkZmQx
14
- ZjZiN2U0ZWM5MzI0NzEyMDRhNjg1NDY5MWM0MzczOGEwYWI1YmEzNWEyMWU4
15
- ZDhkZjc3MzNiMDNkZWIyYTgxYWFiMWUzYjBjNjhiMzMxOGRjMDc=
13
+ MTI5NzU3NGUzNmIwZGI1MGFmOGQ0MGJmYjQ5MzY5ZWVhZjM5NWI2Mjc2OTVk
14
+ MGJjZTVjYTdjNjZjMmIwZTk1OTZmYzg5NTRmZWYzMzU3NmY5OWY1M2IxZDc1
15
+ YzBlNTQwZDU5ZWJhYjMyMWRhMzJiYThjZjlmMzg4YmFmMTNhN2M=
data/lib/searchbing.rb CHANGED
@@ -1,5 +1,14 @@
1
1
  class Bing
2
+ # Create a new object of the bing class
3
+ # >> animals = Bing.new('your_account_key_goes_here', 10, 'Image')
4
+ # => #<Bing:0x9d9b9f4 @accountKey="your_account_key", @num_results=10, @type="Image">
5
+ # Arguments:
6
+ # account_key: (String)
7
+ # num_results: (Integer)
8
+ # type: (String)
9
+
2
10
  def initialize(accountKey, num_results, type)
11
+
3
12
  @accountKey = accountKey
4
13
  @num_results = num_results
5
14
  @type = type
@@ -7,14 +16,22 @@ class Bing
7
16
 
8
17
  attr_accessor :accountKey, :num_results, :type
9
18
 
19
+ # Search for a term
20
+ # >> animals.search("lion")
21
+ # => #<Bing:0x9d9b9f4 @accountKey="your_account_key", @num_results=10, @type="Image">
22
+ # Arguments:
23
+ # search_term: (String)
24
+ # => "{\"d\":{\"results\":[{\"__metadata\":{\"uri\":\"https://api.datamarket....
25
+
10
26
  def search(search_term)
27
+
11
28
  user = ''
12
29
  web_search_url = "https://api.datamarket.azure.com/Bing/Search/#{type}?$format=json&Query="
13
- deuxieme = URI.encode_www_form_component('\'' + search_term + '\'')
14
- specs = "&$top=#{@num_results}"
15
- youknow = web_search_url + deuxieme + specs
30
+ query_portion = URI.encode_www_form_component('\'' + search_term + '\'')
31
+ params = "&$top=#{@num_results}"
32
+ full_address = web_search_url + query_portion + params
16
33
 
17
- uri = URI(youknow)
34
+ uri = URI(full_address)
18
35
  req = Net::HTTP::Get.new(uri.request_uri)
19
36
  req.basic_auth user, accountKey
20
37
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: searchbing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Culliton