nibbler 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/nibbler.rb +2 -2
- data/lib/nibbler/json.rb +4 -2
- metadata +6 -54
data/lib/nibbler.rb
CHANGED
@@ -57,7 +57,7 @@ class Nibbler
|
|
57
57
|
elsif node.respond_to? :inner_text
|
58
58
|
node.inner_text
|
59
59
|
else
|
60
|
-
node
|
60
|
+
node
|
61
61
|
end unless node.nil?
|
62
62
|
end
|
63
63
|
|
@@ -104,7 +104,7 @@ end
|
|
104
104
|
## specs
|
105
105
|
|
106
106
|
if __FILE__ == $0
|
107
|
-
require '
|
107
|
+
require 'rspec'
|
108
108
|
HTML = DATA.read
|
109
109
|
|
110
110
|
class Article < Nibbler
|
data/lib/nibbler/json.rb
CHANGED
@@ -2,6 +2,8 @@ require 'nibbler'
|
|
2
2
|
|
3
3
|
# a wrapper for JSON data that provides `at` and `search`
|
4
4
|
class Nibbler::JsonDocument
|
5
|
+
attr_reader :data
|
6
|
+
|
5
7
|
def initialize(obj)
|
6
8
|
@data = String === obj ? JSON.parse(obj) : obj
|
7
9
|
end
|
@@ -11,11 +13,11 @@ class Nibbler::JsonDocument
|
|
11
13
|
end
|
12
14
|
|
13
15
|
def search(selector)
|
14
|
-
|
16
|
+
Array === data ? data : at(selector)
|
15
17
|
end
|
16
18
|
|
17
19
|
def at(selector)
|
18
|
-
|
20
|
+
data[selector]
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nibbler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 1.
|
10
|
+
version: 1.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Mislav Marohni\xC4\x87"
|
@@ -15,58 +15,10 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-11-30 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
22
|
-
name: yajl-ruby
|
23
|
-
prerelease: false
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 9
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
- 7
|
33
|
-
- 5
|
34
|
-
version: 0.7.5
|
35
|
-
type: :development
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: nokogiri
|
39
|
-
prerelease: false
|
40
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
hash: 113
|
46
|
-
segments:
|
47
|
-
- 1
|
48
|
-
- 4
|
49
|
-
- 3
|
50
|
-
- 1
|
51
|
-
version: 1.4.3.1
|
52
|
-
type: :development
|
53
|
-
version_requirements: *id002
|
54
|
-
- !ruby/object:Gem::Dependency
|
55
|
-
name: rspec
|
56
|
-
prerelease: false
|
57
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
|
-
requirements:
|
60
|
-
- - ~>
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
hash: 27
|
63
|
-
segments:
|
64
|
-
- 1
|
65
|
-
- 3
|
66
|
-
- 0
|
67
|
-
version: 1.3.0
|
68
|
-
type: :development
|
69
|
-
version_requirements: *id003
|
20
|
+
dependencies: []
|
21
|
+
|
70
22
|
description: Nibbler is a super simple and powerful declarative generic scraper written in under 70 lines of code.
|
71
23
|
email: mislav.marohnic@gmail.com
|
72
24
|
executables: []
|