crags 2.1.2 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/VERSION +1 -1
- data/crags.gemspec +8 -8
- data/lib/crags/fetcher.rb +2 -2
- data/lib/crags.rb +2 -2
- data/lib/ext/element.rb +21 -0
- data/spec/crags/fetcher_spec.rb +5 -5
- data/spec/ext/{hpricot/elem_spec.rb → element_spec.rb} +10 -6
- metadata +8 -8
- data/lib/ext/hpricot/elem.rb +0 -19
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.0
|
data/crags.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{crags}
|
8
|
-
s.version = "2.
|
8
|
+
s.version = "2.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Justin Marney"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-02-08}
|
13
13
|
s.description = %q{A library to help search across multiple craigslist locations.}
|
14
14
|
s.email = %q{gotascii@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
"lib/crags/search/country.rb",
|
34
34
|
"lib/crags/search/location.rb",
|
35
35
|
"lib/crags/search/search.rb",
|
36
|
-
"lib/ext/
|
36
|
+
"lib/ext/element.rb",
|
37
37
|
"lib/ext/string.rb",
|
38
38
|
"spec/crags/category_spec.rb",
|
39
39
|
"spec/crags/country_spec.rb",
|
@@ -43,7 +43,7 @@ Gem::Specification.new do |s|
|
|
43
43
|
"spec/crags/search/country_spec.rb",
|
44
44
|
"spec/crags/search/location_spec.rb",
|
45
45
|
"spec/crags/search/search_spec.rb",
|
46
|
-
"spec/ext/
|
46
|
+
"spec/ext/element_spec.rb",
|
47
47
|
"spec/ext/string_spec.rb",
|
48
48
|
"spec/spec_helper.rb"
|
49
49
|
]
|
@@ -60,7 +60,7 @@ Gem::Specification.new do |s|
|
|
60
60
|
"spec/crags/search/country_spec.rb",
|
61
61
|
"spec/crags/search/location_spec.rb",
|
62
62
|
"spec/crags/search/search_spec.rb",
|
63
|
-
"spec/ext/
|
63
|
+
"spec/ext/element_spec.rb",
|
64
64
|
"spec/ext/string_spec.rb",
|
65
65
|
"spec/spec_helper.rb"
|
66
66
|
]
|
@@ -71,14 +71,14 @@ Gem::Specification.new do |s|
|
|
71
71
|
|
72
72
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
73
73
|
s.add_runtime_dependency(%q<curb>, [">= 0"])
|
74
|
-
s.add_runtime_dependency(%q<
|
74
|
+
s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
|
75
75
|
else
|
76
76
|
s.add_dependency(%q<curb>, [">= 0"])
|
77
|
-
s.add_dependency(%q<
|
77
|
+
s.add_dependency(%q<nokogiri>, [">= 0"])
|
78
78
|
end
|
79
79
|
else
|
80
80
|
s.add_dependency(%q<curb>, [">= 0"])
|
81
|
-
s.add_dependency(%q<
|
81
|
+
s.add_dependency(%q<nokogiri>, [">= 0"])
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
data/lib/crags/fetcher.rb
CHANGED
data/lib/crags.rb
CHANGED
data/lib/ext/element.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Element
|
2
|
+
def title
|
3
|
+
at("title").content
|
4
|
+
end
|
5
|
+
|
6
|
+
def url
|
7
|
+
self["about"].strip_http
|
8
|
+
end
|
9
|
+
|
10
|
+
def date_str
|
11
|
+
at("dc|date").content
|
12
|
+
end
|
13
|
+
|
14
|
+
def date
|
15
|
+
DateTime.parse(date_str)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class Nokogiri::XML::Element
|
20
|
+
include Element
|
21
|
+
end
|
data/spec/crags/fetcher_spec.rb
CHANGED
@@ -5,17 +5,17 @@ describe Fetcher do
|
|
5
5
|
extend Fetcher
|
6
6
|
end
|
7
7
|
|
8
|
-
it "
|
9
|
-
stub!(:
|
10
|
-
|
8
|
+
it "nokogiris the fetched xml" do
|
9
|
+
stub!(:fetch_xml).with("url").and_return("xml")
|
10
|
+
Nokogiri::XML.should_receive(:parse).with("xml").and_return("doc")
|
11
11
|
fetch_doc("url").should == "doc"
|
12
12
|
end
|
13
13
|
|
14
|
-
it "
|
14
|
+
it "fetches a request when fetching xml" do
|
15
15
|
curb = mock("curb")
|
16
16
|
curb.stub!(:body_str).and_return("uhh")
|
17
17
|
should_receive(:fetch_request).with("url").and_return(curb)
|
18
|
-
|
18
|
+
fetch_xml("url").should == "uhh"
|
19
19
|
end
|
20
20
|
|
21
21
|
it "creates a new request" do
|
@@ -1,26 +1,30 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
3
|
+
class Tester
|
4
|
+
include Element
|
5
|
+
end
|
6
|
+
|
7
|
+
describe Nokogiri::XML::Element do
|
4
8
|
before do
|
5
|
-
@elem =
|
9
|
+
@elem = Tester.new
|
6
10
|
end
|
7
11
|
|
8
12
|
it "uses the inner_text of title element for title" do
|
9
13
|
title = stub
|
10
|
-
title.stub!(:
|
14
|
+
title.stub!(:content).and_return("title!")
|
11
15
|
@elem.stub!(:at).with("title").and_return(title)
|
12
16
|
@elem.title.should == "title!"
|
13
17
|
end
|
14
18
|
|
15
19
|
it "rdf:about attribute for the url" do
|
16
|
-
@elem.stub!(:[]).with("
|
20
|
+
@elem.stub!(:[]).with("about").and_return("url!")
|
17
21
|
@elem.url.should == "url!"
|
18
22
|
end
|
19
23
|
|
20
24
|
it "uses the inner_text of the dc:date element for date_str" do
|
21
25
|
dc_date = stub
|
22
|
-
dc_date.stub!(:
|
23
|
-
@elem.stub!(:at).with("dc
|
26
|
+
dc_date.stub!(:content).and_return("date_str!")
|
27
|
+
@elem.stub!(:at).with("dc|date").and_return(dc_date)
|
24
28
|
@elem.date_str.should == "date_str!"
|
25
29
|
end
|
26
30
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
- 1
|
9
8
|
- 2
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 2.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Justin Marney
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-02-08 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -35,7 +35,7 @@ dependencies:
|
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
|
-
name:
|
38
|
+
name: nokogiri
|
39
39
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
@@ -72,7 +72,7 @@ files:
|
|
72
72
|
- lib/crags/search/country.rb
|
73
73
|
- lib/crags/search/location.rb
|
74
74
|
- lib/crags/search/search.rb
|
75
|
-
- lib/ext/
|
75
|
+
- lib/ext/element.rb
|
76
76
|
- lib/ext/string.rb
|
77
77
|
- spec/crags/category_spec.rb
|
78
78
|
- spec/crags/country_spec.rb
|
@@ -82,7 +82,7 @@ files:
|
|
82
82
|
- spec/crags/search/country_spec.rb
|
83
83
|
- spec/crags/search/location_spec.rb
|
84
84
|
- spec/crags/search/search_spec.rb
|
85
|
-
- spec/ext/
|
85
|
+
- spec/ext/element_spec.rb
|
86
86
|
- spec/ext/string_spec.rb
|
87
87
|
- spec/spec_helper.rb
|
88
88
|
has_rdoc: true
|
@@ -128,6 +128,6 @@ test_files:
|
|
128
128
|
- spec/crags/search/country_spec.rb
|
129
129
|
- spec/crags/search/location_spec.rb
|
130
130
|
- spec/crags/search/search_spec.rb
|
131
|
-
- spec/ext/
|
131
|
+
- spec/ext/element_spec.rb
|
132
132
|
- spec/ext/string_spec.rb
|
133
133
|
- spec/spec_helper.rb
|
data/lib/ext/hpricot/elem.rb
DELETED