horsefield 0.2.13 → 0.3.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/horsefield/node_set.rb +4 -0
- data/lib/horsefield/scraper.rb +3 -0
- data/lib/horsefield/version.rb +1 -1
- data/spec/scraper_spec.rb +16 -3
- metadata +2 -4
- data/spec/horsefield_spec.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 600cdb34954a4e1cbe152d9885bffae6b84604f6
|
4
|
+
data.tar.gz: 3dabac2ccec96a351bb483fb7e6cc9918507072f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fd0f85c2f966e4676ac083f67fb9064b13cde9f756d185c70a9fe66f646a8fd92f04715605511842d887a0459d8a240fb0a89a42965f649e9824aedb8460917
|
7
|
+
data.tar.gz: 77cf1c3d70e6e2ab26615ff58abb574c08641f4b51bce10f694e6996b3752c57454bef292b7276a2fe6f2b3cb43986f0e7fd044469b9ebd9dfbb7495d098762c
|
data/lib/horsefield/node_set.rb
CHANGED
@@ -18,6 +18,10 @@ module Horsefield
|
|
18
18
|
def browse(*)
|
19
19
|
end
|
20
20
|
|
21
|
+
def scope(selector, &block)
|
22
|
+
@nodes = @nodes.merge(dig_deeper(selector, false, &block))
|
23
|
+
end
|
24
|
+
|
21
25
|
def one(name, selector, type = :text, &block)
|
22
26
|
@nodes[name] = dig_deeper selector, false, type, &block
|
23
27
|
end
|
data/lib/horsefield/scraper.rb
CHANGED
data/lib/horsefield/version.rb
CHANGED
data/spec/scraper_spec.rb
CHANGED
@@ -16,7 +16,20 @@ describe Horsefield::Scraper do
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
result[:jobs].
|
19
|
+
expect(result[:jobs].length).to eq(9)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should be able to scrape in scope' do
|
23
|
+
result = Horsefield::Scraper.new.scrape html: @html do
|
24
|
+
scope '#primaryResults' do
|
25
|
+
many :jobs, '.listingsTable .odd, .listingsTable .even' do
|
26
|
+
one :title, '.jobTitleContainer'
|
27
|
+
one :company, '.companyContainer'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
expect(result[:jobs].length).to eq(9)
|
20
33
|
end
|
21
34
|
|
22
35
|
it 'should return nil for selectors that are not found' do
|
@@ -28,7 +41,7 @@ describe Horsefield::Scraper do
|
|
28
41
|
end
|
29
42
|
end
|
30
43
|
|
31
|
-
result[:job][:missing].
|
44
|
+
expect(result[:job][:missing]).to be_nil
|
32
45
|
end
|
33
46
|
|
34
47
|
it 'can return HTML instead of text' do
|
@@ -40,7 +53,7 @@ describe Horsefield::Scraper do
|
|
40
53
|
end
|
41
54
|
end
|
42
55
|
|
43
|
-
result[:job][:title].
|
56
|
+
expect(result[:job][:title]).to match(/<a id=\"ctl00_ctl00_ctl00_body_body_wacCenterStage_ctl02_rptResults_ctl00_linkJobTitle\"/)
|
44
57
|
end
|
45
58
|
|
46
59
|
it 'works with Watir' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: horsefield
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erik Strömberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mechanize
|
@@ -143,7 +143,6 @@ files:
|
|
143
143
|
- lib/horsefield/version.rb
|
144
144
|
- spec/fixtures/monster.html
|
145
145
|
- spec/fixtures/vcr_cassettes/facebook/johnny_qiu1.yml
|
146
|
-
- spec/horsefield_spec.rb
|
147
146
|
- spec/scraper_spec.rb
|
148
147
|
- spec/spec_helper.rb
|
149
148
|
homepage: ''
|
@@ -173,6 +172,5 @@ summary: It's a scraper
|
|
173
172
|
test_files:
|
174
173
|
- spec/fixtures/monster.html
|
175
174
|
- spec/fixtures/vcr_cassettes/facebook/johnny_qiu1.yml
|
176
|
-
- spec/horsefield_spec.rb
|
177
175
|
- spec/scraper_spec.rb
|
178
176
|
- spec/spec_helper.rb
|
data/spec/horsefield_spec.rb
DELETED