craig 0.0.1.pre → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +165 -28
- data/Rakefile +7 -0
- data/craig.gemspec +2 -2
- data/lib/craig/categories.rb +169 -0
- data/lib/craig/cities.rb +262 -0
- data/lib/craig/craigslist.rb +49 -0
- data/lib/craig/listing.rb +73 -0
- data/lib/craig/node.rb +151 -0
- data/lib/craig/page.rb +50 -0
- data/lib/craig/tasks/update_cities.rb +95 -0
- data/lib/craig/version.rb +1 -1
- data/lib/craig.rb +24 -1
- data/test/community_events_test.rb +56 -0
- data/test/for_sale_cars_trucks_test.rb +38 -0
- data/test/for_sale_photo_video_test.rb +24 -0
- data/test/parsing_test.rb +119 -0
- data/test/personals_casual_encounters_test.rb +36 -0
- data/test/resumes_test.rb +24 -0
- data/test/sample_html/community_event-one-page_files/craigslist.css +1487 -0
- data/test/sample_html/community_event-one-page_files/formats.js +100 -0
- data/test/sample_html/community_event-one-page_files/jquery-1.7.2.js +632 -0
- data/test/sample_html/community_event-one-page_files/jquery.form-defaults.js +2 -0
- data/test/sample_html/community_event-one-page_files/toChecklist.js +47 -0
- data/test/sample_html/community_event-one-page_files/tocs.js +30 -0
- data/test/sample_html/community_events-one-page.html +294 -0
- data/test/sample_html/community_events.html +1077 -0
- data/test/sample_html/community_events_files/craigslist.css +1487 -0
- data/test/sample_html/community_events_files/formats.js +100 -0
- data/test/sample_html/community_events_files/jquery-1.7.2.js +632 -0
- data/test/sample_html/community_events_files/jquery-1.js +632 -0
- data/test/sample_html/community_events_files/jquery.form-defaults.js +2 -0
- data/test/sample_html/community_events_files/jquery.js +2 -0
- data/test/sample_html/community_events_files/toChecklist.js +47 -0
- data/test/sample_html/community_events_files/tocs.js +30 -0
- data/test/sample_html/for_sale.html +1478 -0
- data/test/sample_html/for_sale_cars_trucks.html +1483 -0
- data/test/sample_html/for_sale_cars_trucks_files/craigslist.css +1487 -0
- data/test/sample_html/for_sale_cars_trucks_files/formats.js +100 -0
- data/test/sample_html/for_sale_cars_trucks_files/jquery-1.7.2.js +632 -0
- data/test/sample_html/for_sale_cars_trucks_files/jquery.form-defaults.js +2 -0
- data/test/sample_html/for_sale_cars_trucks_files/toChecklist.js +47 -0
- data/test/sample_html/for_sale_cars_trucks_files/tocs.js +30 -0
- data/test/sample_html/for_sale_files/craigslist.css +1474 -0
- data/test/sample_html/for_sale_files/formats.js +107 -0
- data/test/sample_html/for_sale_files/jquery-1.js +632 -0
- data/test/sample_html/for_sale_files/jquery.js +2 -0
- data/test/sample_html/for_sale_files/toChecklist.js +47 -0
- data/test/sample_html/for_sale_files/tocs.js +30 -0
- data/test/sample_html/for_sale_photo_video.html +674 -0
- data/test/sample_html/for_sale_photo_video_files/craigslist.css +1487 -0
- data/test/sample_html/for_sale_photo_video_files/formats.js +100 -0
- data/test/sample_html/for_sale_photo_video_files/jquery-1.7.2.js +632 -0
- data/test/sample_html/for_sale_photo_video_files/jquery.form-defaults.js +2 -0
- data/test/sample_html/for_sale_photo_video_files/toChecklist.js +47 -0
- data/test/sample_html/for_sale_photo_video_files/tocs.js +30 -0
- data/test/sample_html/gigs.html +1047 -0
- data/test/sample_html/gigs_files/craigslist.css +1474 -0
- data/test/sample_html/gigs_files/formats.js +107 -0
- data/test/sample_html/gigs_files/jquery-1.js +632 -0
- data/test/sample_html/gigs_files/jquery.js +2 -0
- data/test/sample_html/gigs_files/toChecklist.js +47 -0
- data/test/sample_html/gigs_files/tocs.js +30 -0
- data/test/sample_html/housing.html +1406 -0
- data/test/sample_html/housing_vacation_rentals_files/craigslist.css +1474 -0
- data/test/sample_html/housing_vacation_rentals_files/formats.js +107 -0
- data/test/sample_html/housing_vacation_rentals_files/jquery-1.7.2.js +632 -0
- data/test/sample_html/housing_vacation_rentals_files/jquery.form-defaults.js +2 -0
- data/test/sample_html/housing_vacation_rentals_files/toChecklist.js +47 -0
- data/test/sample_html/housing_vacation_rentals_files/tocs.js +30 -0
- data/test/sample_html/jobs.html +1120 -0
- data/test/sample_html/jobs_files/craigslist.css +1474 -0
- data/test/sample_html/jobs_files/formats.js +107 -0
- data/test/sample_html/jobs_files/jquery-1.js +632 -0
- data/test/sample_html/jobs_files/jquery.js +2 -0
- data/test/sample_html/jobs_files/toChecklist.js +47 -0
- data/test/sample_html/jobs_files/tocs.js +30 -0
- data/test/sample_html/personals.html +1096 -0
- data/test/sample_html/personals_casual_encounters.html +1086 -0
- data/test/sample_html/personals_casual_encounters_files/craigslist.css +1487 -0
- data/test/sample_html/personals_casual_encounters_files/formats.js +100 -0
- data/test/sample_html/personals_casual_encounters_files/jquery-1.7.2.js +632 -0
- data/test/sample_html/personals_casual_encounters_files/jquery.form-defaults.js +2 -0
- data/test/sample_html/personals_casual_encounters_files/toChecklist.js +47 -0
- data/test/sample_html/personals_casual_encounters_files/tocs.js +30 -0
- data/test/sample_html/personals_strictly_platonic_files/craigslist.css +1474 -0
- data/test/sample_html/personals_strictly_platonic_files/formats.js +107 -0
- data/test/sample_html/personals_strictly_platonic_files/jquery-1.js +632 -0
- data/test/sample_html/personals_strictly_platonic_files/jquery.js +2 -0
- data/test/sample_html/personals_strictly_platonic_files/toChecklist.js +47 -0
- data/test/sample_html/personals_strictly_platonic_files/tocs.js +30 -0
- data/test/sample_html/resumes.html +811 -0
- data/test/sample_html/resumes_files/craigslist.css +1487 -0
- data/test/sample_html/resumes_files/formats.js +100 -0
- data/test/sample_html/resumes_files/jquery-1.7.2.js +632 -0
- data/test/sample_html/resumes_files/jquery.form-defaults.js +2 -0
- data/test/sample_html/resumes_files/toChecklist.js +47 -0
- data/test/sample_html/resumes_files/tocs.js +30 -0
- data/test/sample_html/services.html +1096 -0
- data/test/sample_html/services_files/craigslist.css +1487 -0
- data/test/sample_html/services_files/formats.js +100 -0
- data/test/sample_html/services_files/jquery-1.7.2.js +632 -0
- data/test/sample_html/services_files/jquery.form-defaults.js +2 -0
- data/test/sample_html/services_files/toChecklist.js +47 -0
- data/test/sample_html/services_files/tocs.js +30 -0
- data/test/sample_html/test.rb +309 -0
- data/test/services_test.rb +25 -0
- data/test/test_helper.rb +26 -0
- metadata +205 -9
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
require "test_helper"
|
3
|
+
|
4
|
+
module Craig
|
5
|
+
|
6
|
+
dom = Helper.dom("personals_casual_encounters.html")
|
7
|
+
listings = Page.new(:personals, :casual_encounters, dom).listings
|
8
|
+
|
9
|
+
describe "Craig" do
|
10
|
+
|
11
|
+
it "parses :personals => :casual_encounters" do
|
12
|
+
listing = listings[63]
|
13
|
+
|
14
|
+
assert { listing.title == "looking for a real couple - m4mw - 37" }
|
15
|
+
assert { listing.location == "abilene" }
|
16
|
+
assert { listing.has_image? == false }
|
17
|
+
assert { listing.has_map? == false }
|
18
|
+
assert { listing.age == 37 }
|
19
|
+
assert { listing.seeking == "m4mw" }
|
20
|
+
assert { listing.posted_at.strftime("%a %b %-d") == "Tue Jan 22" }
|
21
|
+
end
|
22
|
+
|
23
|
+
it "knows when no age is given" do
|
24
|
+
listing = listings[74]
|
25
|
+
|
26
|
+
assert { listing.title == "CD - t4m" }
|
27
|
+
assert { listing.location == "Abilene" }
|
28
|
+
assert { listing.has_image? == false }
|
29
|
+
assert { listing.has_map? == false }
|
30
|
+
assert { listing.age == 0 }
|
31
|
+
assert { listing.seeking == "t4m" }
|
32
|
+
assert { listing.posted_at.strftime("%a %b %-d") == "Tue Jan 22" }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module Craig
|
4
|
+
|
5
|
+
dom = Helper.dom("resumes.html")
|
6
|
+
|
7
|
+
describe "Craig" do
|
8
|
+
it "parses :resumes" do
|
9
|
+
listings = Page.new(:resumes, nil, dom).listings
|
10
|
+
listing = listings[52]
|
11
|
+
|
12
|
+
assert { listing.title == "Female / 28 / Seeking Employment" }
|
13
|
+
assert { listing.location == "Sweetwater Texas" }
|
14
|
+
assert { listing.has_image? == false }
|
15
|
+
deny { listing.respond_to? :price }
|
16
|
+
deny { listing.respond_to? :bedrooms }
|
17
|
+
deny { listing.respond_to? :square_feet }
|
18
|
+
deny { listing.respond_to? :seller }
|
19
|
+
assert { listing.has_map? == false }
|
20
|
+
assert { listing.posted_at.strftime("%a %b %-d") == "Fri Dec 20" }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|