earl 0.3.0 → 2.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.
- checksums.yaml +7 -0
- data/.github/workflows/ruby-tests.yml +32 -0
- data/.gitignore +5 -0
- data/.rubocop.yml +35 -0
- data/.rubocop_todo.yml +22 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +13 -1
- data/Guardfile +15 -0
- data/LICENSE +2 -2
- data/README.md +127 -25
- data/Rakefile +10 -2
- data/earl.gemspec +19 -14
- data/lib/earl/earl.rb +172 -0
- data/lib/earl/scraper.rb +92 -0
- data/lib/earl/version.rb +4 -2
- data/lib/earl.rb +11 -20
- data/spec/fixtures/bicycles.html +490 -0
- data/spec/fixtures/bicycles_without_description.html +489 -0
- data/spec/fixtures/bicycles_without_images.html +457 -0
- data/spec/fixtures/cassettes/feed/is_atom_feed.yml +2298 -0
- data/spec/fixtures/cassettes/feed/is_rss_feed.yml +48 -0
- data/spec/fixtures/cassettes/feed/no_feed.yml +69 -0
- data/spec/fixtures/cassettes/feed/with_atom_and_rss_feed.yml +1471 -0
- data/spec/fixtures/cassettes/feed/with_rss_feed.yml +47 -0
- data/spec/fixtures/cassettes/oembed/no_oembed.yml +101 -0
- data/spec/fixtures/cassettes/oembed/youtube_oembed.yml +129 -0
- data/spec/fixtures/page_as_atom.html +161 -0
- data/spec/fixtures/page_as_rss.html +151 -0
- data/spec/fixtures/page_with_atom_feed.html +39 -0
- data/spec/fixtures/page_with_rss_and_atom_feeds.html +40 -0
- data/spec/fixtures/page_with_rss_feed.html +39 -0
- data/spec/fixtures/page_without_feeds.html +36 -0
- data/spec/fixtures/youtube.html +1839 -0
- data/spec/integration/feed_spec.rb +78 -0
- data/spec/integration/oembed_spec.rb +36 -0
- data/spec/spec_helper.rb +21 -29
- data/spec/support/fixtures.rb +15 -0
- data/spec/support/vcr.rb +9 -0
- data/spec/unit/earl/earl_spec.rb +15 -0
- data/spec/unit/earl/feed_spec.rb +62 -0
- data/spec/unit/earl/oembed_spec.rb +50 -0
- data/spec/unit/earl/scraper_spec.rb +49 -0
- data/spec/unit/earl_spec.rb +74 -0
- metadata +90 -62
- data/.rvmrc +0 -48
- data/lib/earl/email_assembler.rb +0 -11
- data/lib/earl/email_entity.rb +0 -27
- data/lib/earl/email_parser.tt +0 -58
- data/lib/earl/entity_base.rb +0 -37
- data/lib/earl/hash_inquirer.rb +0 -16
- data/lib/earl/string_inquirer.rb +0 -11
- data/lib/earl/url_assembler.rb +0 -15
- data/lib/earl/url_entity.rb +0 -23
- data/lib/earl/url_parser.tt +0 -163
- data/spec/earl/earl_spec.rb +0 -17
- data/spec/earl/email_entity_spec.rb +0 -31
- data/spec/earl/email_parser_spec.rb +0 -29
- data/spec/earl/entity_base_spec.rb +0 -39
- data/spec/earl/hash_inquirer_spec.rb +0 -24
- data/spec/earl/string_inquirer_spec.rb +0 -9
- data/spec/earl/url_entity_spec.rb +0 -45
- data/spec/earl/url_parser_spec.rb +0 -189
@@ -1,189 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Earl do
|
4
|
-
let( :parser ){ Earl::URLParser.new }
|
5
|
-
let( :assembler ){ Earl::URLAssembler.new }
|
6
|
-
|
7
|
-
[
|
8
|
-
[ 'localhost', {
|
9
|
-
:host => 'localhost'
|
10
|
-
} ],
|
11
|
-
[ 'foo.com', {
|
12
|
-
:host => 'foo.com'
|
13
|
-
} ],
|
14
|
-
|
15
|
-
[ 'foo.edu', {
|
16
|
-
:host => 'foo.edu'
|
17
|
-
} ],
|
18
|
-
|
19
|
-
[ 'foo2bar.biz', {
|
20
|
-
:host => 'foo2bar.biz'
|
21
|
-
} ],
|
22
|
-
|
23
|
-
[ 'www.foo.com', {
|
24
|
-
:host => 'foo.com',
|
25
|
-
:subdomain => 'www'
|
26
|
-
} ],
|
27
|
-
|
28
|
-
[ 'http://localhost', {
|
29
|
-
:scheme => 'http',
|
30
|
-
:host => 'localhost'
|
31
|
-
} ],
|
32
|
-
|
33
|
-
[ 'http://foo.com', {
|
34
|
-
:scheme => 'http',
|
35
|
-
:host => 'foo.com'
|
36
|
-
} ],
|
37
|
-
|
38
|
-
[ 'http://www.foo.com', {
|
39
|
-
:scheme => 'http',
|
40
|
-
:host => 'foo.com',
|
41
|
-
:subdomain => 'www'
|
42
|
-
} ],
|
43
|
-
|
44
|
-
[ 'localhost:3000', {
|
45
|
-
:host => 'localhost',
|
46
|
-
:port => '3000'
|
47
|
-
} ],
|
48
|
-
|
49
|
-
[ 'http://localhost:3000', {
|
50
|
-
:scheme => 'http',
|
51
|
-
:host => 'localhost',
|
52
|
-
:port => '3000'
|
53
|
-
} ],
|
54
|
-
|
55
|
-
[ 'www.foo.com:8080', {
|
56
|
-
:subdomain => 'www',
|
57
|
-
:host => 'foo.com',
|
58
|
-
:port => '8080'
|
59
|
-
} ],
|
60
|
-
|
61
|
-
[ 'http://www.foo.com:8080', {
|
62
|
-
:scheme => 'http',
|
63
|
-
:subdomain => 'www',
|
64
|
-
:host => 'foo.com',
|
65
|
-
:port => '8080'
|
66
|
-
} ],
|
67
|
-
|
68
|
-
[ 'localhost/bar', {
|
69
|
-
:host => 'localhost',
|
70
|
-
:path => 'bar'
|
71
|
-
} ],
|
72
|
-
|
73
|
-
[ 'foo.com/bar', {
|
74
|
-
:host => 'foo.com',
|
75
|
-
:path => 'bar'
|
76
|
-
} ],
|
77
|
-
|
78
|
-
[ 'www.foo.com/bar', {
|
79
|
-
:subdomain => 'www',
|
80
|
-
:host => 'foo.com',
|
81
|
-
:path => 'bar'
|
82
|
-
} ],
|
83
|
-
|
84
|
-
[ 'http://localhost/bar', {
|
85
|
-
:scheme => 'http',
|
86
|
-
:host => 'localhost',
|
87
|
-
:path => 'bar'
|
88
|
-
} ],
|
89
|
-
|
90
|
-
[ 'http://foo.com/bar', {
|
91
|
-
:scheme => 'http',
|
92
|
-
:host => 'foo.com',
|
93
|
-
:path => 'bar'
|
94
|
-
} ],
|
95
|
-
|
96
|
-
[ 'http://www.foo.com/bar', {
|
97
|
-
:scheme => 'http',
|
98
|
-
:subdomain => 'www',
|
99
|
-
:host => 'foo.com',
|
100
|
-
:path => 'bar'
|
101
|
-
} ],
|
102
|
-
|
103
|
-
[ 'localhost?baz=woo', {
|
104
|
-
:host => 'localhost',
|
105
|
-
:search => 'baz=woo'
|
106
|
-
} ],
|
107
|
-
|
108
|
-
[ 'localhost:3000?baz=woo', {
|
109
|
-
:host => 'localhost',
|
110
|
-
:port => '3000',
|
111
|
-
:search => 'baz=woo'
|
112
|
-
} ],
|
113
|
-
|
114
|
-
[ 'localhost:3000/bar?baz=woo', {
|
115
|
-
:host => 'localhost',
|
116
|
-
:port => '3000',
|
117
|
-
:path => 'bar',
|
118
|
-
:search => 'baz=woo'
|
119
|
-
} ],
|
120
|
-
|
121
|
-
[ 'foo.com?baz=woo', {
|
122
|
-
:host => 'foo.com',
|
123
|
-
:search => 'baz=woo'
|
124
|
-
} ],
|
125
|
-
|
126
|
-
[ 'www.foo.com?baz=woo', {
|
127
|
-
:subdomain => 'www',
|
128
|
-
:host => 'foo.com',
|
129
|
-
:search => 'baz=woo'
|
130
|
-
} ],
|
131
|
-
|
132
|
-
[ 'http://foo.com?baz=woo', {
|
133
|
-
:scheme => 'http',
|
134
|
-
:host => 'foo.com',
|
135
|
-
:search => 'baz=woo'
|
136
|
-
} ],
|
137
|
-
|
138
|
-
[ 'http://www.foo.com?baz=woo', {
|
139
|
-
:scheme => 'http',
|
140
|
-
:subdomain => 'www',
|
141
|
-
:host => 'foo.com',
|
142
|
-
:search => 'baz=woo'
|
143
|
-
} ],
|
144
|
-
|
145
|
-
[ 'http://foo.com/bar?baz=woo', {
|
146
|
-
:scheme => 'http',
|
147
|
-
:host => 'foo.com',
|
148
|
-
:path => 'bar',
|
149
|
-
:search => 'baz=woo'
|
150
|
-
} ],
|
151
|
-
|
152
|
-
[ 'http://www.foo.com/bar?baz=woot', {
|
153
|
-
:scheme => 'http',
|
154
|
-
:subdomain => 'www',
|
155
|
-
:host => 'foo.com',
|
156
|
-
:path => 'bar',
|
157
|
-
:search => 'baz=woot'
|
158
|
-
} ],
|
159
|
-
|
160
|
-
[ 'http://localhost:3000?baz=woo', {
|
161
|
-
:scheme => 'http',
|
162
|
-
:host => 'localhost',
|
163
|
-
:port => '3000',
|
164
|
-
:search => 'baz=woo'
|
165
|
-
} ],
|
166
|
-
|
167
|
-
[ 'http://foo.com:8080?baz=woooo', {
|
168
|
-
:scheme => 'http',
|
169
|
-
:host => 'foo.com',
|
170
|
-
:port => '8080',
|
171
|
-
:search => 'baz=woooo'
|
172
|
-
} ],
|
173
|
-
|
174
|
-
[ 'http://foo.com:8080/bar?baz=woo', {
|
175
|
-
:scheme => 'http',
|
176
|
-
:host => 'foo.com',
|
177
|
-
:port => '8080',
|
178
|
-
:path => 'bar',
|
179
|
-
:search => 'baz=woo'
|
180
|
-
} ]
|
181
|
-
].each do |string, parts|
|
182
|
-
it "should correctly parse the url parts for #{string}" do
|
183
|
-
parser.parse( string ).resolve.should eql( parts )
|
184
|
-
end
|
185
|
-
it "should correctly assemble the url parts to #{string}" do
|
186
|
-
assembler.assemble( parts ).should eql( string )
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|