boss 0.2 → 0.3
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.
- data/README +4 -1
- data/Rakefile +1 -1
- data/lib/boss.rb +42 -9
- metadata +2 -2
data/README
CHANGED
@@ -13,6 +13,8 @@ require 'boss'
|
|
13
13
|
|
14
14
|
boss.appid = 'Bossdemo' # Set the BOSS appid to what Yahoo assigned you.
|
15
15
|
|
16
|
+
count="10" start="0" totalhits="8775"deephits="8775"
|
17
|
+
|
16
18
|
image_example = boss.images.new('soccer', :count => 30) # Sets a new images resultset of 30 matching 'soccer'.
|
17
19
|
image_example.resultset.each do |r| # Gets current images resultset.
|
18
20
|
r.abstract # Now we don't know Crawford from Adam but he's a good friend of WCP-occasional-contributor Beans and he somewhat has a point, or at least made us laugh while making it.
|
@@ -22,7 +24,7 @@ image_example.resultset.each do |r| # Gets current images resultset.
|
|
22
24
|
r.format # jpeg
|
23
25
|
r.height # 213
|
24
26
|
r.mimetype # image/jpeg
|
25
|
-
r.
|
27
|
+
r.refererclickurl # http://wickedchopspoker.blogs.com/my_weblog/2006/06/world_cup_musin.html
|
26
28
|
r.refererurl # http://wickedchopspoker.blogs.com/my_weblog/2006/06/world_cup_musin.html
|
27
29
|
r.size # 31500
|
28
30
|
r.thumbnail_height # 120
|
@@ -50,6 +52,7 @@ news_example.nextpage # Returns string for next news resultset.
|
|
50
52
|
|
51
53
|
spelling_example = boss.spelling.new # Sets a new spelling resultset.
|
52
54
|
spelling_example.resultset.each do |r| # Gets current spelling resultset.
|
55
|
+
r.query # monkeys+giraffes
|
53
56
|
r.suggestion # monkeys giraffes
|
54
57
|
spelling_example.nextpage # Returns string for next spelling resultset.
|
55
58
|
|
data/Rakefile
CHANGED
data/lib/boss.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
require 'cgi'
|
2
3
|
require 'uri'
|
3
4
|
require 'net/http'
|
4
5
|
require 'json'
|
@@ -19,15 +20,19 @@ module Boss
|
|
19
20
|
@query = URI.encode(q)
|
20
21
|
@arguments = arguments(a)
|
21
22
|
end
|
23
|
+
|
24
|
+
def count
|
25
|
+
ysearchresponse['count'].to_i
|
26
|
+
end
|
22
27
|
|
23
28
|
def nextpage
|
24
29
|
ysearchresponse['nextpage']
|
25
30
|
end
|
26
31
|
|
27
32
|
def response
|
28
|
-
ysearchresponse["resultset_#{service}"]
|
33
|
+
ysearchresponse["resultset_#{service}"]
|
29
34
|
end
|
30
|
-
|
35
|
+
|
31
36
|
private
|
32
37
|
|
33
38
|
def arguments(a = {})
|
@@ -65,7 +70,11 @@ module Boss
|
|
65
70
|
include Resultset
|
66
71
|
|
67
72
|
def resultset
|
68
|
-
|
73
|
+
if count > 0
|
74
|
+
response.collect{|r| Result.new(r)}
|
75
|
+
else
|
76
|
+
response
|
77
|
+
end
|
69
78
|
end
|
70
79
|
|
71
80
|
class Result
|
@@ -149,7 +158,11 @@ module Boss
|
|
149
158
|
include Resultset
|
150
159
|
|
151
160
|
def resultset
|
152
|
-
|
161
|
+
if count > 0
|
162
|
+
response.collect{|r| Result.new(r)}
|
163
|
+
else
|
164
|
+
response
|
165
|
+
end
|
153
166
|
end
|
154
167
|
|
155
168
|
class Result
|
@@ -204,8 +217,16 @@ module Boss
|
|
204
217
|
|
205
218
|
include Resultset
|
206
219
|
|
220
|
+
def response
|
221
|
+
ysearchresponse['resultset_spell']
|
222
|
+
end
|
223
|
+
|
207
224
|
def resultset
|
208
|
-
|
225
|
+
if count > 0
|
226
|
+
response.collect{|r| Result.new(r)}
|
227
|
+
else
|
228
|
+
response
|
229
|
+
end
|
209
230
|
end
|
210
231
|
|
211
232
|
class Result
|
@@ -215,11 +236,15 @@ module Boss
|
|
215
236
|
def initialize(r)
|
216
237
|
@result = r
|
217
238
|
end
|
218
|
-
|
239
|
+
|
240
|
+
def query
|
241
|
+
CGI.escape(suggestion)
|
242
|
+
end
|
243
|
+
|
219
244
|
def suggestion
|
220
245
|
@result['suggestion']
|
221
246
|
end
|
222
|
-
|
247
|
+
|
223
248
|
end
|
224
249
|
|
225
250
|
end
|
@@ -229,7 +254,11 @@ module Boss
|
|
229
254
|
include Resultset
|
230
255
|
|
231
256
|
def resultset
|
232
|
-
|
257
|
+
if count > 0
|
258
|
+
response.collect{|r| Result.new(r)}
|
259
|
+
else
|
260
|
+
response
|
261
|
+
end
|
233
262
|
end
|
234
263
|
|
235
264
|
class Result
|
@@ -240,6 +269,10 @@ module Boss
|
|
240
269
|
@result = r
|
241
270
|
end
|
242
271
|
|
272
|
+
def strip_wbr(s)
|
273
|
+
s.gsub(/<wbr>/, '')
|
274
|
+
end
|
275
|
+
|
243
276
|
def abstract
|
244
277
|
@result['abstract']
|
245
278
|
end
|
@@ -255,7 +288,7 @@ module Boss
|
|
255
288
|
def dispurl(options = {})
|
256
289
|
data = @result['dispurl']
|
257
290
|
if options[:wbr] == false
|
258
|
-
data
|
291
|
+
strip_wbr(data)
|
259
292
|
else
|
260
293
|
data
|
261
294
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "0.
|
4
|
+
version: "0.3"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- UiPoet
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-12-
|
12
|
+
date: 2008-12-17 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|