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 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
@@ -1,4 +1,4 @@
1
- source :gemcutter
1
+ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in doc_wrapper.gemspec
4
4
  gemspec
data/Gemfile.lock CHANGED
@@ -1,15 +1,24 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- doc_wrapper (0.9.2)
4
+ doc_wrapper (0.9.5)
5
5
  activesupport (>= 3.0.0)
6
6
 
7
7
  GEM
8
- remote: http://rubygems.org/
8
+ remote: https://rubygems.org/
9
9
  specs:
10
10
  ZenTest (4.4.2)
11
- activesupport (3.0.5)
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
@@ -1,3 +1,3 @@
1
1
  module DocWrapper
2
- VERSION = "0.9.4"
2
+ VERSION = "0.9.5"
3
3
  end
@@ -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.size.should == 14 }
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 &nbsp; 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
@@ -25,5 +25,6 @@
25
25
  <p class="name">Mark Menard</p>
26
26
  <p class="home_town">Troy, NY</p>
27
27
  </div>
28
+ <p class="float">117.23</p><!-- float -->
28
29
  </body>
29
30
  </html>
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
- hash: 51
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
- date: 2011-06-26 00:00:00 -04:00
19
- default_executable:
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
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
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
- requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 23
46
- segments:
47
- - 1
48
- - 0
49
- - 0
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
- requirement: &id003 !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- hash: 3
62
- segments:
63
- - 0
64
- version: "0"
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
- requirement: &id004 !ruby/object:Gem::Requirement
71
- none: false
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- hash: 15
76
- segments:
77
- - 2
78
- - 0
79
- - 0
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
- requirement: &id005 !ruby/object:Gem::Requirement
87
- none: false
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- hash: 3
92
- segments:
93
- - 0
94
- version: "0"
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
- version_requirements: *id005
97
- description: Using the DocWrapper DSL you can easily define classes that wrap HTML DOM Documents allowing extraction of properties using either XPath or CSS selectors.
98
- email:
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
- none: false
146
- requirements:
147
- - - ">="
148
- - !ruby/object:Gem::Version
149
- hash: 3
150
- segments:
151
- - 0
152
- version: "0"
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: 1.6.2
139
+ rubygems_version: 2.4.3
168
140
  signing_key:
169
- specification_version: 3
141
+ specification_version: 4
170
142
  summary: Declarative DSL for defining classes to wrap HTML DOM Documents
171
143
  test_files: []
172
-