bossman 0.3.0 → 0.4.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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008 Jay Pignata
1
+ Copyright (c) 2009 Jay Pignata
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -8,7 +8,7 @@ This is an older project - I'd encourage you to look at the great HTTParty (http
8
8
 
9
9
  ## Bugs, Features, Feedback
10
10
 
11
- Tickets can be submitted by using GitHub issues.
11
+ Tickets can be submitted by via GitHub issues.
12
12
 
13
13
  ## Example Usage
14
14
 
@@ -60,8 +60,24 @@ Tickets can be submitted by using GitHub issues.
60
60
  boss.suggestion
61
61
 
62
62
  => Diabetes
63
-
64
- ## Output Objects
63
+
64
+ ### BOSS Site Explorer
65
+
66
+ #### se_inlink can be used to query Yahoo for sites that link to a given URL:
67
+
68
+ links = Search.se_inlink("www.wnyc.com")
69
+ links.results.map { |result| result.url }
70
+
71
+ => ["http://www.wnyc.org/", "http://www.onthemedia.org/", "http://www.wnyc.org/shows/radiolab/", "http://cityroom.blogs.nytimes.com/2008/01/22/actor-heath-ledger-is-found-dead", "http://www.streetsblog.org/", "http://cityroom.blogs.nytimes.com/", "http://www.notmuch.com/", "http://www.williams-syndrome.org/", "http://www.manhattancc.org/", "http://scienceblogs.com/grrlscientist/"]
72
+
73
+ #### se_pagedata will return a list of pages underneath a given subdomain:
74
+
75
+ pages = Search.se_inlink("www.webmd.com")
76
+ pages.results.map { |result| result.url }
77
+
78
+ => ["http://www.webmd.com/", "http://www.webmd.com/allergies", "http://www.webmd.com/a-to-z-guides/temporomandibular-disorders", "http://www.webmd.com/oral-health/dental-crowns", "http://www.webmd.com/oral-health/dental-health-bridges", "http://www.webmd.com/oral-health/dental-implants", "http://www.webmd.com/oral-health/guide/canker-sores", "http://www.webmd.com/oral-health/guide/teeth-grinding-bruxism", "http://www.webmd.com/oral-health/guide/gingivitis-periodontal-disease", "http://www.webmd.com/oral-health/guide/plaque-and-your-teeth"]
79
+
80
+ ## Output Properties
65
81
 
66
82
  ### Common
67
83
 
@@ -73,19 +89,17 @@ Tickets can be submitted by using GitHub issues.
73
89
  - search.deephits : Total number of results search yielded
74
90
  - search.results[].clickurl : Tracking URL of result; must be used in user-facing anchor tags by BOSS TOU
75
91
  - search.results[].url : URL of result
92
+ - search.results[].title : Title of item
93
+ - search.results[].abstract : Description of item
76
94
 
77
95
  ### Web
78
96
 
79
- - search.results[].abstract : Description of result with keywords emboldened
80
- - search.results[].title : Document title with keywords emboldened
81
97
  - search.results[].dispurl : Display URL of result
82
98
  - search.results[].size : Size of result in bytes
83
99
  - search.results[].date : Date result was indexed
84
100
 
85
101
  ### News
86
102
 
87
- - search.results[].abstract : Description of news story
88
- - search.results[].title : Title of news story
89
103
  - search.results[].language : Language of news story
90
104
  - search.results[].date : Last publication date of news story
91
105
  - search.results[].time : Last publication time of news story
@@ -94,7 +108,6 @@ Tickets can be submitted by using GitHub issues.
94
108
 
95
109
  ### Images
96
110
 
97
- - search.results[].abstract : Description of image
98
111
  - search.results[].filename : Filename of image
99
112
  - search.results[].size : Size of image
100
113
  - search.results[].format : Format of image
@@ -103,7 +116,6 @@ Tickets can be submitted by using GitHub issues.
103
116
  - search.results[].mimetype : MIME type of image
