horsefield 0.4.63 → 0.4.64

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 317d73b3f9391f892248370ff3183235ccc43b0e
4
- data.tar.gz: f405fc8bbd9c9985b4f2d406a7af3fd308e45373
3
+ metadata.gz: 5202566470d2206afc582ce8543261763a9c3f0c
4
+ data.tar.gz: 2a9f6554cfa9926c11573c6dde74a903c80d9e32
5
5
  SHA512:
6
- metadata.gz: a0671f5904a93494dec110ca5a72596aaab138b4b9cc431d372fac273fd54f80a5dd419d1d8a04281865453e987c5a2246dfc859e0fd875ced01c7ec532f8185
7
- data.tar.gz: a042b4423d660f22b60a4b9f808a788b2485ff5b900bff4ef19c7eeb0809bdcc8eb825b6a3503c9ab432fba7a2eb366b8bb3875bb7ff9a3262d1abad0c6603e4
6
+ metadata.gz: 8695b3f5f93d82ba875b596ba7b90c2ec9de5ec817ede80af458faf8e4e02037b06fc0e86e3c360d15c04157ac06d63755c49cdba2d6e1d4ed3c2617f7b95b2c
7
+ data.tar.gz: 2e3b4cc2155abb4c74847d8248086c90c3c23ce1867730c0d9598f79ddd915ce68ca3e4b5321e15b2518a848cd287f27b18fd255a06d4abcd1a86d066e4b6e24
@@ -1,5 +1,10 @@
1
1
  module Horsefield
2
2
  module Diggable
3
+ def with_fresh_fields
4
+ @fields = {}
5
+ self
6
+ end
7
+
3
8
  def many(name, selector, lookup = :optional, &block)
4
9
  docs = search(selector)
5
10
 
@@ -19,7 +24,7 @@ module Horsefield
19
24
  raise MissingSelectorError, "Couldn't find required selector (#{selector})" if lookup == :required && !doc
20
25
  return fields if lookup == :presence && !doc
21
26
 
22
- fields.merge!(Hash[[[name, doc && doc.instance_eval(&processor(&block))]]])
27
+ fields.merge!(Hash[[[name, doc && doc.with_fresh_fields.instance_eval(&processor(&block))]]])
23
28
  end
24
29
 
25
30
  def many!(name, selector, &block)
@@ -0,0 +1,8 @@
1
+ module Horsefield
2
+ class Digger
3
+ def initialize(nokogiri_doc, fields = {})
4
+ @nokogiri_doc = nokogiri_doc
5
+ @fields = fields
6
+ end
7
+ end
8
+ end
@@ -1,3 +1,3 @@
1
1
  module Horsefield
2
- VERSION = "0.4.63"
2
+ VERSION = "0.4.64"
3
3
  end
@@ -55,7 +55,6 @@ class TestScraper < Minitest::Test
55
55
 
56
56
  def test_that_it_scrapes
57
57
  recipe = RecipeScraper.new(@html).scrape
58
-
59
58
  assert_equal 'Traditional Welsh cawl', recipe[:title]
60
59
  end
61
60
 
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.63
4
+ version: 0.4.64
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: 2015-02-04 00:00:00.000000000 Z
11
+ date: 2015-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -96,6 +96,7 @@ files:
96
96
  - horsefield.gemspec
97
97
  - lib/horsefield.rb
98
98
  - lib/horsefield/diggable.rb
99
+ - lib/horsefield/digger.rb
99
100
  - lib/horsefield/nokogiri.rb
100
101
  - lib/horsefield/scraper.rb
101
102
  - lib/horsefield/version.rb