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.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ruby-tests.yml +32 -0
  3. data/.gitignore +5 -0
  4. data/.rubocop.yml +35 -0
  5. data/.rubocop_todo.yml +22 -0
  6. data/.ruby-gemset +1 -0
  7. data/.ruby-version +1 -0
  8. data/Gemfile +13 -1
  9. data/Guardfile +15 -0
  10. data/LICENSE +2 -2
  11. data/README.md +127 -25
  12. data/Rakefile +10 -2
  13. data/earl.gemspec +19 -14
  14. data/lib/earl/earl.rb +172 -0
  15. data/lib/earl/scraper.rb +92 -0
  16. data/lib/earl/version.rb +4 -2
  17. data/lib/earl.rb +11 -20
  18. data/spec/fixtures/bicycles.html +490 -0
  19. data/spec/fixtures/bicycles_without_description.html +489 -0
  20. data/spec/fixtures/bicycles_without_images.html +457 -0
  21. data/spec/fixtures/cassettes/feed/is_atom_feed.yml +2298 -0
  22. data/spec/fixtures/cassettes/feed/is_rss_feed.yml +48 -0
  23. data/spec/fixtures/cassettes/feed/no_feed.yml +69 -0
  24. data/spec/fixtures/cassettes/feed/with_atom_and_rss_feed.yml +1471 -0
  25. data/spec/fixtures/cassettes/feed/with_rss_feed.yml +47 -0
  26. data/spec/fixtures/cassettes/oembed/no_oembed.yml +101 -0
  27. data/spec/fixtures/cassettes/oembed/youtube_oembed.yml +129 -0
  28. data/spec/fixtures/page_as_atom.html +161 -0
  29. data/spec/fixtures/page_as_rss.html +151 -0
  30. data/spec/fixtures/page_with_atom_feed.html +39 -0
  31. data/spec/fixtures/page_with_rss_and_atom_feeds.html +40 -0
  32. data/spec/fixtures/page_with_rss_feed.html +39 -0
  33. data/spec/fixtures/page_without_feeds.html +36 -0
  34. data/spec/fixtures/youtube.html +1839 -0
  35. data/spec/integration/feed_spec.rb +78 -0
  36. data/spec/integration/oembed_spec.rb +36 -0
  37. data/spec/spec_helper.rb +21 -29
  38. data/spec/support/fixtures.rb +15 -0
  39. data/spec/support/vcr.rb +9 -0
  40. data/spec/unit/earl/earl_spec.rb +15 -0
  41. data/spec/unit/earl/feed_spec.rb +62 -0
  42. data/spec/unit/earl/oembed_spec.rb +50 -0
  43. data/spec/unit/earl/scraper_spec.rb +49 -0
  44. data/spec/unit/earl_spec.rb +74 -0
  45. metadata +90 -62
  46. data/.rvmrc +0 -48
  47. data/lib/earl/email_assembler.rb +0 -11
  48. data/lib/earl/email_entity.rb +0 -27
  49. data/lib/earl/email_parser.tt +0 -58
  50. data/lib/earl/entity_base.rb +0 -37
  51. data/lib/earl/hash_inquirer.rb +0 -16
  52. data/lib/earl/string_inquirer.rb +0 -11
  53. data/lib/earl/url_assembler.rb +0 -15
  54. data/lib/earl/url_entity.rb +0 -23
  55. data/lib/earl/url_parser.tt +0 -163
  56. data/spec/earl/earl_spec.rb +0 -17
  57. data/spec/earl/email_entity_spec.rb +0 -31
  58. data/spec/earl/email_parser_spec.rb +0 -29
  59. data/spec/earl/entity_base_spec.rb +0 -39
  60. data/spec/earl/hash_inquirer_spec.rb +0 -24
  61. data/spec/earl/string_inquirer_spec.rb +0 -9
  62. data/spec/earl/url_entity_spec.rb +0 -45
  63. 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