jpignata-bossman 0.0.5 → 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.
- data/README +80 -53
- data/bossman.gemspec +2 -2
- data/lib/bossman/rest.rb +1 -1
- data/lib/bossman/result.rb +0 -1
- data/lib/bossman/resultset.rb +13 -4
- data/lib/bossman/search.rb +20 -25
- metadata +2 -2
data/README
CHANGED
@@ -1,9 +1,14 @@
|
|
1
|
-
= BOSSMan --
|
1
|
+
= BOSSMan -- Gem for interaction with the Yahoo BOSS web service
|
2
2
|
|
3
3
|
== Description
|
4
4
|
|
5
5
|
BOSSMan can be used to perform image, web and news searches against Yahoo's index. For more information about BOSS (Build your Own Search Service) please refer to http://developer.yahoo.com/search/boss/.
|
6
6
|
|
7
|
+
== Bugs, Features, Feedback
|
8
|
+
|
9
|
+
Feedback would be really appreciated. You can send it to me at john.pignata@gmail.com -- tickets can
|
10
|
+
be submitted by using Lighthouse: http://pignata.lighthouseapp.com/projects/15761-bossman
|
11
|
+
|
7
12
|
== Example Usage
|
8
13
|
|
9
14
|
=== Web
|
@@ -14,12 +19,12 @@ BOSSMan can be used to perform image, web and news searches against Yahoo's inde
|
|
14
19
|
|
15
20
|
BOSSMan.application_id = <Your Application ID>
|
16
21
|
|
17
|
-
|
22
|
+
return = BOSSMan::Search.web("prospect park", { :count => 5, :filter => "-hate" })
|
18
23
|
|
19
|
-
puts "Number of results: #{
|
24
|
+
puts "Number of results: #{return.totalhits}"
|
20
25
|
puts
|
21
26
|
|
22
|
-
|
27
|
+
return.results.each do |result|
|
23
28
|
puts "#{result.title}"
|
24
29
|
puts "-" * 80
|
25
30
|
puts "#{result.abstract}"
|
@@ -34,9 +39,9 @@ BOSSMan can be used to perform image, web and news searches against Yahoo's inde
|
|
34
39
|
|
35
40
|
BOSSMan.application_id = <Your Application ID>
|
36
41
|
|
37
|
-
|
42
|
+
return = BOSSMan::Search.news("brooklyn new york", { :age => "7d" })
|
38
43
|
|
39
|
-
|
44
|
+
return.results.each do |result|
|
40
45
|
puts "#{result.title} [from #{result.source}]"
|
41
46
|
puts "-" * 80
|
42
47
|
puts "#{result.abstract}"
|
@@ -50,69 +55,91 @@ BOSSMan can be used to perform image, web and news searches against Yahoo's inde
|
|
50
55
|
|
51
56
|
BOSSMan.application_id = <Your Application ID>
|
52
57
|
|
53
|
-
|
58
|
+
dumbo = BOSSMan::Search.images("brooklyn dumbo", { :dimensions => "large" })
|
54
59
|
|
55
|
-
|
56
|
-
puts "
|
60
|
+
return.results.each do |result|
|
61
|
+
puts "#{result.url}: #{result.abstract}"
|
57
62
|
end
|
58
63
|
|
64
|
+
=== Spelling
|
65
|
+
|
66
|
+
require 'rubygems'
|
67
|
+
require 'bossman'
|
68
|
+
include BOSSMan
|
69
|
+
|
70
|
+
BOSSMan.application_id = <Your Application ID>
|
71
|
+
|
72
|
+
return = BOSSMan::Search.spelling("Diabretes")
|
73
|
+
|
74
|
+
puts result.suggestion
|
59
75
|
|
60
76
|
== Output Objects
|
61
77
|
|
78
|
+
Assuming an object returned called search:
|
79
|
+
|
80
|
+
search = BOSSMan::Search.web("staten island", 0, 20)
|
81
|
+
|
62
82
|
=== Common
|
63
83
|
|
64
|
-
.responsecode
|
65
|
-
.nextpage
|
66
|
-
.count : Number of search results contained in response
|
67
|
-
.start : Search result from which output starts
|
68
|
-
.totalhits : De-duplicated total number of results search yielded
|
69
|
-
.deephits
|
70
|
-
.results[].clickurl : Tracking URL of result; must be used in user-facing
|
71
|
-
|
84
|
+
search.responsecode : HTTP response code
|
85
|
+
search.nextpage : REST URL to next page of search results
|
86
|
+
search.count : Number of search results contained in response
|
87
|
+
search.start : Search result from which output starts
|
88
|
+
search.totalhits : De-duplicated total number of results search yielded
|
89
|
+
search.deephits : Total number of results search yielded
|
90
|
+
search.results[].clickurl : Tracking URL of result; must be used in user-facing
|
91
|
+
anchor tags by BOSS TOU
|
92
|
+
search.results[].url : URL of result
|
72
93
|
|
73
94
|
=== Web
|
74
95
|
|
75
|
-
.results[].abstract : Description of result with keywords emboldened
|
76
|
-
.results[].title
|
77
|
-
.results[].dispurl : Display URL of result
|
78
|
-
.results[].size : Size of result in bytes
|
79
|
-
.results[].date : Date result was indexed
|
96
|
+
search.results[].abstract : Description of result with keywords emboldened
|
97
|
+
search.results[].title : Document title with keywords emboldened
|
98
|
+
search.results[].dispurl : Display URL of result
|
99
|
+
search.results[].size : Size of result in bytes
|
100
|
+
search.results[].date : Date result was indexed
|
80
101
|
|
81
102
|
=== News
|
82
103
|
|
83
|
-
.results[].abstract : Description of news story
|
84
|
-
.results[].title
|
85
|
-
.results[].language : Language of news story
|
86
|
-
.results[].date : Last publication date of news story
|
87
|
-
.results[].time : Last publication time of news story
|
88
|
-
.results[].source
|
89
|
-
.results[].sourceurl
|
104
|
+
search.results[].abstract : Description of news story
|
105
|
+
search.results[].title : Title of news story
|
106
|
+
search.results[].language : Language of news story
|
107
|
+
search.results[].date : Last publication date of news story
|
108
|
+
search.results[].time : Last publication time of news story
|
109
|
+
search.results[].source : Source of news story
|
110
|
+
search.results[].sourceurl : URL of source publication
|
90
111
|
|
91
112
|
=== Images
|
92
113
|
|
93
|
-
.results[].abstract : Description of image
|
94
|
-
.results[].filename : Filename of image
|
95
|
-
.results[].size : Size of image
|
96
|
-
.results[].format
|
97
|
-
.results[].height
|
98
|
-
.results[].date : Last modification date of image (YYYY/MM/DD)
|
99
|
-
.results[].mimetype : MIME type of image
|
100
|
-
.results[].refererclickurl : Link to page where image was found
|
101
|
-
.results[].refererurl : Link to page where image was found
|
102
|
-
.results[].title
|
103
|
-
.results[].width
|
104
|
-
.results[].thumbnailurl : URL of thumbnail image
|
105
|
-
.results[].thumbnail_height
|
106
|
-
.results[].thumbnail_width
|
107
|
-
|
108
|
-
===
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
114
|
+
search.results[].abstract : Description of image
|
115
|
+
search.results[].filename : Filename of image
|
116
|
+
search.results[].size : Size of image
|
117
|
+
search.results[].format : Format of image
|
118
|
+
search.results[].height : Height of full-size image
|
119
|
+
search.results[].date : Last modification date of image (YYYY/MM/DD)
|
120
|
+
search.results[].mimetype : MIME type of image
|
121
|
+
search.results[].refererclickurl : Link to page where image was found
|
122
|
+
search.results[].refererurl : Link to page where image was found
|
123
|
+
search.results[].title : Title of image (usually the filename)
|
124
|
+
search.results[].width : Width of full-size image
|
125
|
+
search.results[].thumbnailurl : URL of thumbnail image
|
126
|
+
search.results[].thumbnail_height : Height of thumbnail image
|
127
|
+
search.results[].thumbnail_width : Width of thumbnail image
|
128
|
+
|
129
|
+
=== Spelling
|
130
|
+
|
131
|
+
search.suggestion : Returns spelling suggestion from BOSS
|
132
|
+
|
133
|
+
=== Raw dump formats
|
134
|
+
|
135
|
+
Resultsets are returnable in JSON, XML and YAML by use of to_json, to_xml (or to_s), to_yaml respectively.
|
136
|
+
|
137
|
+
search : dumps XML of entire resultset
|
138
|
+
search.to_json : dumps JSON of entire resultset
|
139
|
+
search.to_yaml : dumps YAML of entire resultset
|
140
|
+
search.results[3] : dumps XML of one search result
|
141
|
+
search.results[3].to_json : dumps JSON of one search result
|
142
|
+
search.results[3].to_yaml : dumps YAML of one search result
|
116
143
|
|
117
144
|
== Installation
|
118
145
|
|
@@ -146,4 +173,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
146
173
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
147
174
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
148
175
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
149
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
176
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/bossman.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "bossman"
|
3
|
-
s.version = "0.0
|
4
|
-
s.date = "2008-08-
|
3
|
+
s.version = "0.1.0"
|
4
|
+
s.date = "2008-08-27"
|
5
5
|
s.summary = "Class for interaction with the Yahoo BOSS web service."
|
6
6
|
s.email = "jpignata@waterfrontmedia.com"
|
7
7
|
s.homepage = "http://github.com/jpignata/bossman-gem"
|
data/lib/bossman/rest.rb
CHANGED
data/lib/bossman/result.rb
CHANGED
data/lib/bossman/resultset.rb
CHANGED
@@ -5,7 +5,9 @@ module BOSSMan
|
|
5
5
|
@response = response
|
6
6
|
|
7
7
|
@response["ysearchresponse"].each do |key, value|
|
8
|
-
if key.include? "
|
8
|
+
if key.include? "resultset_spell"
|
9
|
+
set_parameter("suggestion", @response["ysearchresponse"]["resultset_spell"][0]["suggestion"])
|
10
|
+
elsif key.include? "resultset"
|
9
11
|
results = Array.new
|
10
12
|
response["ysearchresponse"][key].each { |result| results << Result.new(result) }
|
11
13
|
set_parameter("results", results)
|
@@ -14,12 +16,19 @@ module BOSSMan
|
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
17
|
-
|
19
|
+
|
18
20
|
def to_xml
|
19
21
|
@response['ysearchresponse'].to_xml(:root => 'resultset')
|
20
22
|
end
|
21
|
-
|
23
|
+
|
24
|
+
def _dump(level)
|
25
|
+
@response.to_json
|
26
|
+
end
|
27
|
+
|
28
|
+
def self._load(string)
|
29
|
+
ResultSet.new(ActiveSupport::JSON.decode(string))
|
30
|
+
end
|
31
|
+
|
22
32
|
alias to_s to_xml
|
23
|
-
|
24
33
|
end
|
25
34
|
end
|
data/lib/bossman/search.rb
CHANGED
@@ -1,43 +1,38 @@
|
|
1
1
|
module BOSSMan
|
2
2
|
class Search
|
3
3
|
class << self
|
4
|
-
|
5
|
-
|
4
|
+
DEFAULT_COUNT = 10
|
5
|
+
DEFAULT_START = 0
|
6
|
+
|
7
|
+
def web(query, options = {})
|
6
8
|
method = "web"
|
7
|
-
|
8
|
-
options = default_options(BOSSMan.application_id, count, start)
|
9
|
-
options[:filter] = filter if filter
|
10
|
-
options[:type] = type if type
|
11
|
-
options[:lang] = lang if lang
|
12
|
-
options[:region] = region if region
|
13
|
-
|
9
|
+
options.merge!(return_options(options))
|
14
10
|
return REST.get(method, query, options)
|
15
11
|
end
|
16
12
|
|
17
|
-
def images(query,
|
13
|
+
def images(query, options = {})
|
18
14
|
method = "images"
|
19
|
-
|
20
|
-
options = default_options(BOSSMan.application_id, count, start)
|
21
|
-
options[:filter] = filter if filter
|
22
|
-
options[:dimensions] = dimensions if dimensions
|
23
|
-
options[:refererurl] = refererurl if refererurl
|
24
|
-
options[:url] = url if url
|
25
|
-
|
15
|
+
options.merge!(return_options(options))
|
26
16
|
return REST.get(method, query, options)
|
27
17
|
end
|
28
18
|
|
29
|
-
def news(query,
|
19
|
+
def news(query, options = {})
|
30
20
|
method = "news"
|
31
|
-
|
32
|
-
options = default_options(BOSSMan.application_id, count, start)
|
33
|
-
options[:age] = age if age
|
34
|
-
|
21
|
+
options.merge!(return_options(options))
|
35
22
|
return REST.get(method, query, options)
|
36
23
|
end
|
37
24
|
|
38
|
-
|
39
|
-
|
40
|
-
|
25
|
+
def spelling(query, options = {})
|
26
|
+
method = "spelling"
|
27
|
+
options.merge!(return_options(options))
|
28
|
+
return REST.get(method, query, options)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
def return_options(options)
|
33
|
+
count = options[:count] ? options[:count] : DEFAULT_COUNT
|
34
|
+
start = options[:start] ? options[:start] : DEFAULT_START
|
35
|
+
return {:appid => BOSSMan.application_id, :count => count, :start => start }
|
41
36
|
end
|
42
37
|
|
43
38
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jpignata-bossman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jay Pignata
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-08-
|
12
|
+
date: 2008-08-27 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|