csspool 3.0.2 → 4.0.0.pre
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/Gemfile.lock +4 -4
- data/Manifest.txt +13 -0
- data/README.rdoc +1 -1
- data/lib/csspool/css/document.rb +6 -0
- data/lib/csspool/css/document_handler.rb +41 -7
- data/lib/csspool/css/document_query.rb +14 -0
- data/lib/csspool/css/import_rule.rb +8 -4
- data/lib/csspool/css/keyframes_block.rb +14 -0
- data/lib/csspool/css/keyframes_rule.rb +14 -0
- data/lib/csspool/css/media.rb +5 -3
- data/lib/csspool/css/namespace_rule.rb +13 -0
- data/lib/csspool/css/parser.rb +970 -425
- data/lib/csspool/css/parser.y +227 -30
- data/lib/csspool/css/tokenizer.rb +31 -7
- data/lib/csspool/css/tokenizer.rex +36 -7
- data/lib/csspool/css.rb +4 -0
- data/lib/csspool/selector.rb +5 -1
- data/lib/csspool/selectors/attribute.rb +6 -1
- data/lib/csspool/selectors/pseudo.rb +17 -0
- data/lib/csspool/selectors/pseudo_element.rb +13 -0
- data/lib/csspool/selectors/simple.rb +0 -4
- data/lib/csspool/selectors/type.rb +7 -0
- data/lib/csspool/selectors/universal.rb +7 -0
- data/lib/csspool/selectors.rb +1 -1
- data/lib/csspool/terms/math.rb +18 -0
- data/lib/csspool/terms.rb +1 -0
- data/lib/csspool/visitors/children.rb +1 -1
- data/lib/csspool/visitors/comparable.rb +8 -2
- data/lib/csspool/visitors/iterator.rb +1 -1
- data/lib/csspool/visitors/to_css.rb +41 -21
- data/lib/csspool.rb +1 -1
- data/test/_local_helper.rb +2 -0
- data/test/css/test_document_query.rb +76 -0
- data/test/css/test_import_rule.rb +1 -1
- data/test/css/test_keyframes_rule.rb +93 -0
- data/test/css/test_namespace_rule.rb +54 -0
- data/test/css/test_parser.rb +46 -1
- data/test/css/test_tokenizer.rb +0 -45
- data/test/helper.rb +6 -1
- data/test/sac/test_parser.rb +16 -3
- data/test/test_declaration.rb +39 -0
- data/test/test_parser.rb +26 -13
- data/test/test_selector.rb +205 -5
- data/test/test_term.rb +23 -0
- data/test/visitors/test_to_css.rb +34 -23
- metadata +136 -118
data/Gemfile.lock
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
hoe (3.
|
4
|
+
hoe (3.0.4)
|
5
5
|
rake (~> 0.8)
|
6
|
-
hoe-bundler (1.
|
6
|
+
hoe-bundler (1.1.0)
|
7
7
|
hoe (>= 2.2.0)
|
8
8
|
hoe-gemspec (1.0.0)
|
9
9
|
hoe (>= 2.2.0)
|
10
10
|
hoe-git (1.5.0)
|
11
11
|
hoe (>= 2.2.0)
|
12
|
-
json (1.7.
|
13
|
-
racc (1.4.
|
12
|
+
json (1.7.0)
|
13
|
+
racc (1.4.8)
|
14
14
|
rake (0.9.2.2)
|
15
15
|
rdoc (3.12)
|
16
16
|
json (~> 1.4)
|
data/Manifest.txt
CHANGED
@@ -12,8 +12,12 @@ lib/csspool/css/charset.rb
|
|
12
12
|
lib/csspool/css/declaration.rb
|
13
13
|
lib/csspool/css/document.rb
|
14
14
|
lib/csspool/css/document_handler.rb
|
15
|
+
lib/csspool/css/document_query.rb
|
15
16
|
lib/csspool/css/import_rule.rb
|
17
|
+
lib/csspool/css/keyframes_block.rb
|
18
|
+
lib/csspool/css/keyframes_rule.rb
|
16
19
|
lib/csspool/css/media.rb
|
20
|
+
lib/csspool/css/namespace_rule.rb
|
17
21
|
lib/csspool/css/parser.rb
|
18
22
|
lib/csspool/css/parser.y
|
19
23
|
lib/csspool/css/rule_set.rb
|
@@ -29,7 +33,9 @@ lib/csspool/selectors/additional.rb
|
|
29
33
|
lib/csspool/selectors/attribute.rb
|
30
34
|
lib/csspool/selectors/class.rb
|
31
35
|
lib/csspool/selectors/id.rb
|
36
|
+
lib/csspool/selectors/pseudo.rb
|
32
37
|
lib/csspool/selectors/pseudo_class.rb
|
38
|
+
lib/csspool/selectors/pseudo_element.rb
|
33
39
|
lib/csspool/selectors/simple.rb
|
34
40
|
lib/csspool/selectors/type.rb
|
35
41
|
lib/csspool/selectors/universal.rb
|
@@ -37,6 +43,7 @@ lib/csspool/terms.rb
|
|
37
43
|
lib/csspool/terms/function.rb
|
38
44
|
lib/csspool/terms/hash.rb
|
39
45
|
lib/csspool/terms/ident.rb
|
46
|
+
lib/csspool/terms/math.rb
|
40
47
|
lib/csspool/terms/number.rb
|
41
48
|
lib/csspool/terms/rgb.rb
|
42
49
|
lib/csspool/terms/string.rb
|
@@ -47,8 +54,12 @@ lib/csspool/visitors/comparable.rb
|
|
47
54
|
lib/csspool/visitors/iterator.rb
|
48
55
|
lib/csspool/visitors/to_css.rb
|
49
56
|
lib/csspool/visitors/visitor.rb
|
57
|
+
test/_local_helper.rb
|
50
58
|
test/css/test_document.rb
|
59
|
+
test/css/test_document_query.rb
|
51
60
|
test/css/test_import_rule.rb
|
61
|
+
test/css/test_keyframes_rule.rb
|
62
|
+
test/css/test_namespace_rule.rb
|
52
63
|
test/css/test_parser.rb
|
53
64
|
test/css/test_tokenizer.rb
|
54
65
|
test/files/test.css
|
@@ -57,8 +68,10 @@ test/sac/test_parser.rb
|
|
57
68
|
test/sac/test_properties.rb
|
58
69
|
test/sac/test_terms.rb
|
59
70
|
test/test_collection.rb
|
71
|
+
test/test_declaration.rb
|
60
72
|
test/test_parser.rb
|
61
73
|
test/test_selector.rb
|
74
|
+
test/test_term.rb
|
62
75
|
test/visitors/test_children.rb
|
63
76
|
test/visitors/test_comparable.rb
|
64
77
|
test/visitors/test_each.rb
|
data/README.rdoc
CHANGED
data/lib/csspool/css/document.rb
CHANGED
@@ -21,15 +21,21 @@ module CSSPool
|
|
21
21
|
attr_accessor :rule_sets
|
22
22
|
attr_accessor :charsets
|
23
23
|
attr_accessor :import_rules
|
24
|
+
attr_accessor :document_queries
|
25
|
+
attr_accessor :namespaces
|
24
26
|
attr_accessor :parent
|
25
27
|
attr_accessor :parent_import_rule
|
28
|
+
attr_accessor :keyframes_rules
|
26
29
|
|
27
30
|
def initialize
|
28
31
|
@rule_sets = []
|
29
32
|
@charsets = []
|
30
33
|
@import_rules = []
|
34
|
+
@document_queries = []
|
35
|
+
@namespaces = []
|
31
36
|
@parent = nil
|
32
37
|
@parent_import_rule = nil
|
38
|
+
@keyframes_rules = []
|
33
39
|
end
|
34
40
|
|
35
41
|
def [] selector
|
@@ -5,7 +5,8 @@ module CSSPool
|
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
@document = nil
|
8
|
-
@
|
8
|
+
@conditional_stack = []
|
9
|
+
@active_keyframes_block = nil
|
9
10
|
end
|
10
11
|
|
11
12
|
def start_document
|
@@ -20,32 +21,65 @@ module CSSPool
|
|
20
21
|
@document.import_rules << CSS::ImportRule.new(
|
21
22
|
uri,
|
22
23
|
ns,
|
23
|
-
media_list
|
24
|
+
media_list,
|
24
25
|
@document,
|
25
26
|
loc
|
26
27
|
)
|
27
28
|
end
|
28
29
|
|
30
|
+
def namespace prefix, uri
|
31
|
+
@document.namespaces << CSS::NamespaceRule.new(
|
32
|
+
prefix,
|
33
|
+
uri
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
29
37
|
def start_selector selector_list
|
30
|
-
|
38
|
+
rs = RuleSet.new(
|
31
39
|
selector_list,
|
32
40
|
[],
|
33
|
-
@
|
41
|
+
@conditional_stack.last || []
|
34
42
|
)
|
43
|
+
@document.rule_sets << rs
|
44
|
+
@conditional_stack.last.rule_sets << rs unless @conditional_stack.empty?
|
35
45
|
end
|
36
46
|
|
37
47
|
def property name, exp, important
|
38
|
-
rs = @document.rule_sets.last
|
48
|
+
rs = @active_keyframes_block.nil? ? @document.rule_sets.last : @active_keyframes_block
|
39
49
|
rs.declarations << Declaration.new(name, exp, important, rs)
|
40
50
|
end
|
41
51
|
|
42
52
|
def start_media media_list, parse_location = {}
|
43
|
-
@
|
53
|
+
@conditional_stack << CSS::Media.new(media_list, parse_location)
|
44
54
|
end
|
45
55
|
|
46
56
|
def end_media media_list, parse_location = {}
|
47
|
-
@
|
57
|
+
@conditional_stack.pop
|
58
|
+
end
|
59
|
+
|
60
|
+
def start_document_query url_functions
|
61
|
+
dq = CSS::DocumentQuery.new(url_functions)
|
62
|
+
@document.document_queries << dq
|
63
|
+
@conditional_stack << dq
|
64
|
+
end
|
65
|
+
|
66
|
+
def end_document_query
|
67
|
+
@conditional_stack.pop
|
48
68
|
end
|
69
|
+
|
70
|
+
def start_keyframes_rule name
|
71
|
+
@document.keyframes_rules << CSS::KeyframesRule.new(name)
|
72
|
+
end
|
73
|
+
|
74
|
+
def start_keyframes_block keyText
|
75
|
+
@active_keyframes_block = CSS::KeyframesBlock.new(keyText)
|
76
|
+
@document.keyframes_rules.last.rule_sets << @active_keyframes_block
|
77
|
+
end
|
78
|
+
|
79
|
+
def end_keyframes_block
|
80
|
+
@active_keyframes_block = nil
|
81
|
+
end
|
82
|
+
|
49
83
|
end
|
50
84
|
end
|
51
85
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Represents an @document conditional rule
|
2
|
+
module CSSPool
|
3
|
+
module CSS
|
4
|
+
class DocumentQuery < CSSPool::Node
|
5
|
+
attr_accessor :url_functions
|
6
|
+
attr_accessor :rule_sets
|
7
|
+
|
8
|
+
def initialize url_functions
|
9
|
+
@url_functions = url_functions
|
10
|
+
@rule_sets = []
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -3,14 +3,14 @@ module CSSPool
|
|
3
3
|
class ImportRule < CSSPool::Node
|
4
4
|
attr_accessor :uri
|
5
5
|
attr_accessor :namespace
|
6
|
-
attr_accessor :
|
6
|
+
attr_accessor :media_list
|
7
7
|
attr_accessor :document
|
8
8
|
attr_accessor :parse_location
|
9
9
|
|
10
|
-
def initialize uri, namespace,
|
10
|
+
def initialize uri, namespace, media_list, document, parse_location
|
11
11
|
@uri = uri
|
12
12
|
@namespace = namespace
|
13
|
-
@
|
13
|
+
@media_list = media_list
|
14
14
|
@document = document
|
15
15
|
@parse_location = parse_location
|
16
16
|
end
|
@@ -19,7 +19,11 @@ module CSSPool
|
|
19
19
|
new_doc = CSSPool.CSS(yield uri.value)
|
20
20
|
new_doc.parent_import_rule = self
|
21
21
|
new_doc.parent = document
|
22
|
-
|
22
|
+
# we'll make a "fake" media rule if this import specified media to apply to the rulesets
|
23
|
+
if !media_list.empty?
|
24
|
+
media = CSS::Media.new(media_list, parse_location)
|
25
|
+
new_doc.rule_sets.each { |rs| rs.media = media }
|
26
|
+
end
|
23
27
|
new_doc
|
24
28
|
end
|
25
29
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Represents a block inside a @keyframes rule
|
2
|
+
module CSSPool
|
3
|
+
module CSS
|
4
|
+
class KeyframesBlock < CSSPool::Node
|
5
|
+
attr_accessor :keyText
|
6
|
+
attr_accessor :declarations
|
7
|
+
|
8
|
+
def initialize keyText
|
9
|
+
@keyText = keyText
|
10
|
+
@declarations = []
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/csspool/css/media.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
module CSSPool
|
2
2
|
module CSS
|
3
3
|
class Media < CSSPool::Node
|
4
|
-
attr_accessor :
|
4
|
+
attr_accessor :media_list
|
5
5
|
attr_accessor :parse_location
|
6
|
+
attr_accessor :rule_sets
|
6
7
|
|
7
|
-
def initialize
|
8
|
-
@
|
8
|
+
def initialize media_list, parse_location
|
9
|
+
@media_list = media_list
|
9
10
|
@parse_location = parse_location
|
11
|
+
@rule_sets = []
|
10
12
|
end
|
11
13
|
end
|
12
14
|
end
|