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
@@ -0,0 +1,34 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
|
4
|
+
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
7
|
+
<title>Color Parser</title>
|
8
|
+
<style>
|
9
|
+
body {
|
10
|
+
color: #444;
|
11
|
+
background-color: #535353;
|
12
|
+
}
|
13
|
+
a:link {
|
14
|
+
color: #357ad1;
|
15
|
+
}
|
16
|
+
a:visited {
|
17
|
+
color: #77abf0;
|
18
|
+
}
|
19
|
+
a:hover {
|
20
|
+
color: #333;
|
21
|
+
}
|
22
|
+
</style>
|
23
|
+
</head>
|
24
|
+
<body>
|
25
|
+
<style>
|
26
|
+
div {
|
27
|
+
background-color: #aaa;
|
28
|
+
border: 1px solid #ccc;
|
29
|
+
}
|
30
|
+
</style>
|
31
|
+
|
32
|
+
<div></div>
|
33
|
+
</body>
|
34
|
+
</html>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
|
4
|
+
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
7
|
+
<title>Color Parser</title>
|
8
|
+
<style>
|
9
|
+
@import "stylesheets/print.css";@import url "stylesheets/fonts.css"
|
10
|
+
@import url("stylesheets/colors.css")
|
11
|
+
</style>
|
12
|
+
</head>
|
13
|
+
<body>
|
14
|
+
<div></div>
|
15
|
+
</body>
|
16
|
+
</html>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
|
4
|
+
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
7
|
+
<title>Color Parser</title>
|
8
|
+
|
9
|
+
<link rel="stylesheet" href="stylesheets/asdf.css" media="screen" type="text/css" />
|
10
|
+
<link rel="stylesheet" href="stylesheets/screen.css" media="screen" type="text/css" />
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<div></div>
|
14
|
+
</body>
|
15
|
+
</html>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
|
4
|
+
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
7
|
+
<title>Color Parser</title>
|
8
|
+
|
9
|
+
<link rel="stylesheet" href="stylesheets/screen.css" media="screen" type="text/css" />
|
10
|
+
<link rel="stylesheet" href="stylesheets/print.css" media="print" type="text/css" />
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<div></div>
|
14
|
+
</body>
|
15
|
+
</html>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
|
4
|
+
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
7
|
+
<title>Color Parser</title>
|
8
|
+
|
9
|
+
<link rel="stylesheet" href="/css/stylesheets/screen.css" media="screen" type="text/css" />
|
10
|
+
<link rel="stylesheet" href="/css/stylesheets/print.css" media="print" type="text/css" />
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<div></div>
|
14
|
+
</body>
|
15
|
+
</html>
|
File without changes
|
File without changes
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
|
4
|
+
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
7
|
+
<title>Color Parser</title>
|
8
|
+
|
9
|
+
<link rel="stylesheet" href="stylesheets/frequency.css" media="screen" type="text/css" />
|
10
|
+
<style>
|
11
|
+
body {
|
12
|
+
background-color: #535353;
|
13
|
+
}
|
14
|
+
a:link {
|
15
|
+
color: #357ad1;
|
16
|
+
}
|
17
|
+
</style>
|
18
|
+
</head>
|
19
|
+
<body>
|
20
|
+
<div></div>
|
21
|
+
</body>
|
22
|
+
</html>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
/* color names - 008080 */
|
2
|
+
div {
|
3
|
+
background-color: teal;
|
4
|
+
}
|
5
|
+
|
6
|
+
/* hex */
|
7
|
+
div {
|
8
|
+
color: #386ec0;
|
9
|
+
}
|
10
|
+
|
11
|
+
/* hex short */
|
12
|
+
div {
|
13
|
+
color: #c0c;
|
14
|
+
}
|
15
|
+
|
16
|
+
/* rgb -- 718ad7 */
|
17
|
+
div {
|
18
|
+
color: rgb(113,138,215);
|
19
|
+
}
|
20
|
+
|
21
|
+
/* rgb spaces -- 3a5dc4 */
|
22
|
+
div {
|
23
|
+
color: rgb(58, 93, 196);
|
24
|
+
}
|
25
|
+
|
26
|
+
/* rgba -- 29469e */
|
27
|
+
div {
|
28
|
+
color: rgba(41,70,158,0.5);
|
29
|
+
}
|
30
|
+
|
31
|
+
/* rgba spaces -- 3f6aeb */
|
32
|
+
div {
|
33
|
+
color: rgba(63, 106, 235, 0.5);
|
34
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
/* background-color */
|
2
|
+
div {
|
3
|
+
background-color: #abcdef;
|
4
|
+
}
|
5
|
+
|
6
|
+
/* background */
|
7
|
+
div {
|
8
|
+
background: #abcdef url("/images/something.png");
|
9
|
+
}
|
10
|
+
|
11
|
+
/* border-color */
|
12
|
+
div {
|
13
|
+
border-color: #abcdef;
|
14
|
+
}
|
15
|
+
|
16
|
+
/* border */
|
17
|
+
div {
|
18
|
+
border: 1px solid #abcdef;
|
19
|
+
}
|
20
|
+
|
21
|
+
/* text color */
|
22
|
+
div {
|
23
|
+
color: #abcdef;
|
24
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
/* backgrounds */
|
2
|
+
div {
|
3
|
+
background-color: #3a5dc4;
|
4
|
+
}
|
5
|
+
div {
|
6
|
+
background: #386ec0 url("/images/something.png");
|
7
|
+
}
|
8
|
+
div {
|
9
|
+
background: #386ec0 url("/images/something.png");
|
10
|
+
}
|
11
|
+
|
12
|
+
|
13
|
+
/* text */
|
14
|
+
div {
|
15
|
+
color: #718ad7;
|
16
|
+
}
|
17
|
+
h1 {
|
18
|
+
color: #386ec0;
|
19
|
+
}
|
20
|
+
h2 {
|
21
|
+
color: #386ec0;
|
22
|
+
}
|
23
|
+
|
24
|
+
/* borders */
|
25
|
+
div {
|
26
|
+
border-color: #718ad7;
|
27
|
+
}
|
28
|
+
div {
|
29
|
+
border: 1px solid #3a5dc4;
|
30
|
+
}
|
31
|
+
div {
|
32
|
+
border: 1px solid #3a5dc4;
|
33
|
+
}
|
34
|
+
|
35
|
+
@import url("imported_selectors.css");
|
@@ -0,0 +1,18 @@
|
|
1
|
+
div {
|
2
|
+
background: #000;
|
3
|
+
color: #fff
|
4
|
+
}
|
5
|
+
|
6
|
+
/* combo with semi */
|
7
|
+
p {
|
8
|
+
margin:0;
|
9
|
+
background-color:#ccc;
|
10
|
+
}
|
11
|
+
|
12
|
+
/* single line */
|
13
|
+
h1 {font-size:100%;border-color:rgb(1,2,3);}
|
14
|
+
|
15
|
+
/* more single line */
|
16
|
+
p {padding:0;}h1 {padding:0;}
|
17
|
+
|
18
|
+
@import url("imported_selectors.css");
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
|
4
|
+
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
7
|
+
<title>Color Parser</title>
|
8
|
+
|
9
|
+
<link rel="stylesheet" href="stylesheets/paths.css" media="screen" type="text/css" />
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
<img src="images/mango.png" />
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
/* absolute */
|
2
|
+
body {
|
3
|
+
background: #fff url("http://example.com/css_images/images/apple.png") 0 0 no-repeat;
|
4
|
+
}
|
5
|
+
|
6
|
+
/* relative */
|
7
|
+
div {
|
8
|
+
background: #fff url("/css_images/images/kiwi.jpg") 0 0 no-repeat;
|
9
|
+
}
|
10
|
+
|
11
|
+
/* relative root */
|
12
|
+
ul {
|
13
|
+
background: #fff url("../images/cantaloupe.png") 0 0 no-repeat;
|
14
|
+
}
|
15
|
+
|
16
|
+
/* import */
|
17
|
+
@import url("import_paths.css");
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/* quotes */
|
2
|
+
dl {
|
3
|
+
background: #fff url("/css_images/images/apple.png") 0 0 no-repeat;
|
4
|
+
}
|
5
|
+
|
6
|
+
/* single quotes */
|
7
|
+
h1 {
|
8
|
+
background: #fff url('/css_images/images/kiwi.jpg') 0 0 no-repeat;
|
9
|
+
}
|
10
|
+
|
11
|
+
/* no quotes */
|
12
|
+
h2 {
|
13
|
+
background: #fff url(/css_images/images/cantaloupe.png) 0 0 no-repeat;
|
14
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
|
4
|
+
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
7
|
+
<title>Color Parser</title>
|
8
|
+
|
9
|
+
<link rel="stylesheet" href="stylesheets/screen.css" media="screen" type="text/css" />
|
10
|
+
<link rel="stylesheet" href="stylesheets/print.css" media="screen" type="text/css" />
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<div></div>
|
14
|
+
</body>
|
15
|
+
</html>
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,12 @@
|
|
1
|
+
body {
|
2
|
+
color: #444;
|
3
|
+
background-color: #535353;
|
4
|
+
}
|
5
|
+
|
6
|
+
@import url("master.css");
|
7
|
+
@import url('/css_import/stylesheets/fonts.css');
|
8
|
+
@import url(http://example.com/css_import/stylesheets/ie.css);
|
9
|
+
@import url "images.css";
|
10
|
+
@import "borders.css";
|
11
|
+
@import colors.css;
|
12
|
+
@import url("invalid.css");
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
|
4
|
+
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
7
|
+
<title>Color Parser</title>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<img src="http://example.com/inline_images/images/apple.png" />
|
11
|
+
<p>Something</p>
|
12
|
+
<img src='http://example.com/inline_images/images/kiwi.jpg' />
|
13
|
+
</body>
|
14
|
+
</html>
|
Binary file
|
Binary file
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
|
4
|
+
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
7
|
+
<title>Color Parser</title>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<img src="images/apple.png" />
|
11
|
+
<p>Something</p>
|
12
|
+
<img src='images/kiwi.jpg' />
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
|
4
|
+
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
7
|
+
<title>Color Parser</title>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<img src="/inline_images/images/apple.png" />
|
11
|
+
<p>Something</p>
|
12
|
+
<img src='/inline_images/images/kiwi.jpg' />
|
13
|
+
</body>
|
14
|
+
</html>
|
data/test/image_test.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative "test_helper"
|
2
|
+
|
3
|
+
describe Image do
|
4
|
+
def setup
|
5
|
+
ColorParser.request = ColorParser::TestRequest.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should assign url" do
|
9
|
+
image = ColorParser::Image.new("http://example.com/foo/bar.png")
|
10
|
+
|
11
|
+
image.url.must_equal "http://example.com/foo/bar.png"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should parse host path and query from url" do
|
15
|
+
image = ColorParser::Image.new("http://example.com/foo/bar.png?baz=bar")
|
16
|
+
|
17
|
+
image.host.must_equal "example.com"
|
18
|
+
image.path.must_equal "/foo/bar.png"
|
19
|
+
image.query.must_equal "baz=bar"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should parse name" do
|
23
|
+
image = ColorParser::Image.new("http://example.com/foo/bar.png?baz=bar")
|
24
|
+
|
25
|
+
"bar.png".must_equal image.name
|
26
|
+
end
|
27
|
+
end
|