html_reader 0.0.0
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.
- data/.document +5 -0
- data/.infinity_test +19 -0
- data/.rspec +1 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +36 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +23 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/lib/html_reader.rb +79 -0
- data/log/listagem.txt +1082 -0
- data/spec/html_reader_spec.rb +87 -0
- data/spec/spec.opts +7 -0
- data/spec/spec_helper.rb +13 -0
- metadata +230 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
3
|
+
|
|
4
|
+
describe "HtmlReader" do
|
|
5
|
+
before(:each) do
|
|
6
|
+
@htmlr = HtmlReader.new
|
|
7
|
+
@valid_first_tag="//div[@class='texto']"
|
|
8
|
+
@valid_second_tag="//div"
|
|
9
|
+
@returned_content="<div><strong>Cidade: Aguaí<br />\r\n</strong>Órgão: Procon<br />\r\nEndereço: Praça Tacredo Neves, 33<br />\r\nUF: SP<br />\r\nCEP: 13860-000<br />\r\nDDD: 19<br />\r\nFone: 3652-7002/3652-1132<br />\r\n</div>"
|
|
10
|
+
@valid_phone_number = "3652-7002"
|
|
11
|
+
@valid_ddd = "19"
|
|
12
|
+
@valid_complete_phone_number = "(19) 3652-7002"
|
|
13
|
+
cleanned_string = @htmlr.clean_string @returned_content
|
|
14
|
+
@information_array = cleanned_string.split("\r\n")
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should clean the returned string" do
|
|
18
|
+
cleanned_string = @htmlr.clean_string @returned_content
|
|
19
|
+
cleanned_string.should_not include("<div>")
|
|
20
|
+
cleanned_string.should_not include("<strong>")
|
|
21
|
+
cleanned_string.should_not include("</div>")
|
|
22
|
+
cleanned_string.should_not include("</strong>")
|
|
23
|
+
cleanned_string.should_not include(" ")
|
|
24
|
+
cleanned_string.should_not include("<br />")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "should find a valid city content" do
|
|
28
|
+
@information_array
|
|
29
|
+
@information_array[0].should include("Cidade: Aguaí")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "should find a valid city" do
|
|
33
|
+
cleanned_string = @htmlr.clean_string @returned_content
|
|
34
|
+
@htmlr.find_city(cleanned_string).should == "Aguaí"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "should find a valid telephone number content" do
|
|
38
|
+
@information_array
|
|
39
|
+
@information_array[6].should include("Fone: 3652-7002/3652-1132")
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should find a valid telephone number" do
|
|
43
|
+
cleanned_string = @htmlr.clean_string @returned_content
|
|
44
|
+
@htmlr.find_telephone_number(cleanned_string).should == "3652-7002/3652-1132"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "should find a valid address content" do
|
|
48
|
+
@information_array
|
|
49
|
+
@information_array[2].should include("Endereço: Praça Tacredo Neves, 33")
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "should not be valid when contains UF in adreess" do
|
|
53
|
+
@information_array
|
|
54
|
+
@information_array[2].should_not include("UF:")
|
|
55
|
+
@information_array[2].should_not include("SP")
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "should find a valid address" do
|
|
59
|
+
cleanned_string = @htmlr.clean_string @returned_content
|
|
60
|
+
@htmlr.find_address(cleanned_string).should == "Praça Tacredo Neves, 33"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "should find a valid cep content" do
|
|
64
|
+
@information_array
|
|
65
|
+
@information_array[4].should include("CEP: 13860-000")
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "should find a valid cep" do
|
|
69
|
+
cleanned_string = @htmlr.clean_string @returned_content
|
|
70
|
+
@htmlr.find_cep(cleanned_string).should == "13860-000"
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "should find a valid ddd content" do
|
|
74
|
+
@information_array
|
|
75
|
+
@information_array[5].should include("DDD: 19")
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it "should find a valid ddd" do
|
|
79
|
+
cleanned_string = @htmlr.clean_string @returned_content
|
|
80
|
+
@htmlr.find_ddd(cleanned_string).should == "19"
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it "should find a valid complete telephone number" do
|
|
84
|
+
@htmlr.format_complete_phone_number(@valid_phone_number,@valid_ddd).should == @valid_complete_phone_number
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
3
|
+
require 'rspec'
|
|
4
|
+
require 'html_reader'
|
|
5
|
+
require 'rspec/autorun'
|
|
6
|
+
|
|
7
|
+
# Requires supporting files with custom matchers and macros, etc,
|
|
8
|
+
# in ./support/ and its subdirectories.
|
|
9
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
|
10
|
+
|
|
11
|
+
RSpec.configure do |config|
|
|
12
|
+
|
|
13
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: html_reader
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
prerelease: false
|
|
5
|
+
segments:
|
|
6
|
+
- 0
|
|
7
|
+
- 0
|
|
8
|
+
- 0
|
|
9
|
+
version: 0.0.0
|
|
10
|
+
platform: ruby
|
|
11
|
+
authors:
|
|
12
|
+
- mauriciovoto
|
|
13
|
+
autorequire:
|
|
14
|
+
bindir: bin
|
|
15
|
+
cert_chain: []
|
|
16
|
+
|
|
17
|
+
date: 2010-12-10 00:00:00 -02:00
|
|
18
|
+
default_executable:
|
|
19
|
+
dependencies:
|
|
20
|
+
- !ruby/object:Gem::Dependency
|
|
21
|
+
name: rspec
|
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
23
|
+
none: false
|
|
24
|
+
requirements:
|
|
25
|
+
- - ~>
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
segments:
|
|
28
|
+
- 2
|
|
29
|
+
- 1
|
|
30
|
+
- 0
|
|
31
|
+
version: 2.1.0
|
|
32
|
+
type: :development
|
|
33
|
+
prerelease: false
|
|
34
|
+
version_requirements: *id001
|
|
35
|
+
- !ruby/object:Gem::Dependency
|
|
36
|
+
name: bundler
|
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
38
|
+
none: false
|
|
39
|
+
requirements:
|
|
40
|
+
- - ~>
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
segments:
|
|
43
|
+
- 1
|
|
44
|
+
- 0
|
|
45
|
+
- 0
|
|
46
|
+
version: 1.0.0
|
|
47
|
+
type: :development
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: *id002
|
|
50
|
+
- !ruby/object:Gem::Dependency
|
|
51
|
+
name: jeweler
|
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
53
|
+
none: false
|
|
54
|
+
requirements:
|
|
55
|
+
- - ~>
|
|
56
|
+
- !ruby/object:Gem::Version
|
|
57
|
+
segments:
|
|
58
|
+
- 1
|
|
59
|
+
- 5
|
|
60
|
+
- 1
|
|
61
|
+
version: 1.5.1
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: *id003
|
|
65
|
+
- !ruby/object:Gem::Dependency
|
|
66
|
+
name: rcov
|
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
|
68
|
+
none: false
|
|
69
|
+
requirements:
|
|
70
|
+
- - ">"
|
|
71
|
+
- !ruby/object:Gem::Version
|
|
72
|
+
segments:
|
|
73
|
+
- 0
|
|
74
|
+
version: "0"
|
|
75
|
+
type: :development
|
|
76
|
+
prerelease: false
|
|
77
|
+
version_requirements: *id004
|
|
78
|
+
- !ruby/object:Gem::Dependency
|
|
79
|
+
name: hpricot
|
|
80
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
|
81
|
+
none: false
|
|
82
|
+
requirements:
|
|
83
|
+
- - ">"
|
|
84
|
+
- !ruby/object:Gem::Version
|
|
85
|
+
segments:
|
|
86
|
+
- 0
|
|
87
|
+
version: "0"
|
|
88
|
+
type: :development
|
|
89
|
+
prerelease: false
|
|
90
|
+
version_requirements: *id005
|
|
91
|
+
- !ruby/object:Gem::Dependency
|
|
92
|
+
name: rest-open-uri
|
|
93
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
|
94
|
+
none: false
|
|
95
|
+
requirements:
|
|
96
|
+
- - ">"
|
|
97
|
+
- !ruby/object:Gem::Version
|
|
98
|
+
segments:
|
|
99
|
+
- 0
|
|
100
|
+
version: "0"
|
|
101
|
+
type: :development
|
|
102
|
+
prerelease: false
|
|
103
|
+
version_requirements: *id006
|
|
104
|
+
- !ruby/object:Gem::Dependency
|
|
105
|
+
name: spreadsheet
|
|
106
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
|
107
|
+
none: false
|
|
108
|
+
requirements:
|
|
109
|
+
- - ">"
|
|
110
|
+
- !ruby/object:Gem::Version
|
|
111
|
+
segments:
|
|
112
|
+
- 0
|
|
113
|
+
version: "0"
|
|
114
|
+
type: :development
|
|
115
|
+
prerelease: false
|
|
116
|
+
version_requirements: *id007
|
|
117
|
+
- !ruby/object:Gem::Dependency
|
|
118
|
+
name: hpricot
|
|
119
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
|
120
|
+
none: false
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">"
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
segments:
|
|
125
|
+
- 0
|
|
126
|
+
version: "0"
|
|
127
|
+
type: :runtime
|
|
128
|
+
prerelease: false
|
|
129
|
+
version_requirements: *id008
|
|
130
|
+
- !ruby/object:Gem::Dependency
|
|
131
|
+
name: rest-open-uri
|
|
132
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
|
133
|
+
none: false
|
|
134
|
+
requirements:
|
|
135
|
+
- - ">"
|
|
136
|
+
- !ruby/object:Gem::Version
|
|
137
|
+
segments:
|
|
138
|
+
- 0
|
|
139
|
+
version: "0"
|
|
140
|
+
type: :runtime
|
|
141
|
+
prerelease: false
|
|
142
|
+
version_requirements: *id009
|
|
143
|
+
- !ruby/object:Gem::Dependency
|
|
144
|
+
name: spreadsheet
|
|
145
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
|
146
|
+
none: false
|
|
147
|
+
requirements:
|
|
148
|
+
- - ">"
|
|
149
|
+
- !ruby/object:Gem::Version
|
|
150
|
+
segments:
|
|
151
|
+
- 0
|
|
152
|
+
version: "0"
|
|
153
|
+
type: :runtime
|
|
154
|
+
prerelease: false
|
|
155
|
+
version_requirements: *id010
|
|
156
|
+
- !ruby/object:Gem::Dependency
|
|
157
|
+
name: rspec
|
|
158
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
|
159
|
+
none: false
|
|
160
|
+
requirements:
|
|
161
|
+
- - ">"
|
|
162
|
+
- !ruby/object:Gem::Version
|
|
163
|
+
segments:
|
|
164
|
+
- 1
|
|
165
|
+
- 2
|
|
166
|
+
- 3
|
|
167
|
+
version: 1.2.3
|
|
168
|
+
type: :development
|
|
169
|
+
prerelease: false
|
|
170
|
+
version_requirements: *id011
|
|
171
|
+
description: This gem was created to generate a worksheet with some informations about Procon and off course, my first gem, so it was my lab
|
|
172
|
+
email: mauriciovoto@gmail.com
|
|
173
|
+
executables: []
|
|
174
|
+
|
|
175
|
+
extensions: []
|
|
176
|
+
|
|
177
|
+
extra_rdoc_files:
|
|
178
|
+
- LICENSE.txt
|
|
179
|
+
- README.rdoc
|
|
180
|
+
files:
|
|
181
|
+
- .document
|
|
182
|
+
- .infinity_test
|
|
183
|
+
- .rspec
|
|
184
|
+
- Gemfile
|
|
185
|
+
- Gemfile.lock
|
|
186
|
+
- LICENSE.txt
|
|
187
|
+
- README.rdoc
|
|
188
|
+
- Rakefile
|
|
189
|
+
- VERSION
|
|
190
|
+
- lib/html_reader.rb
|
|
191
|
+
- log/listagem.txt
|
|
192
|
+
- spec/html_reader_spec.rb
|
|
193
|
+
- spec/spec.opts
|
|
194
|
+
- spec/spec_helper.rb
|
|
195
|
+
has_rdoc: true
|
|
196
|
+
homepage: http://github.com/mauriciovoto/html_reader
|
|
197
|
+
licenses:
|
|
198
|
+
- MIT
|
|
199
|
+
post_install_message:
|
|
200
|
+
rdoc_options: []
|
|
201
|
+
|
|
202
|
+
require_paths:
|
|
203
|
+
- lib
|
|
204
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
205
|
+
none: false
|
|
206
|
+
requirements:
|
|
207
|
+
- - ">="
|
|
208
|
+
- !ruby/object:Gem::Version
|
|
209
|
+
hash: -3431676198434769912
|
|
210
|
+
segments:
|
|
211
|
+
- 0
|
|
212
|
+
version: "0"
|
|
213
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
|
+
none: false
|
|
215
|
+
requirements:
|
|
216
|
+
- - ">="
|
|
217
|
+
- !ruby/object:Gem::Version
|
|
218
|
+
segments:
|
|
219
|
+
- 0
|
|
220
|
+
version: "0"
|
|
221
|
+
requirements: []
|
|
222
|
+
|
|
223
|
+
rubyforge_project:
|
|
224
|
+
rubygems_version: 1.3.7
|
|
225
|
+
signing_key:
|
|
226
|
+
specification_version: 3
|
|
227
|
+
summary: This is a gem to find out all the Procon's address info on the website of it and generate a worksheet with that content.
|
|
228
|
+
test_files:
|
|
229
|
+
- spec/html_reader_spec.rb
|
|
230
|
+
- spec/spec_helper.rb
|