stylesheet 0.1.1 → 0.1.7
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/README.md +1 -1
- data/lib/stylesheet.rb +1 -0
- data/lib/stylesheet/css_null_rule.rb +16 -0
- data/lib/stylesheet/css_rule.rb +2 -1
- data/lib/stylesheet/css_rule_list.rb +2 -2
- data/lib/stylesheet/css_style_declaration.rb +4 -1
- data/lib/stylesheet/css_style_sheet.rb +11 -3
- data/lib/stylesheet/document.rb +8 -7
- data/lib/stylesheet/location.rb +7 -8
- data/lib/stylesheet/version.rb +1 -1
- data/spec/css_charset_rule_spec.rb +4 -4
- data/spec/css_font_face_rule_spec.rb +4 -4
- data/spec/css_import_rule_spec.rb +4 -4
- data/spec/css_media_rule_spec.rb +4 -4
- data/spec/css_rule_list_spec.rb +30 -0
- data/spec/css_rule_spec.rb +15 -0
- data/spec/css_style_declaration_spec.rb +29 -0
- data/spec/css_style_rule_spec.rb +3 -3
- data/spec/css_style_sheet_spec.rb +37 -4
- data/spec/location_spec.rb +26 -25
- data/stylesheet.gemspec +1 -0
- metadata +40 -43
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bc5eb1cd967796c26fa522311f64ba8663d917b97a2107fe54ff46b4bc4b0cfc
|
4
|
+
data.tar.gz: 59910caf94fa181675c0ea35bca624d9895334a40706a3690ce359983de30f2d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 634effa1d81245401ec054e7a30748111fa65480900773a5a12e9aff0cc13390cbb1d93392de11a9eecd946c51c5093360c40b717465182490742a704cd96774
|
7
|
+
data.tar.gz: c48fdfec84a35d17f07e5fe7877e0eb7b46dcba1fa7471b93ce7c1df240345486aaca9cc4d1dd6f0bb5a62cc37406629e6ac80127fa23d6da13f280d10a2905c
|
data/README.md
CHANGED
data/lib/stylesheet.rb
CHANGED
data/lib/stylesheet/css_rule.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module Stylesheet
|
2
2
|
class CssRule
|
3
|
+
NULL_RULE = 0
|
3
4
|
STYLE_RULE = 1
|
4
5
|
CHARSET_RULE = 2
|
5
6
|
IMPORT_RULE = 3
|
@@ -50,7 +51,7 @@ module Stylesheet
|
|
50
51
|
|
51
52
|
private
|
52
53
|
|
53
|
-
def parse_css_text
|
54
|
+
def parse_css_text
|
54
55
|
raise NotImplementedError
|
55
56
|
end
|
56
57
|
end
|
@@ -16,13 +16,13 @@ module Stylesheet
|
|
16
16
|
|
17
17
|
def parse(rules, parent)
|
18
18
|
# clean out comments
|
19
|
-
rules = rules.gsub(/\/\*[\s\S]*?\*\//, '')
|
19
|
+
rules = rules.gsub(/\/\*[\s\S]*?\*\//, '').gsub("/*", "").gsub("*/", "")
|
20
20
|
|
21
21
|
# clean extraneous whitespace
|
22
22
|
rules = rules.to_s.gsub(/\s+/m, " ").gsub(/([\};])\s/, '\1')
|
23
23
|
|
24
24
|
directive_re = "@.+?;"
|
25
|
-
rules_re = ".+?\{
|
25
|
+
rules_re = ".+?\{.*?\}"
|
26
26
|
split_rules = rules.scan(/(#{directive_re}|#{rules_re})/im).map {|r| r[0] }
|
27
27
|
|
28
28
|
split_rules.map do |css_text|
|
@@ -15,7 +15,10 @@ module Stylesheet
|
|
15
15
|
def css_text=(css_text)
|
16
16
|
@declarations_list = []
|
17
17
|
|
18
|
-
|
18
|
+
re = /((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)\s*/
|
19
|
+
css_text.to_s.strip.chomp(";").scan(re).flatten.each do |declaration|
|
20
|
+
next unless declaration.include?(":")
|
21
|
+
|
19
22
|
property, value = declaration.split(":", 2)
|
20
23
|
@declarations_list << declaration.strip
|
21
24
|
@declarations[property.strip] = parse_value(value.strip)
|
@@ -49,7 +49,7 @@ module Stylesheet
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def content=(content)
|
52
|
-
@content = content if content
|
52
|
+
@content = content if content
|
53
53
|
end
|
54
54
|
|
55
55
|
def content
|
@@ -62,6 +62,14 @@ module Stylesheet
|
|
62
62
|
|
63
63
|
alias_method :rules, :css_rules
|
64
64
|
|
65
|
+
def import_rules
|
66
|
+
css_rules.select {|r| r.type == CssRule::IMPORT_RULE }
|
67
|
+
end
|
68
|
+
|
69
|
+
def style_rules
|
70
|
+
css_rules.select {|r| r.type == CssRule::STYLE_RULE }
|
71
|
+
end
|
72
|
+
|
65
73
|
def parent_style_sheet
|
66
74
|
@parent if @owner_rule
|
67
75
|
end
|
@@ -98,7 +106,7 @@ module Stylesheet
|
|
98
106
|
end
|
99
107
|
|
100
108
|
def request_content
|
101
|
-
raise InvalidLocationError unless location.valid?
|
109
|
+
raise InvalidLocationError unless location && location.valid?
|
102
110
|
request.get(location.href)
|
103
111
|
end
|
104
112
|
|
@@ -106,4 +114,4 @@ module Stylesheet
|
|
106
114
|
@request ||= Stylesheet.request
|
107
115
|
end
|
108
116
|
end
|
109
|
-
end
|
117
|
+
end
|
data/lib/stylesheet/document.rb
CHANGED
@@ -27,13 +27,14 @@ module Stylesheet
|
|
27
27
|
|
28
28
|
private
|
29
29
|
|
30
|
-
def styles
|
30
|
+
def styles
|
31
31
|
(inline_styles + external_styles).map do |style|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
html = style.inner_html
|
33
|
+
{ parent: self,
|
34
|
+
content: html != "" ? html : nil,
|
35
|
+
href: style["href"],
|
36
|
+
media: style["media"],
|
37
|
+
title: style["title"] }
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
@@ -60,4 +61,4 @@ module Stylesheet
|
|
60
61
|
@request ||= Stylesheet.request
|
61
62
|
end
|
62
63
|
end
|
63
|
-
end
|
64
|
+
end
|
data/lib/stylesheet/location.rb
CHANGED
@@ -47,7 +47,7 @@ module Stylesheet
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def valid?
|
50
|
-
|
50
|
+
!!(valid_protocol? && valid_host?)
|
51
51
|
end
|
52
52
|
|
53
53
|
def expand_paths_from_parent
|
@@ -74,19 +74,19 @@ module Stylesheet
|
|
74
74
|
def valid_protocol?
|
75
75
|
protocol && protocol != ":"
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
def valid_host?
|
79
79
|
host && host != ""
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
def valid_port?
|
83
83
|
port && port != ""
|
84
84
|
end
|
85
|
-
|
85
|
+
|
86
86
|
def standard_port?
|
87
87
|
port_80? || port_443?
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
def port_80?
|
91
91
|
uri && uri.port == 80 && uri.scheme == "http"
|
92
92
|
end
|
@@ -100,14 +100,13 @@ module Stylesheet
|
|
100
100
|
URI.parse(url.strip)
|
101
101
|
rescue URI::InvalidURIError
|
102
102
|
URI.parse(URI.escape(url.strip))
|
103
|
-
end
|
103
|
+
end
|
104
104
|
|
105
105
|
# re-raise external library errors in our namespace
|
106
106
|
rescue URI::InvalidURIError => error
|
107
107
|
raise Stylesheet::InvalidLocationError.new(
|
108
108
|
"#{error.class}: #{error.message}")
|
109
109
|
end
|
110
|
-
|
110
|
+
|
111
111
|
end
|
112
112
|
end
|
113
|
-
|
data/lib/stylesheet/version.rb
CHANGED
@@ -23,17 +23,17 @@ describe CssCharsetRule do
|
|
23
23
|
describe ".matches_rule?" do
|
24
24
|
it "should match text starting with @charset" do
|
25
25
|
matches = CssCharsetRule.matches_rule?(css_text)
|
26
|
-
expect(matches).to
|
26
|
+
expect(matches).to eq true
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should not match text without at-rule" do
|
30
30
|
matches = CssCharsetRule.matches_rule?("a:link { color: #357ad1; }")
|
31
|
-
expect(matches).to
|
31
|
+
expect(matches).to eq false
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should not match text without charset" do
|
35
35
|
matches = CssCharsetRule.matches_rule?("@import url(\"import1.css\");")
|
36
|
-
expect(matches).to
|
36
|
+
expect(matches).to eq false
|
37
37
|
end
|
38
38
|
end
|
39
|
-
end
|
39
|
+
end
|
@@ -31,17 +31,17 @@ describe CssFontFaceRule do
|
|
31
31
|
describe ".matches_rule?" do
|
32
32
|
it "should match text starting with @font-face" do
|
33
33
|
matches = CssFontFaceRule.matches_rule?(css_text)
|
34
|
-
expect(matches).to
|
34
|
+
expect(matches).to eq true
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should not match text without at-rule" do
|
38
38
|
matches = CssFontFaceRule.matches_rule?("a:link { color: #357ad1; }")
|
39
|
-
expect(matches).to
|
39
|
+
expect(matches).to eq false
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should not match text without font-face" do
|
43
43
|
matches = CssFontFaceRule.matches_rule?("@import url(\"import1.css\");")
|
44
|
-
expect(matches).to
|
44
|
+
expect(matches).to eq false
|
45
45
|
end
|
46
46
|
end
|
47
|
-
end
|
47
|
+
end
|
@@ -162,17 +162,17 @@ describe CssImportRule do
|
|
162
162
|
describe ".matches_rule?" do
|
163
163
|
it "should match text starting with @import" do
|
164
164
|
matches = CssImportRule.matches_rule?(css_text)
|
165
|
-
expect(matches).to
|
165
|
+
expect(matches).to eq true
|
166
166
|
end
|
167
167
|
|
168
168
|
it "should not match text without at-rule" do
|
169
169
|
matches = CssImportRule.matches_rule?("a:link { color: #357ad1; }")
|
170
|
-
expect(matches).to
|
170
|
+
expect(matches).to eq false
|
171
171
|
end
|
172
172
|
|
173
173
|
it "should not match text without import" do
|
174
174
|
matches = CssImportRule.matches_rule?("@charset \"UTF-8\";")
|
175
|
-
expect(matches).to
|
175
|
+
expect(matches).to eq false
|
176
176
|
end
|
177
177
|
end
|
178
|
-
end
|
178
|
+
end
|
data/spec/css_media_rule_spec.rb
CHANGED
@@ -41,17 +41,17 @@ describe CssMediaRule do
|
|
41
41
|
describe ".matches_rule?" do
|
42
42
|
it "should match text starting with @media" do
|
43
43
|
matches = CssMediaRule.matches_rule?(css_text)
|
44
|
-
expect(matches).to
|
44
|
+
expect(matches).to eq true
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should not match text without at-rule" do
|
48
48
|
matches = CssMediaRule.matches_rule?("a:link { color: #357ad1; }")
|
49
|
-
expect(matches).to
|
49
|
+
expect(matches).to eq false
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should not match text without media" do
|
53
53
|
matches = CssMediaRule.matches_rule?("@charset \"UTF-8\";")
|
54
|
-
expect(matches).to
|
54
|
+
expect(matches).to eq false
|
55
55
|
end
|
56
56
|
end
|
57
|
-
end
|
57
|
+
end
|
data/spec/css_rule_list_spec.rb
CHANGED
@@ -35,6 +35,21 @@ describe CssRuleList do
|
|
35
35
|
font-size: 90%;
|
36
36
|
}"
|
37
37
|
end
|
38
|
+
|
39
|
+
let(:style_w_mismatched_comments) do
|
40
|
+
"body {
|
41
|
+
color: #444;
|
42
|
+
background-color: #535353;
|
43
|
+
}
|
44
|
+
|
45
|
+
*/
|
46
|
+
p {
|
47
|
+
font-size: 90%;
|
48
|
+
}" end
|
49
|
+
|
50
|
+
let(:style_w_empty_rules) do
|
51
|
+
"#cboxOverlay{color:#ccc}#colorbox{}#cboxTopLeft{width:21px;}"
|
52
|
+
end
|
38
53
|
|
39
54
|
describe ".new" do
|
40
55
|
it "parses charset rules" do
|
@@ -68,6 +83,21 @@ describe CssRuleList do
|
|
68
83
|
expect(rules[0].css_text).to eq "body { color: #444;background-color: #535353;}"
|
69
84
|
expect(rules[1].css_text).to eq "p { font-size: 90%;}"
|
70
85
|
end
|
86
|
+
|
87
|
+
it "removes mismatched comments" do
|
88
|
+
rules = CssRuleList.new(style_w_mismatched_comments)
|
89
|
+
expect(rules.length).to eq 2
|
90
|
+
expect(rules[0].css_text).to eq "body { color: #444;background-color: #535353;}"
|
91
|
+
expect(rules[1].css_text).to eq "p { font-size: 90%;}"
|
92
|
+
end
|
93
|
+
|
94
|
+
it "parses empty rules" do
|
95
|
+
rules = CssRuleList.new(style_w_empty_rules)
|
96
|
+
expect(rules.length).to eq 3
|
97
|
+
expect(rules[0].css_text).to eq "#cboxOverlay{color:#ccc}"
|
98
|
+
expect(rules[1].css_text).to eq "#colorbox{}"
|
99
|
+
expect(rules[2].css_text).to eq "#cboxTopLeft{width:21px;}"
|
100
|
+
end
|
71
101
|
end
|
72
102
|
|
73
103
|
describe "#[]" do
|
data/spec/css_rule_spec.rb
CHANGED
@@ -26,6 +26,15 @@ describe CssRule do
|
|
26
26
|
src: url(\"http://example.com/fonts/VeraSeBd.ttf\");
|
27
27
|
}"
|
28
28
|
end
|
29
|
+
|
30
|
+
let(:moz_doc_text) do
|
31
|
+
"@-moz-document url-prefix() {
|
32
|
+
.rec_details .rec-ellipsis:before {
|
33
|
+
float:right;
|
34
|
+
content: url(/fade.png);
|
35
|
+
}
|
36
|
+
}"
|
37
|
+
end
|
29
38
|
|
30
39
|
describe ".factory" do
|
31
40
|
it "should build an a css style rule" do
|
@@ -58,6 +67,12 @@ describe CssRule do
|
|
58
67
|
:parent_style_sheet => Object.new)
|
59
68
|
expect(rule).to be_kind_of(CssFontFaceRule)
|
60
69
|
end
|
70
|
+
|
71
|
+
it "should build a null rule" do
|
72
|
+
rule = CssRule.factory(:css_text => moz_doc_text,
|
73
|
+
:parent_style_sheet => Object.new)
|
74
|
+
expect(rule).to be_kind_of(CssNullRule)
|
75
|
+
end
|
61
76
|
end
|
62
77
|
|
63
78
|
describe "#css_text" do
|
@@ -79,4 +79,33 @@ describe CssStyleDeclaration do
|
|
79
79
|
expect(declaration.overflow).to eq ""
|
80
80
|
end
|
81
81
|
end
|
82
|
+
|
83
|
+
describe "a declaration with base64 encoded rule" do
|
84
|
+
let(:css_text) do
|
85
|
+
"background:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIi);color:#1d6299;"
|
86
|
+
end
|
87
|
+
|
88
|
+
it "returns the css style declaration for rules with base64 data" do
|
89
|
+
rule = CssStyleRule.new(:css_text => "div.section { #{css_text} }")
|
90
|
+
decl = CssStyleDeclaration.new(:css_text => css_text, :parent_rule => rule)
|
91
|
+
|
92
|
+
expected = {"background" => "url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIi)",
|
93
|
+
"color" => "#1d6299"}
|
94
|
+
expect(decl.declarations).to eq expected
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "a declaration with an invalid rule" do
|
99
|
+
let(:css_text) do
|
100
|
+
"padding0;color:#1d6299;"
|
101
|
+
end
|
102
|
+
|
103
|
+
it "skips the invalid rule" do
|
104
|
+
rule = CssStyleRule.new(:css_text => "div.section { #{css_text} }")
|
105
|
+
decl = CssStyleDeclaration.new(:css_text => css_text, :parent_rule => rule)
|
106
|
+
|
107
|
+
expected = {"color" => "#1d6299"}
|
108
|
+
expect(decl.declarations).to eq expected
|
109
|
+
end
|
110
|
+
end
|
82
111
|
end
|
data/spec/css_style_rule_spec.rb
CHANGED
@@ -42,12 +42,12 @@ describe CssStyleRule do
|
|
42
42
|
describe ".matches_rule?" do
|
43
43
|
it "should match text that doesn't begin with an at-rule" do
|
44
44
|
matches = CssStyleRule.matches_rule?(css_text)
|
45
|
-
expect(matches).to
|
45
|
+
expect(matches).to eq true
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should not match rules starting with at-rule" do
|
49
49
|
matches = CssStyleRule.matches_rule?("@import url(\"import1.css\");")
|
50
|
-
expect(matches).to
|
50
|
+
expect(matches).to eq false
|
51
51
|
end
|
52
52
|
end
|
53
|
-
end
|
53
|
+
end
|
@@ -8,10 +8,10 @@ describe CssStyleSheet do
|
|
8
8
|
describe "#disabled" do
|
9
9
|
it "shows if style sheet is disabled" do
|
10
10
|
sheet = CssStyleSheet.new("http://example.com/css/stylesheets/screen.css")
|
11
|
-
expect(sheet.disabled?).to
|
11
|
+
expect(sheet.disabled?).to eq false
|
12
12
|
|
13
13
|
sheet.disabled = true
|
14
|
-
expect(sheet.disabled?).to
|
14
|
+
expect(sheet.disabled?).to eq true
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -127,7 +127,18 @@ describe CssStyleSheet do
|
|
127
127
|
expect(sheet.type).to eq "text/css"
|
128
128
|
end
|
129
129
|
end
|
130
|
-
|
130
|
+
|
131
|
+
describe "#content" do
|
132
|
+
it "doesn't fetch for empty inline styles" do
|
133
|
+
sheet = CssStyleSheet.new(content: "")
|
134
|
+
|
135
|
+
expect {
|
136
|
+
sheet.css_rules.map {|r| r.content }
|
137
|
+
}.not_to raise_error
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
141
|
+
|
131
142
|
describe "#css_rules" do
|
132
143
|
it "returns a list of css rules found in the style sheet" do
|
133
144
|
sheet = CssStyleSheet.new("http://example.com/css/stylesheets/screen.css")
|
@@ -142,6 +153,28 @@ describe CssStyleSheet do
|
|
142
153
|
end
|
143
154
|
end
|
144
155
|
|
156
|
+
describe "#import_rules" do
|
157
|
+
it "returns all import rules from style sheet" do
|
158
|
+
sheet = CssStyleSheet.new("http://example.com/css_import/stylesheets/screen.css")
|
159
|
+
expect(sheet.import_rules.length).to eq 9
|
160
|
+
|
161
|
+
sheet.import_rules.each do |rule|
|
162
|
+
expect(rule.type).to eq CssRule::IMPORT_RULE
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
describe "#style_rules" do
|
168
|
+
it "returns all style rules from style sheet" do
|
169
|
+
sheet = CssStyleSheet.new("http://example.com/css_import/stylesheets/screen.css")
|
170
|
+
expect(sheet.style_rules.length).to eq 1
|
171
|
+
|
172
|
+
sheet.style_rules.each do |rule|
|
173
|
+
expect(rule.type).to eq CssRule::STYLE_RULE
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
145
178
|
describe "#owner_rule" do
|
146
179
|
let(:parent) do
|
147
180
|
CssStyleSheet.new("http://example.com/css_import/stylesheets/screen.css")
|
@@ -185,4 +218,4 @@ describe CssStyleSheet do
|
|
185
218
|
|
186
219
|
end
|
187
220
|
end
|
188
|
-
end
|
221
|
+
end
|
data/spec/location_spec.rb
CHANGED
@@ -8,18 +8,14 @@ describe Location do
|
|
8
8
|
location = Location.new(url)
|
9
9
|
expect(location.host).to eq "initvisual.com"
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
it "should accept relative urls" do
|
13
13
|
location = Location.new("/some/path.html")
|
14
14
|
expect(location.to_s).to eq "/some/path.html"
|
15
15
|
end
|
16
|
-
|
17
|
-
it "should throw error for invalid host" do
|
18
|
-
expect { Location.new("http://") }.to raise_error(InvalidLocationError)
|
19
|
-
end
|
20
16
|
end
|
21
|
-
|
22
|
-
|
17
|
+
|
18
|
+
|
23
19
|
describe "#new with parent" do
|
24
20
|
it "should not expand a full url" do
|
25
21
|
parent = Location.new("http://example.com/css/url.html")
|
@@ -31,7 +27,7 @@ describe Location do
|
|
31
27
|
it "should expand a relative path into a full path given the parent" do
|
32
28
|
parent = Location.new("http://example.com/css/relative.html")
|
33
29
|
location = Location.new("stylesheets/screen.css", parent)
|
34
|
-
|
30
|
+
|
35
31
|
expect(location.to_s).to eq "http://example.com/css/stylesheets/screen.css"
|
36
32
|
end
|
37
33
|
|
@@ -40,9 +36,9 @@ describe Location do
|
|
40
36
|
location = Location.new("/css/stylesheets/screen.css", parent)
|
41
37
|
|
42
38
|
expect(location.to_s).to eq "http://example.com/css/stylesheets/screen.css"
|
43
|
-
end
|
39
|
+
end
|
44
40
|
end
|
45
|
-
|
41
|
+
|
46
42
|
|
47
43
|
describe "#host" do
|
48
44
|
it "should parse out the url host" do
|
@@ -50,27 +46,27 @@ describe Location do
|
|
50
46
|
expect(location.host).to eq "initvisual.com"
|
51
47
|
end
|
52
48
|
end
|
53
|
-
|
54
|
-
describe "#host=" do
|
55
|
-
it "should assign host to url" do
|
49
|
+
|
50
|
+
describe "#host=" do
|
51
|
+
it "should assign host to url" do
|
56
52
|
location = Location.new(url)
|
57
|
-
|
53
|
+
|
58
54
|
location.host = "derekdevries.com"
|
59
55
|
expect(location.host).to eq "derekdevries.com"
|
60
56
|
end
|
61
57
|
end
|
62
|
-
|
58
|
+
|
63
59
|
describe "#hostname" do
|
64
60
|
it "should parse out the url hostname" do
|
65
61
|
location = Location.new(url)
|
66
62
|
expect(location.hostname).to eq "initvisual.com"
|
67
63
|
end
|
68
64
|
end
|
69
|
-
|
65
|
+
|
70
66
|
describe "#hostname=" do
|
71
67
|
it "should assign hostname to url" do
|
72
68
|
location = Location.new(url)
|
73
|
-
|
69
|
+
|
74
70
|
location.hostname = "derekdevries.com"
|
75
71
|
expect(location.hostname).to eq "derekdevries.com"
|
76
72
|
end
|
@@ -86,14 +82,14 @@ describe Location do
|
|
86
82
|
describe "#pathname=" do
|
87
83
|
it "should assign path to url" do
|
88
84
|
location = Location.new(url)
|
89
|
-
|
85
|
+
|
90
86
|
location.pathname = "/work"
|
91
87
|
expect(location.pathname).to eq "/work"
|
92
88
|
end
|
93
89
|
|
94
90
|
it "add initial forward-slash if not given" do
|
95
91
|
location = Location.new(url)
|
96
|
-
|
92
|
+
|
97
93
|
location.pathname = "work"
|
98
94
|
expect(location.pathname).to eq "/work"
|
99
95
|
end
|
@@ -243,18 +239,23 @@ describe Location do
|
|
243
239
|
describe "#valid?" do
|
244
240
|
it "should be true with a valid host and protocol" do
|
245
241
|
location = Location.new("http://initvisual.com")
|
246
|
-
expect(location.valid?).to
|
242
|
+
expect(location.valid?).to eq true
|
247
243
|
end
|
248
244
|
|
249
|
-
it "should be false for an invalid host" do
|
245
|
+
it "should be false for an invalid host" do
|
250
246
|
location = Location.new("/asdf")
|
251
|
-
expect(location.valid?).to
|
247
|
+
expect(location.valid?).to eq false
|
248
|
+
end
|
249
|
+
|
250
|
+
it "should be false for a missing host" do
|
251
|
+
location = Location.new("http://")
|
252
|
+
expect(location.valid?).to eq false
|
252
253
|
end
|
253
254
|
|
254
|
-
it "should be false for an invalid protocol" do
|
255
|
+
it "should be false for an invalid protocol" do
|
255
256
|
location = Location.new("foo.com/asdf")
|
256
|
-
expect(location.valid?).to
|
257
|
+
expect(location.valid?).to eq false
|
257
258
|
end
|
258
259
|
end
|
259
260
|
|
260
|
-
end
|
261
|
+
end
|
data/stylesheet.gemspec
CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |gem|
|
|
24
24
|
gem.add_runtime_dependency("curb", "~> 0.8")
|
25
25
|
gem.add_runtime_dependency("nokogiri", "~> 1.5")
|
26
26
|
|
27
|
+
gem.add_development_dependency("rake")
|
27
28
|
gem.add_development_dependency("rspec", "~> 2.9")
|
28
29
|
gem.add_development_dependency("cucumber", "~> 1.2")
|
29
30
|
|
metadata
CHANGED
@@ -1,126 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stylesheet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.7
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Derek DeVries
|
9
|
-
autorequire:
|
8
|
+
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2020-08-24 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: curb
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0.8'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0.8'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: nokogiri
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- - ~>
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '1.5'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- - ~>
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '1.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
46
55
|
- !ruby/object:Gem::Dependency
|
47
56
|
name: rspec
|
48
57
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
58
|
requirements:
|
51
|
-
- - ~>
|
59
|
+
- - "~>"
|
52
60
|
- !ruby/object:Gem::Version
|
53
61
|
version: '2.9'
|
54
62
|
type: :development
|
55
63
|
prerelease: false
|
56
64
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
65
|
requirements:
|
59
|
-
- - ~>
|
66
|
+
- - "~>"
|
60
67
|
- !ruby/object:Gem::Version
|
61
68
|
version: '2.9'
|
62
69
|
- !ruby/object:Gem::Dependency
|
63
70
|
name: cucumber
|
64
71
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
72
|
requirements:
|
67
|
-
- - ~>
|
73
|
+
- - "~>"
|
68
74
|
- !ruby/object:Gem::Version
|
69
75
|
version: '1.2'
|
70
76
|
type: :development
|
71
77
|
prerelease: false
|
72
78
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
79
|
requirements:
|
75
|
-
- - ~>
|
80
|
+
- - "~>"
|
76
81
|
- !ruby/object:Gem::Version
|
77
82
|
version: '1.2'
|
78
83
|
- !ruby/object:Gem::Dependency
|
79
84
|
name: guard
|
80
85
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
86
|
requirements:
|
83
|
-
- - ~>
|
87
|
+
- - "~>"
|
84
88
|
- !ruby/object:Gem::Version
|
85
89
|
version: '1.7'
|
86
90
|
type: :development
|
87
91
|
prerelease: false
|
88
92
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
93
|
requirements:
|
91
|
-
- - ~>
|
94
|
+
- - "~>"
|
92
95
|
- !ruby/object:Gem::Version
|
93
96
|
version: '1.7'
|
94
97
|
- !ruby/object:Gem::Dependency
|
95
98
|
name: guard-rspec
|
96
99
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
100
|
requirements:
|
99
|
-
- - ~>
|
101
|
+
- - "~>"
|
100
102
|
- !ruby/object:Gem::Version
|
101
103
|
version: '2.5'
|
102
104
|
type: :development
|
103
105
|
prerelease: false
|
104
106
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
107
|
requirements:
|
107
|
-
- - ~>
|
108
|
+
- - "~>"
|
108
109
|
- !ruby/object:Gem::Version
|
109
110
|
version: '2.5'
|
110
111
|
- !ruby/object:Gem::Dependency
|
111
112
|
name: rb-fsevent
|
112
113
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
114
|
requirements:
|
115
|
-
- - ~>
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0.9'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
121
|
requirements:
|
123
|
-
- - ~>
|
122
|
+
- - "~>"
|
124
123
|
- !ruby/object:Gem::Version
|
125
124
|
version: '0.9'
|
126
125
|
description: A CSS parser based on the DOM API
|
@@ -130,7 +129,7 @@ executables: []
|
|
130
129
|
extensions: []
|
131
130
|
extra_rdoc_files: []
|
132
131
|
files:
|
133
|
-
- .gitignore
|
132
|
+
- ".gitignore"
|
134
133
|
- Gemfile
|
135
134
|
- Guardfile
|
136
135
|
- LICENSE.txt
|
@@ -148,6 +147,7 @@ files:
|
|
148
147
|
- lib/stylesheet/css_font_face_rule.rb
|
149
148
|
- lib/stylesheet/css_import_rule.rb
|
150
149
|
- lib/stylesheet/css_media_rule.rb
|
150
|
+
- lib/stylesheet/css_null_rule.rb
|
151
151
|
- lib/stylesheet/css_rule.rb
|
152
152
|
- lib/stylesheet/css_rule_list.rb
|
153
153
|
- lib/stylesheet/css_style_declaration.rb
|
@@ -214,27 +214,25 @@ files:
|
|
214
214
|
homepage: https://github.com/devrieda/stylesheet
|
215
215
|
licenses:
|
216
216
|
- MIT
|
217
|
-
|
217
|
+
metadata: {}
|
218
|
+
post_install_message:
|
218
219
|
rdoc_options: []
|
219
220
|
require_paths:
|
220
221
|
- lib
|
221
222
|
required_ruby_version: !ruby/object:Gem::Requirement
|
222
|
-
none: false
|
223
223
|
requirements:
|
224
|
-
- -
|
224
|
+
- - ">="
|
225
225
|
- !ruby/object:Gem::Version
|
226
226
|
version: 1.9.3
|
227
227
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
228
|
-
none: false
|
229
228
|
requirements:
|
230
|
-
- -
|
229
|
+
- - ">="
|
231
230
|
- !ruby/object:Gem::Version
|
232
231
|
version: '0'
|
233
232
|
requirements: []
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
specification_version: 3
|
233
|
+
rubygems_version: 3.1.2
|
234
|
+
signing_key:
|
235
|
+
specification_version: 4
|
238
236
|
summary: A CSS parser based on the DOM API
|
239
237
|
test_files:
|
240
238
|
- features/document_styles.feature
|
@@ -293,4 +291,3 @@ test_files:
|
|
293
291
|
- spec/stubs/fake_request.rb
|
294
292
|
- spec/style_sheet_list_spec.rb
|
295
293
|
- spec/version_spec.rb
|
296
|
-
has_rdoc:
|