horsefield 0.2.13 → 0.3.13

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17b6a1907fab5f39fbbe85fc306c3cbd198cc452
4
- data.tar.gz: 96920552317abba9925eba2892ffb304d04138ef
3
+ metadata.gz: 600cdb34954a4e1cbe152d9885bffae6b84604f6
4
+ data.tar.gz: 3dabac2ccec96a351bb483fb7e6cc9918507072f
5
5
  SHA512:
6
- metadata.gz: 2fd67c7eed390a6f9ee806ed150cdfe1b0637c0b3c0baa503a9909c35b0931ed23d7af76c78d0e5c3b761d26eb64ea81ce9063e0ec77fd4e23cb1931f48556ca
7
- data.tar.gz: 0a54c4037613638c3e6806840f787df355c16846aeaca8110f18f5497181b00fec5210a8886d9c71b8aecdb4de4e02d0c7f2b3a55eeacc623ac8885ba9f4afc7
6
+ metadata.gz: 4fd0f85c2f966e4676ac083f67fb9064b13cde9f756d185c70a9fe66f646a8fd92f04715605511842d887a0459d8a240fb0a89a42965f649e9824aedb8460917
7
+ data.tar.gz: 77cf1c3d70e6e2ab26615ff58abb574c08641f4b51bce10f694e6996b3752c57454bef292b7276a2fe6f2b3cb43986f0e7fd044469b9ebd9dfbb7495d098762c
@@ -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
@@ -20,6 +20,9 @@ module Horsefield
20
20
  browser.instance_eval &block
21
21
  end
22
22
 
23
+ def scope(*)
24
+ end
25
+
23
26
  def one(*)
24
27
  end
25
28
 
@@ -1,3 +1,3 @@
1
1
  module Horsefield
2
- VERSION = "0.2.13"
2
+ VERSION = "0.3.13"
3
3
  end
@@ -16,7 +16,20 @@ describe Horsefield::Scraper do
16
16
  end
17
17
  end
18
18
 
19
- result[:jobs].should have(9).items
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].should be_nil
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].should match(/<a id=\"ctl00_ctl00_ctl00_body_body_wacCenterStage_ctl02_rptResults_ctl00_linkJobTitle\"/)
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.2.13
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-19 00:00:00.000000000 Z
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
@@ -1,11 +0,0 @@
1
- require 'horsefield'
2
-
3
- describe Horsefield do
4
- it 'should delegate to Scraper' do
5
- result = Horsefield.scrape 'http://example.org' do
6
- one :headline, 'h1'
7
- end
8
-
9
- result[:headline].should == 'Example Domain'
10
- end
11
- end