104
117
  - search.results[].refererclickurl : Link to page where image was found
105
118
  - search.results[].refererurl : Link to page where image was found
106
- - search.results[].title : Title of image (usually the filename)
107
119
  - search.results[].width : Width of full-size image
108
120
  - search.results[].thumbnail_url : URL of thumbnail image
109
121
  - search.results[].thumbnail_height : Height of thumbnail image
@@ -132,14 +144,15 @@ Result sets can be dumped as JSON, XML and YAML by use of to_json, to_xml, to_ya
132
144
 
133
145
  ## Requirements
134
146
 
135
- - Active Support >= 2.1
136
- - FakeWeb (in order to run the specs)
147
+ * FakeWeb = 1.2.6
148
+ * RSpec >= 1.2.9
149
+ * Active Support >= 2.1
137
150
 
138
151
  ## LICENSE:
139
152
 
140
153
  (The MIT License)
141
154
 
142
- Copyright (c) 2008 Jay Pignata
155
+ Copyright (c) 2009 Jay Pignata
143
156
 
144
157
  Permission is hereby granted, free of charge, to any person obtaining
145
158
  a copy of this software and associated documentation files (the
data/lib/bossman/boss.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  module BOSSMan
2
2
  class BOSS
3
+ HTTP_HEADERS = { 'Accept-Encoding' => 'gzip' }
3
4
 
4
5
  def initialize(method, query, options)
5
6
  @options = options
@@ -7,7 +8,7 @@ module BOSSMan
7
8
 
8
9
  @uri = URI.parse(URI.encode("#{API_BASEURI}/#{method}/#{API_VERSION}/#{query}"))
9
10
  @uri.query = @options.to_query
10
- @request = Net::HTTP::Get.new(@uri.request_uri)
11
+ @request = Net::HTTP::Get.new(@uri.request_uri, HTTP_HEADERS)
11
12
  end
12
13
 
13
14
  def get
@@ -34,9 +35,7 @@ module BOSSMan
34
35
  raise MissingConfiguration, "Application ID must be set prior to making a service call."
35
36
  end
36
37
 
37
- if @options[:count] <= 0
38
- raise InvalidParameter, "Invalid count. Count must be > 0."
39
- end
38
+ @options[:count] = 10 unless @options.include?(:count) && @options[:count] > 0
40
39
  end
41
40
  end
42
41
  end
@@ -9,7 +9,7 @@ module BOSSMan
9
9
  method, query, options = args
10
10
  super unless VALID_METHODS.include?(method)
11
11
  options = {} if options.nil?
12
- boss = BOSS.new(method, query, options_defaults.merge!(options))
12
+ boss = BOSS.new(method, query, options_defaults.merge(options))
13
13
  boss.get
14
14
  end
15
15
  end
data/lib/bossman.rb CHANGED
@@ -2,7 +2,13 @@ require 'active_support'
2
2
  require 'net/http'
3
3
  require 'uri'
4
4
 
5
- Dir["#{File.dirname(__FILE__)}/bossman/*.rb"].sort.each { |bossman_lib| require bossman_lib }
5
+ require 'extensions/http_success'
6
+
7
+ require 'bossman/base_value_object'
8
+ require 'bossman/boss'
9
+ require 'bossman/result_set'
10
+ require 'bossman/result'
11
+ require 'bossman/search'
6
12
 
7
13
  module BOSSMan
8
14
  API_VERSION = :v1
@@ -12,6 +18,5 @@ module BOSSMan
12
18
  module_function :application_id, :application_id=
13
19
 
14
20
  class MissingConfiguration < StandardError; end
15
- class InvalidParameter < StandardError; end
16
21
  class BOSSError < StandardError; end
17
- end
22
+ end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bossman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
- - Jay Pignata
7
+ - John Pignata
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-21 00:00:00 -04:00
12
+ date: 2009-11-01 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency