quixoten-craigler 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,21 +19,23 @@ or
19
19
  puts item.time
20
20
  end
21
21
 
22
- You can also create a search object to fetch the results later. When no location or category is given Craigler searches <tt>:all_for_sale_or_wanted</tt> in <tt>:anywhere</tt>
22
+ You can also create a search object to fetch the results later. When no location or category is given Craigler searches <tt>:all_for_sale_or_wanted</tt> <tt>:in => :anywhere</tt>
23
23
 
24
24
  search = Craigler::Search.new('Yamaha')
25
- search.results(:page_limit => 1)
25
+ search.results()
26
26
 
27
27
  Note that additional calls to <tt>search.results()</tt> will always return the same result set unless refresh is forced
28
28
  search.results(:refresh => true)
29
29
 
30
+ See Craigler::Search for a list of all available options
31
+
30
32
  === Supported Categories
31
33
  <tt>:all_for_sale_or_wanted</tt>, <tt>:art_and_crafts</tt>, <tt>:auto_parts</tt>, <tt>:baby_and_kid_stuff</tt>, <tt>:barter</tt>, <tt>:bicycles</tt>, <tt>:boats</tt>, <tt>:books</tt>, <tt>:business</tt>, <tt>:cars_and_trucks</tt>, <tt>:clothing</tt>, <tt>:collectibles</tt>, <tt>:community</tt>, <tt>:computers_and_tech</tt>, <tt>:electronics</tt>, <tt>:event</tt>, <tt>:farm_and_garden</tt>, <tt>:free_stuff</tt>, <tt>:furniture</tt>, <tt>:games_and_toys</tt>, <tt>:garage_sales</tt>, <tt>:general</tt>, <tt>:gigs</tt>, <tt>:household</tt>, <tt>:housing</tt>, <tt>:items_wanted</tt>, <tt>:jewelry</tt>, <tt>:jobs</tt>, <tt>:materials</tt>, <tt>:media</tt>, <tt>:motorcycles</tt>, <tt>:musical_instruments</tt>, <tt>:personals</tt>, <tt>:photo_and_video</tt>, <tt>:recreational_vehicles</tt>, <tt>:resume</tt>, <tt>:services_offered</tt>, <tt>:sporting_goods</tt>, <tt>:tickets</tt>, <tt>:tools</tt>
32
34
 
33
35
  === Supported Locations
34
36
  <tt>:alaska</tt>, <tt>:arizona</tt>, <tt>:arkansas</tt>, <tt>:california</tt>, <tt>:colorado</tt>, <tt>:connecticut</tt>, <tt>:delaware</tt>, <tt>:dc</tt>, <tt>:florida</tt>, <tt>:georgia</tt>, <tt>:hawaii</tt>, <tt>:idaho</tt>, <tt>:illinois</tt>, <tt>:indiana</tt>, <tt>:iowa</tt>, <tt>:kansas</tt>, <tt>:kentucky</tt>, <tt>:louisiana</tt>, <tt>:maine</tt>, <tt>:maryland</tt>, <tt>:mass</tt>, <tt>:michigan</tt>, <tt>:minnesota</tt>, <tt>:mississippi</tt>, <tt>:missouri</tt>, <tt>:montana</tt>, <tt>:nebraska</tt>, <tt>:nevada</tt>, <tt>:n_hampshire</tt>, <tt>:new_jersey</tt>, <tt>:new_mexico</tt>, <tt>:new_york</tt>, <tt>:n_carolina</tt>, <tt>:north_dakota</tt>, <tt>:ohio</tt>, <tt>:oklahoma</tt>, <tt>:oregon</tt>, <tt>:pennsylvania</tt>, <tt>:rhode_island</tt>, <tt>:s_carolina</tt>, <tt>:south_dakota</tt>, <tt>:tennessee</tt>, <tt>:texas</tt>, <tt>:utah</tt>, <tt>:vermont</tt>, <tt>:virginia</tt>, <tt>:washington</tt>, <tt>:west_virginia</tt> <tt>:wisconsin</tt>, <tt>:wyoming</tt>
35
37
 
36
- Or use <tt>:anywhere</tt> to search all supported locations.
38
+ Or use <tt>:in => :anywhere</tt> to search all supported locations.
37
39
 
38
40
  == REQUIREMENTS:
39
41
 
data/Rakefile CHANGED
@@ -50,7 +50,8 @@ Rake::RDocTask.new do |rdoc|
50
50
 
51
51
  rdoc.rdoc_dir = 'rdoc'
52
52
  rdoc.title = "Craigler #{version}"
53
- rdoc.rdoc_files.include('README.rdoc', 'LICENSE')
54
53
  rdoc.rdoc_files.include('lib/**/*.rb')
54
+ rdoc.rdoc_files.include('README.rdoc', 'LICENSE')
55
+ rdoc.main = 'README.rdoc'
55
56
  end
56
57
 
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 1
3
3
  :minor: 2
4
- :patch: 0
4
+ :patch: 1
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{craigler}
8
- s.version = "1.2.0"
8
+ s.version = "1.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Devin Christensen"]
@@ -5,15 +5,20 @@ require 'craigler/constants'
5
5
  require 'craigler/search'
6
6
 
7
7
  module Craigler
8
+
9
+ # :stopdoc:
8
10
  class CraiglerError < StandardError; end
9
11
  class InvalidCategory < CraiglerError; end
10
12
  class InvalidSearchTerm < CraiglerError; end
11
13
  class InvalidLocation < CraiglerError; end
14
+ # :startdoc:
12
15
 
13
16
  class << self
14
17
  # Interface to Search that may or may not be more readable
18
+ #
19
+ # Supports all options of Search#new except <tt>:only</tt>, as it's supplied through the <tt>category</tt> parameter
15
20
  def search(category, options = {})
16
- options = { :only => category }.merge(options)
21
+ options = options.merge({ :only => category })
17
22
  results = Search.new(options.delete(:for), options).results()
18
23
  results.each {|result| yield(result) } if block_given?
19
24
  results
@@ -1,5 +1,7 @@
1
1
  module Craigler
2
- RESULTS_PER_PAGE = 25 # :nodoc:
2
+
3
+ # :stopdoc:
4
+ RESULTS_PER_PAGE = 25
3
5
 
4
6
  LOCATIONS = {
5
7
  :alabama => ['http://auburn.craigslist.org/','http://bham.craigslist.org/','http://columbusga.craigslist.org/','http://dothan.craigslist.org/','http://shoals.craigslist.org/','http://gadsden.craigslist.org/','http://huntsville.craigslist.org/','http://mobile.craigslist.org/','http://montgomery.craigslist.org/','http://tuscaloosa.craigslist.org/'],
@@ -53,7 +55,7 @@ module Craigler
53
55
  :west_virginia => ['http://charlestonwv.craigslist.org/','http://huntington.craigslist.org/','http://martinsburg.craigslist.org/','http://morgantown.craigslist.org/','http://parkersburg.craigslist.org/','http://wv.craigslist.org/','http://wheeling.craigslist.org/'],
54
56
  :wisconsin => ['http://appleton.craigslist.org/','http://duluth.craigslist.org/','http://eauclaire.craigslist.org/','http://greenbay.craigslist.org/','http://janesville.craigslist.org/','http://racine.craigslist.org/','http://lacrosse.craigslist.org/','http://madison.craigslist.org/','http://milwaukee.craigslist.org/','http://sheboygan.craigslist.org/','http://wausau.craigslist.org/'],
55
57
  :wyoming => ['http://wyoming.craigslist.org/']
56
- } # :nodoc:
58
+ }
57
59
 
58
60
  CATEGORIES = {
59
61
  :community => 'ccc',
@@ -96,5 +98,7 @@ module Craigler
96
98
  :personals => 'ppp',
97
99
  :resume => 'res',
98
100
  :services_offered => 'bbb'
99
- } # :nodoc:
101
+ }
102
+
103
+ # :startdoc:
100
104
  end
@@ -18,7 +18,7 @@ module Craigler
18
18
  # <b>Note:</b> A location may, and often does, have more than one searchable
19
19
  # url assciated with it, e.g., {California}[http://geo.craigslist.org/iso/us/ca]. Because
20
20
  # <tt>:page_limit</tt> is applied seperately to each url within the location, searching <tt>:in => :california</tt>
21
- # with a <tt>:page_limit => 4</tt> could potentially make up to 100 page requests.</em>
21
+ # with a <tt>:page_limit => 4</tt> could potentially make up to 100 page requests.
22
22
  def initialize(search_term, options = {})
23
23
  raise InvalidSearchTerm if search_term.nil? || search_term == ''
24
24
 
@@ -59,20 +59,20 @@ module Craigler
59
59
  end
60
60
 
61
61
  protected
62
- def _validate_locations
62
+ def _validate_locations # :nodoc:
63
63
  @locations.each() do |location|
64
64
  raise InvalidLocation.new(":anywhere not expected as part of an array") if location == :anywhere
65
65
  raise InvalidLocation.new(":#{location} is not a valid location") unless LOCATIONS.key?(location)
66
66
  end
67
67
  end
68
68
 
69
- def _validate_categories
69
+ def _validate_categories # :nodoc:
70
70
  @categories.each() do |category|
71
71
  raise InvalidCategory unless CATEGORIES.key?(category)
72
72
  end
73
73
  end
74
74
 
75
- def _for_each_locations_search_url()
75
+ def _for_each_locations_search_url # :nodoc:
76
76
  @locations.each do |location|
77
77
  LOCATIONS[location].each do |url|
78
78
  @categories.each do |category|
@@ -82,7 +82,7 @@ module Craigler
82
82
  end
83
83
  end
84
84
 
85
- def _extract_items_from_url(location, url)
85
+ def _extract_items_from_url(location, url) # :nodoc:
86
86
  (Hpricot(open(url))/'item').collect { |item| {
87
87
  :url => item['rdf:about'],
88
88
  :title => (item%'title').inner_text,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quixoten-craigler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Devin Christensen