doc_wrapper 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +16 -3
- data/README.txt +1 -1
- data/lib/doc_wrapper.rb +2 -1
- data/lib/doc_wrapper/base_class_methods.rb +1 -1
- data/lib/doc_wrapper/float_property_definition.rb +12 -0
- data/lib/doc_wrapper/version.rb +1 -1
- data/spec/doc_wrapper_spec.rb +5 -1
- data/spec/fixtures/doc_wrapper_test.html +1 -0
- metadata +81 -110
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ODkxMGRhNWE1M2ZjNWY5ZTQ0MWQ2YTljZDljODdiN2I2OWNmYTM1Ng==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MmJlMjQ2MTZhYmEwNmQ4MmZhMTBmM2UwMWE0OWQ1NTY1Y2Y4MzQ5ZA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NWQzYjk3NGUwZGY2Y2FiZTE0NGM3MTMxYmVjMjQ1MmUxMzU2ZmI1MjBhZWNk
|
10
|
+
MjdmOTcwNDJhZjUxNDI4OGY0OWRiMWVhNGZlZTg3ZDUyYWM5ZjAzNDVhNjk4
|
11
|
+
N2IxNDk3ZGJhYmRmOWIzZTI4ZGRjOWM1ODA2NjJjNmUzYjI5Nzg=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OGJiMjA0OGNiMDc1NzY1NzA3OWJiZjczNTI3ZWQyNjU3MGQ5ZmM0YTE2MWUy
|
14
|
+
MTZmMzkwZTc0MGFlZjIwZWZmYzI5ZTcyZGY0ZTE0ODU2NjNhZGYzOTllNzFm
|
15
|
+
NmUzZTkwNjdjMDhiNjQ3OThkZmRkMTEyMmVlZmNlMTcxYjFhNmI=
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,15 +1,24 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
doc_wrapper (0.9.
|
4
|
+
doc_wrapper (0.9.5)
|
5
5
|
activesupport (>= 3.0.0)
|
6
6
|
|
7
7
|
GEM
|
8
|
-
remote:
|
8
|
+
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
ZenTest (4.4.2)
|
11
|
-
activesupport (
|
11
|
+
activesupport (4.2.0)
|
12
|
+
i18n (~> 0.7)
|
13
|
+
json (~> 1.7, >= 1.7.7)
|
14
|
+
minitest (~> 5.1)
|
15
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
16
|
+
tzinfo (~> 1.1)
|
12
17
|
diff-lcs (1.1.2)
|
18
|
+
i18n (0.7.0)
|
19
|
+
json (1.8.2)
|
20
|
+
json (1.8.2-java)
|
21
|
+
minitest (5.5.1)
|
13
22
|
nokogiri (1.4.4)
|
14
23
|
nokogiri (1.4.4-java)
|
15
24
|
weakling (>= 0.0.3)
|
@@ -21,6 +30,10 @@ GEM
|
|
21
30
|
rspec-expectations (2.5.0)
|
22
31
|
diff-lcs (~> 1.1.2)
|
23
32
|
rspec-mocks (2.5.0)
|
33
|
+
thread_safe (0.3.4)
|
34
|
+
thread_safe (0.3.4-java)
|
35
|
+
tzinfo (1.2.2)
|
36
|
+
thread_safe (~> 0.1)
|
24
37
|
weakling (0.0.4-java)
|
25
38
|
|
26
39
|
PLATFORMS
|
data/README.txt
CHANGED
@@ -40,7 +40,7 @@ person_wrapper.last_name # => 'Menard'
|
|
40
40
|
|
41
41
|
Supported Property Types
|
42
42
|
|
43
|
-
Currently DocWrapper support :string, :date, :time, :boolean, and :raw. Additionally DocWrapper supports embedded wrappers using has_one and has_many functionality very similar to ActiveRecord. See specs for example usages.
|
43
|
+
Currently DocWrapper support :string, :date, :time, :boolean, :float and :raw. Additionally DocWrapper supports embedded wrappers using has_one and has_many functionality very similar to ActiveRecord. See specs for example usages.
|
44
44
|
|
45
45
|
Access to Node Attributes
|
46
46
|
|
data/lib/doc_wrapper.rb
CHANGED
@@ -19,4 +19,5 @@ require 'doc_wrapper/inner_html_property_definition'
|
|
19
19
|
require 'doc_wrapper/string_property_definition'
|
20
20
|
require 'doc_wrapper/date_property_definition'
|
21
21
|
require 'doc_wrapper/time_property_definition'
|
22
|
-
require 'doc_wrapper/boolean_property_definition'
|
22
|
+
require 'doc_wrapper/boolean_property_definition'
|
23
|
+
require 'doc_wrapper/float_property_definition'
|
@@ -4,7 +4,7 @@ module DocWrapper
|
|
4
4
|
# Create a typed property definition for a document wrapper.
|
5
5
|
# The property_name must be a symbol.
|
6
6
|
def property (property_name, type, selector, options = {}, &block)
|
7
|
-
raise "Unhandled property type: #{type.to_s}" if ![:string, :date, :time, :boolean, :raw].include?(type)
|
7
|
+
raise "Unhandled property type: #{type.to_s}" if ![:string, :date, :time, :boolean, :float, :raw].include?(type)
|
8
8
|
add_property_definition(property_name, build_property_definition(property_name, type, selector, initialize_options(options), block))
|
9
9
|
end
|
10
10
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module DocWrapper
|
2
|
+
class FloatPropertyDefinition < InnerHtmlPropertyDefinition
|
3
|
+
def transform (result)
|
4
|
+
if block
|
5
|
+
result = block.call(result)
|
6
|
+
else
|
7
|
+
result = result.blank? ? nil : (options[:parser] ? options[:parser].call(result) : result.to_f)
|
8
|
+
end
|
9
|
+
result
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/doc_wrapper/version.rb
CHANGED
data/spec/doc_wrapper_spec.rb
CHANGED
@@ -36,7 +36,8 @@ describe DocWrapper do
|
|
36
36
|
it { document_properties[:combined_tds].should == 'A table data A table data' }
|
37
37
|
it { document_properties[:combined_date_and_time].should == Time.parse('12-Dec-2009 12:31 PM') }
|
38
38
|
it { document_properties[:arrayed_xpath].should == 'name1 position1 salary1' }
|
39
|
-
it { document_properties.
|
39
|
+
it { document_properties[:float].should == 117.23 }
|
40
|
+
it { document_properties.size.should == 15 }
|
40
41
|
end
|
41
42
|
|
42
43
|
it { document.should respond_to(:paragraph) }
|
@@ -46,6 +47,7 @@ describe DocWrapper do
|
|
46
47
|
it { document.should respond_to(:combined_tds) }
|
47
48
|
it { document.should respond_to(:combined_date_and_time) }
|
48
49
|
it { document.should respond_to(:arrayed_xpath) }
|
50
|
+
it { document.should respond_to(:float) }
|
49
51
|
|
50
52
|
it { document.paragraph.should == 'A paragraph' }
|
51
53
|
it { document.paragraph2.should == 'A second paragraph' }
|
@@ -55,6 +57,7 @@ describe DocWrapper do
|
|
55
57
|
it { document.date_with_block.should == 'result from block' }
|
56
58
|
it { document.active.should == true }
|
57
59
|
it { document.time.should == Time.parse('12-Dec-2009 12:31 PM') }
|
60
|
+
it { document.float.should == 117.23 }
|
58
61
|
it "should strip HTML from string properties" do
|
59
62
|
pending
|
60
63
|
document.space_example.should == 'Space Example'
|
@@ -147,6 +150,7 @@ class TestDocWrapper
|
|
147
150
|
end
|
148
151
|
property :time, :time, "/html/body/p[4]"
|
149
152
|
property :parsed_time, :time, "/html/body/p[4]", :parser => lambda { |x| Time.parse(x) }
|
153
|
+
property :float, :float, "//p[@class='float']"
|
150
154
|
property :table_data, :string, "/html/body/table[1]/tr/td[1]"
|
151
155
|
property :paragraph2, :string, "/html/body/p[1]", :document => 2
|
152
156
|
has_many :line_items, "/html/body/table[2]/tr", TestDocLineItem, :start_row => 1, :end_row => 4
|
metadata
CHANGED
@@ -1,109 +1,93 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: doc_wrapper
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 9
|
9
|
-
- 4
|
10
|
-
version: 0.9.4
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.5
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Mark Menard
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2015-01-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
22
14
|
name: activesupport
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 7
|
30
|
-
segments:
|
31
|
-
- 3
|
32
|
-
- 0
|
33
|
-
- 0
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
34
19
|
version: 3.0.0
|
35
20
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: bundler
|
39
21
|
prerelease: false
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
50
33
|
version: 1.0.0
|
51
34
|
type: :development
|
52
|
-
version_requirements: *id002
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: nokogiri
|
55
35
|
prerelease: false
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: nokogiri
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
65
48
|
type: :development
|
66
|
-
version_requirements: *id003
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
|
-
name: rspec
|
69
49
|
prerelease: false
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
80
61
|
version: 2.0.0
|
81
62
|
type: :development
|
82
|
-
version_requirements: *id004
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: ZenTest
|
85
63
|
prerelease: false
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.0.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: ZenTest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
95
76
|
type: :development
|
96
|
-
|
97
|
-
|
98
|
-
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Using the DocWrapper DSL you can easily define classes that wrap HTML
|
84
|
+
DOM Documents allowing extraction of properties using either XPath or CSS selectors.
|
85
|
+
email:
|
99
86
|
- mark@enablelabs.com
|
100
87
|
executables: []
|
101
|
-
|
102
88
|
extensions: []
|
103
|
-
|
104
89
|
extra_rdoc_files: []
|
105
|
-
|
106
|
-
files:
|
90
|
+
files:
|
107
91
|
- .gitignore
|
108
92
|
- Gemfile
|
109
93
|
- Gemfile.lock
|
@@ -116,6 +100,7 @@ files:
|
|
116
100
|
- lib/doc_wrapper/base_property_definition.rb
|
117
101
|
- lib/doc_wrapper/boolean_property_definition.rb
|
118
102
|
- lib/doc_wrapper/date_property_definition.rb
|
103
|
+
- lib/doc_wrapper/float_property_definition.rb
|
119
104
|
- lib/doc_wrapper/has_many_property_definition.rb
|
120
105
|
- lib/doc_wrapper/has_one_property_definition.rb
|
121
106
|
- lib/doc_wrapper/inner_html_property_definition.rb
|
@@ -132,41 +117,27 @@ files:
|
|
132
117
|
- spec/fixtures/doc_wrapper_test.html
|
133
118
|
- spec/fixtures/doc_wrapper_test_2.html
|
134
119
|
- spec/spec_helper.rb
|
135
|
-
has_rdoc: true
|
136
120
|
homepage: http://rubygems.org/gems/doc_wrapper
|
137
121
|
licenses: []
|
138
|
-
|
122
|
+
metadata: {}
|
139
123
|
post_install_message:
|
140
124
|
rdoc_options: []
|
141
|
-
|
142
|
-
require_paths:
|
125
|
+
require_paths:
|
143
126
|
- lib
|
144
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
|
-
none: false
|
155
|
-
requirements:
|
156
|
-
- - ">="
|
157
|
-
- !ruby/object:Gem::Version
|
158
|
-
hash: 23
|
159
|
-
segments:
|
160
|
-
- 1
|
161
|
-
- 3
|
162
|
-
- 6
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ! '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ! '>='
|
135
|
+
- !ruby/object:Gem::Version
|
163
136
|
version: 1.3.6
|
164
137
|
requirements: []
|
165
|
-
|
166
138
|
rubyforge_project: doc_wrapper
|
167
|
-
rubygems_version:
|
139
|
+
rubygems_version: 2.4.3
|
168
140
|
signing_key:
|
169
|
-
specification_version:
|
141
|
+
specification_version: 4
|
170
142
|
summary: Declarative DSL for defining classes to wrap HTML DOM Documents
|
171
143
|
test_files: []
|
172
|
-
|