color_parser 0.0.2
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/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +43 -0
- data/Rakefile +10 -0
- data/color_parser.gemspec +26 -0
- data/lib/color_parser/image.rb +20 -0
- data/lib/color_parser/page.rb +88 -0
- data/lib/color_parser/stylesheet.rb +197 -0
- data/lib/color_parser/version.rb +3 -0
- data/lib/color_parser.rb +142 -0
- data/test/color_parser_test.rb +83 -0
- data/test/fixtures/css/absolute.html +15 -0
- data/test/fixtures/css/inline.html +34 -0
- data/test/fixtures/css/inline_import.html +16 -0
- data/test/fixtures/css/invalid.html +15 -0
- data/test/fixtures/css/relative.html +15 -0
- data/test/fixtures/css/relative_root.html +15 -0
- data/test/fixtures/css/stylesheets/colors.css +0 -0
- data/test/fixtures/css/stylesheets/fonts.css +0 -0
- data/test/fixtures/css/stylesheets/print.css +3 -0
- data/test/fixtures/css/stylesheets/screen.css +16 -0
- data/test/fixtures/css_color/frequency.html +22 -0
- data/test/fixtures/css_color/stylesheets/color_styles.css +34 -0
- data/test/fixtures/css_color/stylesheets/css_elements.css +24 -0
- data/test/fixtures/css_color/stylesheets/frequency.css +35 -0
- data/test/fixtures/css_color/stylesheets/imported_selectors.css +3 -0
- data/test/fixtures/css_color/stylesheets/properties.css +18 -0
- data/test/fixtures/css_images/images/apple.png +0 -0
- data/test/fixtures/css_images/images/cantaloupe.png +0 -0
- data/test/fixtures/css_images/images/kiwi.jpg +0 -0
- data/test/fixtures/css_images/images/mango.png +0 -0
- data/test/fixtures/css_images/images/pineapple.png +0 -0
- data/test/fixtures/css_images/paths.html +14 -0
- data/test/fixtures/css_images/stylesheets/import_paths.css +4 -0
- data/test/fixtures/css_images/stylesheets/paths.css +17 -0
- data/test/fixtures/css_images/stylesheets/quotes.css +14 -0
- data/test/fixtures/css_import/index.html +15 -0
- data/test/fixtures/css_import/stylesheets/borders.css +0 -0
- data/test/fixtures/css_import/stylesheets/colors.css +0 -0
- data/test/fixtures/css_import/stylesheets/fonts.css +3 -0
- data/test/fixtures/css_import/stylesheets/ie.css +3 -0
- data/test/fixtures/css_import/stylesheets/images.css +0 -0
- data/test/fixtures/css_import/stylesheets/master.css +12 -0
- data/test/fixtures/css_import/stylesheets/print.css +3 -0
- data/test/fixtures/css_import/stylesheets/screen.css +12 -0
- data/test/fixtures/inline_images/absolute.html +14 -0
- data/test/fixtures/inline_images/images/apple.png +0 -0
- data/test/fixtures/inline_images/images/kiwi.jpg +0 -0
- data/test/fixtures/inline_images/relative.html +14 -0
- data/test/fixtures/inline_images/relative_root.html +14 -0
- data/test/image_test.rb +27 -0
- data/test/page_test.rb +194 -0
- data/test/stylesheet_test.rb +257 -0
- data/test/test_helper.rb +6 -0
- data/test/test_request.rb +19 -0
- data/test/version_test.rb +7 -0
- metadata +184 -0
data/test/page_test.rb
ADDED
@@ -0,0 +1,194 @@
|
|
1
|
+
require_relative "test_helper"
|
2
|
+
|
3
|
+
describe Page do
|
4
|
+
def setup
|
5
|
+
ColorParser.request = ColorParser::TestRequest.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should initialize url" do
|
9
|
+
url = "http://example.com/css/inline.html?foo=bar"
|
10
|
+
page = ColorParser::Page.new(url)
|
11
|
+
|
12
|
+
page.url.must_equal url
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should parse url" do
|
16
|
+
url = "http://example.com/css/inline.html?foo=bar"
|
17
|
+
page = ColorParser::Page.new(url)
|
18
|
+
|
19
|
+
page.host.must_equal "example.com"
|
20
|
+
page.path.must_equal "/css/inline.html"
|
21
|
+
page.query.must_equal "foo=bar"
|
22
|
+
end
|
23
|
+
|
24
|
+
# Stylesheet sources
|
25
|
+
it "should build styles from inline css" do
|
26
|
+
url = "http://example.com/css/inline.html"
|
27
|
+
page = ColorParser::Page.new(url)
|
28
|
+
|
29
|
+
# 2 found
|
30
|
+
page.stylesheets.length.must_equal 2
|
31
|
+
|
32
|
+
# stylesheet content
|
33
|
+
sheet = page.stylesheets.first
|
34
|
+
sheet.type.must_equal "inline"
|
35
|
+
sheet.text.must_include "background"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should build styles with inine css with import" do
|
39
|
+
url = "http://example.com/css/inline_import.html"
|
40
|
+
page = ColorParser::Page.new(url)
|
41
|
+
|
42
|
+
page.stylesheets.length.must_equal 1
|
43
|
+
|
44
|
+
page.stylesheets[0].name.must_equal "inline_import.html"
|
45
|
+
page.stylesheets[0].stylesheets[0].name.must_equal "print.css"
|
46
|
+
page.stylesheets[0].stylesheets[1].name.must_equal "fonts.css"
|
47
|
+
page.stylesheets[0].stylesheets[2].name.must_equal "colors.css"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should build styles from external relative css" do
|
51
|
+
url = "http://example.com/css/relative.html"
|
52
|
+
page = ColorParser::Page.new(url)
|
53
|
+
|
54
|
+
# 2 found
|
55
|
+
page.stylesheets.length.must_equal 2
|
56
|
+
|
57
|
+
# stylesheet content
|
58
|
+
sheet = page.stylesheets.first
|
59
|
+
sheet.type.must_equal "external"
|
60
|
+
sheet.text.must_include "background"
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should build styles from external relative root css" do
|
64
|
+
url = "http://example.com/css/relative_root.html"
|
65
|
+
page = ColorParser::Page.new(url)
|
66
|
+
|
67
|
+
# 2 found
|
68
|
+
page.stylesheets.length.must_equal 2
|
69
|
+
|
70
|
+
# stylesheet content
|
71
|
+
sheet = page.stylesheets.first
|
72
|
+
sheet.type.must_equal "external"
|
73
|
+
sheet.text.must_include "background"
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should build styles from external absolute css" do
|
77
|
+
url = "http://example.com/css/relative.html"
|
78
|
+
page = ColorParser::Page.new(url)
|
79
|
+
|
80
|
+
# 2 found
|
81
|
+
page.stylesheets.length.must_equal 2
|
82
|
+
|
83
|
+
# stylesheet content
|
84
|
+
sheet = page.stylesheets.first
|
85
|
+
sheet.type.must_equal "external"
|
86
|
+
sheet.text.must_include "background"
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should build styles from imported css" do
|
90
|
+
url = "http://example.com/css_import/index.html"
|
91
|
+
page = ColorParser::Page.new(url)
|
92
|
+
css = page.stylesheets
|
93
|
+
|
94
|
+
css.length.must_equal 2
|
95
|
+
|
96
|
+
# 5 found
|
97
|
+
css[0].name.must_include "screen.css"
|
98
|
+
css[1].name.must_include "print.css"
|
99
|
+
|
100
|
+
css[0].stylesheets[0].name.must_include "master.css"
|
101
|
+
css[0].stylesheets[1].name.must_include "fonts.css"
|
102
|
+
css[0].stylesheets[2].name.must_include "ie.css"
|
103
|
+
css[0].stylesheets[3].name.must_include "images.css"
|
104
|
+
css[0].stylesheets[4].name.must_include "borders.css"
|
105
|
+
css[0].stylesheets[5].name.must_include "colors.css"
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should not fail from an invalid css path" do
|
109
|
+
url = "http://example.com/css/invalid.html"
|
110
|
+
page = ColorParser::Page.new(url)
|
111
|
+
|
112
|
+
# 1 found
|
113
|
+
page.stylesheets.length.must_equal 1
|
114
|
+
page.stylesheets[0].name.must_include "screen.css"
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
# IMAGES
|
119
|
+
|
120
|
+
it "should build images from inline images with relative paths" do
|
121
|
+
url = "http://example.com/inline_images/relative.html"
|
122
|
+
page = ColorParser::Page.new(url)
|
123
|
+
images = page.images
|
124
|
+
|
125
|
+
images.size.must_equal 2
|
126
|
+
|
127
|
+
images[0].url.must_equal "http://example.com/inline_images/images/apple.png"
|
128
|
+
images[1].url.must_equal "http://example.com/inline_images/images/kiwi.jpg"
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should build images from inline images with relative root paths" do
|
132
|
+
url = "http://example.com/inline_images/relative_root.html"
|
133
|
+
page = ColorParser::Page.new(url)
|
134
|
+
images = page.images
|
135
|
+
|
136
|
+
images.size.must_equal 2
|
137
|
+
|
138
|
+
images[0].url.must_equal "http://example.com/inline_images/images/apple.png"
|
139
|
+
images[1].url.must_equal "http://example.com/inline_images/images/kiwi.jpg"
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should build images from inline images with absolute paths" do
|
143
|
+
url = "http://example.com/inline_images/absolute.html"
|
144
|
+
page = ColorParser::Page.new(url)
|
145
|
+
images = page.images
|
146
|
+
|
147
|
+
images.size.must_equal 2
|
148
|
+
|
149
|
+
images[0].url.must_equal "http://example.com/inline_images/images/apple.png"
|
150
|
+
images[1].url.must_equal "http://example.com/inline_images/images/kiwi.jpg"
|
151
|
+
end
|
152
|
+
|
153
|
+
|
154
|
+
# STYLESHEET IMAGES
|
155
|
+
|
156
|
+
it "should combine images from inline external and import styles" do
|
157
|
+
url = "http://example.com/css_images/paths.html"
|
158
|
+
page = ColorParser::Page.new(url)
|
159
|
+
images = page.images
|
160
|
+
|
161
|
+
images.size.must_equal 5
|
162
|
+
|
163
|
+
images[0].name.must_equal "mango.png"
|
164
|
+
images[1].name.must_equal "apple.png"
|
165
|
+
images[2].name.must_equal "kiwi.jpg"
|
166
|
+
images[3].name.must_equal "cantaloupe.png"
|
167
|
+
images[4].name.must_equal "pineapple.png"
|
168
|
+
end
|
169
|
+
|
170
|
+
|
171
|
+
# STYLESHEET COLORS
|
172
|
+
|
173
|
+
it "should combine colors from external and import styles" do
|
174
|
+
url = "http://example.com/css_color/frequency.html"
|
175
|
+
page = ColorParser::Page.new(url)
|
176
|
+
colors = page.colors
|
177
|
+
|
178
|
+
colors["386ec0"].must_equal 4
|
179
|
+
colors["3a5dc4"].must_equal 3
|
180
|
+
colors["718ad7"].must_equal 2
|
181
|
+
colors["ff0000"].must_equal 1
|
182
|
+
colors["357ad1"].must_equal 1
|
183
|
+
colors["535353"].must_equal 1
|
184
|
+
end
|
185
|
+
|
186
|
+
it "should solot colors by frequency" do
|
187
|
+
url = "http://example.com/css_color/frequency.html"
|
188
|
+
page = ColorParser::Page.new(url)
|
189
|
+
|
190
|
+
colors = ["386ec0", "3a5dc4", "718ad7", "535353", "357ad1", "ff0000"]
|
191
|
+
page.colors_by_frequency.must_equal colors
|
192
|
+
end
|
193
|
+
|
194
|
+
end
|
@@ -0,0 +1,257 @@
|
|
1
|
+
require_relative "test_helper"
|
2
|
+
|
3
|
+
describe Stylesheet do
|
4
|
+
def setup
|
5
|
+
ColorParser.request = ColorParser::TestRequest.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "must initialize params" do
|
9
|
+
sheet = ColorParser::Stylesheet.new(text: "a { background: #fff; }",
|
10
|
+
type: "inline",
|
11
|
+
url: "http://example.com/css/inline.html?foo=bar")
|
12
|
+
sheet.type.must_equal "inline"
|
13
|
+
sheet.text.must_equal "a { background: #fff; }"
|
14
|
+
sheet.url.must_equal "http://example.com/css/inline.html?foo=bar"
|
15
|
+
sheet.host.must_equal "example.com"
|
16
|
+
sheet.path.must_equal "/css/inline.html"
|
17
|
+
sheet.query.must_equal "foo=bar"
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
# Import Quoting
|
22
|
+
|
23
|
+
it "should import stylesheets with double quotes" do
|
24
|
+
css = style("/css_import/stylesheets/screen.css")
|
25
|
+
|
26
|
+
imported = css.stylesheets[0]
|
27
|
+
imported.name.must_equal "master.css"
|
28
|
+
imported.text.must_include "a:link"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should import stylesheets with single quotes" do
|
32
|
+
css = style("/css_import/stylesheets/screen.css")
|
33
|
+
|
34
|
+
imported = css.stylesheets[1]
|
35
|
+
imported.name.must_equal "fonts.css"
|
36
|
+
imported.text.must_include "font-family"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should import stylesheets with no quotes" do
|
40
|
+
css = style("/css_import/stylesheets/screen.css")
|
41
|
+
|
42
|
+
imported = css.stylesheets[2]
|
43
|
+
imported.name.must_equal "ie.css"
|
44
|
+
imported.text.must_include "background-color"
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
# Import Paths
|
49
|
+
|
50
|
+
it "should import from relative path" do
|
51
|
+
css = style("/css_import/stylesheets/screen.css")
|
52
|
+
|
53
|
+
imported = css.stylesheets[0]
|
54
|
+
imported.url.must_equal "http://example.com/css_import/stylesheets/master.css"
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should import from relative root path" do
|
58
|
+
css = style("/css_import/stylesheets/screen.css")
|
59
|
+
|
60
|
+
imported = css.stylesheets[1]
|
61
|
+
imported.url.must_equal "http://example.com/css_import/stylesheets/fonts.css"
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should import from absolute path" do
|
65
|
+
css = style("/css_import/stylesheets/screen.css")
|
66
|
+
|
67
|
+
imported = css.stylesheets[2]
|
68
|
+
imported.url.must_equal "http://example.com/css_import/stylesheets/ie.css"
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should not fail on invalid import path" do
|
72
|
+
css = style("/css_import/stylesheets/screen.css")
|
73
|
+
css.stylesheets[6].must_be_nil
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
# Selector parsing
|
78
|
+
|
79
|
+
it "should parse selectors" do
|
80
|
+
css = style("/css_color/stylesheets/properties.css")
|
81
|
+
selectors = css.selectors
|
82
|
+
|
83
|
+
selectors.size.must_equal 4
|
84
|
+
|
85
|
+
selectors["p"].size.must_equal 2
|
86
|
+
selectors["div"].size.must_equal 1
|
87
|
+
selectors["h1"].size.must_equal 2
|
88
|
+
|
89
|
+
# imported
|
90
|
+
selectors["dl"].size.must_equal 1
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should parse properties" do
|
94
|
+
css = style("/css_color/stylesheets/properties.css")
|
95
|
+
props = css.properties
|
96
|
+
|
97
|
+
props.size.must_equal 9
|
98
|
+
|
99
|
+
props.must_include ["background", "#000"]
|
100
|
+
props.must_include ["color", "#fff"]
|
101
|
+
props.must_include ["margin", "0"]
|
102
|
+
props.must_include ["background-color", "#ccc"]
|
103
|
+
props.must_include ["font-size", "100%"]
|
104
|
+
props.must_include ["border-color", "rgb(1,2,3)"]
|
105
|
+
|
106
|
+
# imported
|
107
|
+
props.must_include ["border", "1px solid red"]
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
# Color Parsing
|
112
|
+
|
113
|
+
it "should parse hex colors" do
|
114
|
+
css = style("/css_color/stylesheets/color_styles.css")
|
115
|
+
|
116
|
+
css.colors["386ec0"].wont_be_nil # 386ec0
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should parse hex short colors" do
|
120
|
+
css = style("/css_color/stylesheets/color_styles.css")
|
121
|
+
|
122
|
+
css.colors["cc00cc"].wont_be_nil # c0c
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should parse textual colors" do
|
126
|
+
css = style("/css_color/stylesheets/color_styles.css")
|
127
|
+
|
128
|
+
css.colors["008080"].wont_be_nil # teal
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should parse rgb colors" do
|
132
|
+
css = style("/css_color/stylesheets/color_styles.css")
|
133
|
+
|
134
|
+
css.colors["718ad7"].wont_be_nil # rgb(113,138,215)
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should parse rgb colors with space" do
|
138
|
+
css = style("/css_color/stylesheets/color_styles.css")
|
139
|
+
|
140
|
+
css.colors["3a5dc4"].wont_be_nil # rgb(58, 93, 196)
|
141
|
+
end
|
142
|
+
|
143
|
+
it "should parse rgba colors" do
|
144
|
+
css = style("/css_color/stylesheets/color_styles.css")
|
145
|
+
|
146
|
+
css.colors["29469e"].wont_be_nil # rgba(41,70,158,0.5);
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should parse rgba colors with space" do
|
150
|
+
css = style("/css_color/stylesheets/color_styles.css")
|
151
|
+
|
152
|
+
css.colors["3f6aeb"].wont_be_nil # rgba(63, 106, 235, 0.5);
|
153
|
+
end
|
154
|
+
|
155
|
+
|
156
|
+
# Color weighting
|
157
|
+
|
158
|
+
it "should order colors by frequency" do
|
159
|
+
css = style("/css_color/stylesheets/frequency.css")
|
160
|
+
|
161
|
+
colors = {"386ec0" => 4, "3a5dc4" => 3,
|
162
|
+
"718ad7" => 2, "ff0000" => 1}
|
163
|
+
css.colors.must_equal colors
|
164
|
+
end
|
165
|
+
|
166
|
+
# BG colors
|
167
|
+
it "should order background colors by frequency" do
|
168
|
+
css = style("/css_color/stylesheets/frequency.css")
|
169
|
+
|
170
|
+
colors = {"386ec0" => 2, "3a5dc4" => 1}
|
171
|
+
css.bg_colors.must_equal colors
|
172
|
+
end
|
173
|
+
|
174
|
+
# Text colors
|
175
|
+
it "should order text colors by frequency" do
|
176
|
+
css = style("/css_color/stylesheets/frequency.css")
|
177
|
+
|
178
|
+
colors = {"386ec0" => 2, "718ad7" => 1}
|
179
|
+
css.text_colors.must_equal colors
|
180
|
+
end
|
181
|
+
|
182
|
+
# Border colors
|
183
|
+
it "should order border colors by frequency" do
|
184
|
+
css = style("/css_color/stylesheets/frequency.css")
|
185
|
+
|
186
|
+
colors = {"3a5dc4" => 2, "ff0000" => 1, "718ad7" => 1}
|
187
|
+
css.border_colors.must_equal colors
|
188
|
+
end
|
189
|
+
|
190
|
+
|
191
|
+
# Images Parsing
|
192
|
+
|
193
|
+
it "should parse images with double quotes" do
|
194
|
+
css = style("/css_images/stylesheets/quotes.css")
|
195
|
+
|
196
|
+
css.images[0].name.must_equal "apple.png"
|
197
|
+
end
|
198
|
+
|
199
|
+
it "should parse images with single quotes" do
|
200
|
+
css = style("/css_images/stylesheets/quotes.css")
|
201
|
+
|
202
|
+
css.images[1].name.must_equal "kiwi.jpg"
|
203
|
+
end
|
204
|
+
|
205
|
+
it "should parse images with no quotes" do
|
206
|
+
css = style("/css_images/stylesheets/quotes.css")
|
207
|
+
|
208
|
+
css.images[2].name.must_equal "cantaloupe.png"
|
209
|
+
end
|
210
|
+
|
211
|
+
|
212
|
+
# Image paths
|
213
|
+
|
214
|
+
it "should build image from absolute path" do
|
215
|
+
css = style("/css_images/stylesheets/paths.css")
|
216
|
+
urls = css.images.map {|image| image.url }
|
217
|
+
|
218
|
+
urls.size.must_equal 4
|
219
|
+
urls.must_include "http://example.com/css_images/images/apple.png"
|
220
|
+
end
|
221
|
+
|
222
|
+
it "should build image from relative path" do
|
223
|
+
css = style("/css_images/stylesheets/paths.css")
|
224
|
+
urls = css.images.map {|image| image.url }
|
225
|
+
|
226
|
+
urls.size.must_equal 4
|
227
|
+
urls.must_include "http://example.com/css_images/images/kiwi.jpg"
|
228
|
+
end
|
229
|
+
|
230
|
+
it "should build image from relative root path" do
|
231
|
+
css = style("/css_images/stylesheets/paths.css")
|
232
|
+
urls = css.images.map {|image| image.url }
|
233
|
+
|
234
|
+
urls.size.must_equal 4
|
235
|
+
urls.must_include "http://example.com/css_images/images/cantaloupe.png"
|
236
|
+
end
|
237
|
+
|
238
|
+
it "should build image from imported path" do
|
239
|
+
css = style("/css_images/stylesheets/paths.css")
|
240
|
+
urls = css.images.map {|image| image.url }
|
241
|
+
|
242
|
+
urls.size.must_equal 4
|
243
|
+
urls.must_include "http://example.com/css_images/images/pineapple.png"
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
private
|
248
|
+
|
249
|
+
def style(path)
|
250
|
+
ColorParser::Stylesheet.new(text: fixture(path),
|
251
|
+
url: "http://example.com#{path}")
|
252
|
+
end
|
253
|
+
|
254
|
+
def fixture(path)
|
255
|
+
fixture = "#{File.dirname(__FILE__)}/../test/fixtures#{path}"
|
256
|
+
File.read(fixture) if File.exist?(fixture)
|
257
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module ColorParser
|
2
|
+
class TestRequest
|
3
|
+
def initialize(params={})
|
4
|
+
end
|
5
|
+
|
6
|
+
# Read in fixture file instead of url
|
7
|
+
def get(url)
|
8
|
+
begin
|
9
|
+
uri = URI.parse(url.strip)
|
10
|
+
rescue URI::InvalidURIError
|
11
|
+
uri = URI.parse(URI.escape(url.strip))
|
12
|
+
end
|
13
|
+
|
14
|
+
# simple hack to read in fixtures instead of url for tests
|
15
|
+
fixture = "#{File.dirname(__FILE__)}/../test/fixtures#{uri.path}"
|
16
|
+
File.read(fixture) if File.exist?(fixture)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,184 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: color_parser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Derek DeVries
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: nokogiri
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.5'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.5'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Color Parser finds the colors on a given webpage
|
47
|
+
email:
|
48
|
+
- derek@sportspyder.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- LICENSE.txt
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- color_parser.gemspec
|
59
|
+
- lib/color_parser.rb
|
60
|
+
- lib/color_parser/image.rb
|
61
|
+
- lib/color_parser/page.rb
|
62
|
+
- lib/color_parser/stylesheet.rb
|
63
|
+
- lib/color_parser/version.rb
|
64
|
+
- test/color_parser_test.rb
|
65
|
+
- test/fixtures/css/absolute.html
|
66
|
+
- test/fixtures/css/inline.html
|
67
|
+
- test/fixtures/css/inline_import.html
|
68
|
+
- test/fixtures/css/invalid.html
|
69
|
+
- test/fixtures/css/relative.html
|
70
|
+
- test/fixtures/css/relative_root.html
|
71
|
+
- test/fixtures/css/stylesheets/colors.css
|
72
|
+
- test/fixtures/css/stylesheets/fonts.css
|
73
|
+
- test/fixtures/css/stylesheets/print.css
|
74
|
+
- test/fixtures/css/stylesheets/screen.css
|
75
|
+
- test/fixtures/css_color/frequency.html
|
76
|
+
- test/fixtures/css_color/stylesheets/color_styles.css
|
77
|
+
- test/fixtures/css_color/stylesheets/css_elements.css
|
78
|
+
- test/fixtures/css_color/stylesheets/frequency.css
|
79
|
+
- test/fixtures/css_color/stylesheets/imported_selectors.css
|
80
|
+
- test/fixtures/css_color/stylesheets/properties.css
|
81
|
+
- test/fixtures/css_images/images/apple.png
|
82
|
+
- test/fixtures/css_images/images/cantaloupe.png
|
83
|
+
- test/fixtures/css_images/images/kiwi.jpg
|
84
|
+
- test/fixtures/css_images/images/mango.png
|
85
|
+
- test/fixtures/css_images/images/pineapple.png
|
86
|
+
- test/fixtures/css_images/paths.html
|
87
|
+
- test/fixtures/css_images/stylesheets/import_paths.css
|
88
|
+
- test/fixtures/css_images/stylesheets/paths.css
|
89
|
+
- test/fixtures/css_images/stylesheets/quotes.css
|
90
|
+
- test/fixtures/css_import/index.html
|
91
|
+
- test/fixtures/css_import/stylesheets/borders.css
|
92
|
+
- test/fixtures/css_import/stylesheets/colors.css
|
93
|
+
- test/fixtures/css_import/stylesheets/fonts.css
|
94
|
+
- test/fixtures/css_import/stylesheets/ie.css
|
95
|
+
- test/fixtures/css_import/stylesheets/images.css
|
96
|
+
- test/fixtures/css_import/stylesheets/master.css
|
97
|
+
- test/fixtures/css_import/stylesheets/print.css
|
98
|
+
- test/fixtures/css_import/stylesheets/screen.css
|
99
|
+
- test/fixtures/inline_images/absolute.html
|
100
|
+
- test/fixtures/inline_images/images/apple.png
|
101
|
+
- test/fixtures/inline_images/images/kiwi.jpg
|
102
|
+
- test/fixtures/inline_images/relative.html
|
103
|
+
- test/fixtures/inline_images/relative_root.html
|
104
|
+
- test/image_test.rb
|
105
|
+
- test/page_test.rb
|
106
|
+
- test/stylesheet_test.rb
|
107
|
+
- test/test_helper.rb
|
108
|
+
- test/test_request.rb
|
109
|
+
- test/version_test.rb
|
110
|
+
homepage: https://github.com/devrieda/color_parser
|
111
|
+
licenses:
|
112
|
+
- MIT
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options: []
|
115
|
+
require_paths:
|
116
|
+
- lib
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - ! '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 1.9.3
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
none: false
|
125
|
+
requirements:
|
126
|
+
- - ! '>='
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
segments:
|
130
|
+
- 0
|
131
|
+
hash: -3886628688892773367
|
132
|
+
requirements: []
|
133
|
+
rubyforge_project:
|
134
|
+
rubygems_version: 1.8.24
|
135
|
+
signing_key:
|
136
|
+
specification_version: 3
|
137
|
+
summary: Color Parser finds the colors on a given webpage
|
138
|
+
test_files:
|
139
|
+
- test/color_parser_test.rb
|
140
|
+
- test/fixtures/css/absolute.html
|
141
|
+
- test/fixtures/css/inline.html
|
142
|
+
- test/fixtures/css/inline_import.html
|
143
|
+
- test/fixtures/css/invalid.html
|
144
|
+
- test/fixtures/css/relative.html
|
145
|
+
- test/fixtures/css/relative_root.html
|
146
|
+
- test/fixtures/css/stylesheets/colors.css
|
147
|
+
- test/fixtures/css/stylesheets/fonts.css
|
148
|
+
- test/fixtures/css/stylesheets/print.css
|
149
|
+
- test/fixtures/css/stylesheets/screen.css
|
150
|
+
- test/fixtures/css_color/frequency.html
|
151
|
+
- test/fixtures/css_color/stylesheets/color_styles.css
|
152
|
+
- test/fixtures/css_color/stylesheets/css_elements.css
|
153
|
+
- test/fixtures/css_color/stylesheets/frequency.css
|
154
|
+
- test/fixtures/css_color/stylesheets/imported_selectors.css
|
155
|
+
- test/fixtures/css_color/stylesheets/properties.css
|
156
|
+
- test/fixtures/css_images/images/apple.png
|
157
|
+
- test/fixtures/css_images/images/cantaloupe.png
|
158
|
+
- test/fixtures/css_images/images/kiwi.jpg
|
159
|
+
- test/fixtures/css_images/images/mango.png
|
160
|
+
- test/fixtures/css_images/images/pineapple.png
|
161
|
+
- test/fixtures/css_images/paths.html
|
162
|
+
- test/fixtures/css_images/stylesheets/import_paths.css
|
163
|
+
- test/fixtures/css_images/stylesheets/paths.css
|
164
|
+
- test/fixtures/css_images/stylesheets/quotes.css
|
165
|
+
- test/fixtures/css_import/index.html
|
166
|
+
- test/fixtures/css_import/stylesheets/borders.css
|
167
|
+
- test/fixtures/css_import/stylesheets/colors.css
|
168
|
+
- test/fixtures/css_import/stylesheets/fonts.css
|
169
|
+
- test/fixtures/css_import/stylesheets/ie.css
|
170
|
+
- test/fixtures/css_import/stylesheets/images.css
|
171
|
+
- test/fixtures/css_import/stylesheets/master.css
|
172
|
+
- test/fixtures/css_import/stylesheets/print.css
|
173
|
+
- test/fixtures/css_import/stylesheets/screen.css
|
174
|
+
- test/fixtures/inline_images/absolute.html
|
175
|
+
- test/fixtures/inline_images/images/apple.png
|
176
|
+
- test/fixtures/inline_images/images/kiwi.jpg
|
177
|
+
- test/fixtures/inline_images/relative.html
|
178
|
+
- test/fixtures/inline_images/relative_root.html
|
179
|
+
- test/image_test.rb
|
180
|
+
- test/page_test.rb
|
181
|
+
- test/stylesheet_test.rb
|
182
|
+
- test/test_helper.rb
|
183
|
+
- test/test_request.rb
|
184
|
+
- test/version_test.rb
|