csspool 4.0.0.pre → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.rdoc +12 -0
- data/Gemfile.lock +6 -6
- data/Manifest.txt +10 -2
- data/Rakefile +1 -0
- data/lib/csspool/css/declaration.rb +1 -1
- data/lib/csspool/css/document.rb +5 -1
- data/lib/csspool/css/document_handler.rb +43 -11
- data/lib/csspool/css/fontface_rule.rb +13 -0
- data/lib/csspool/css/import_rule.rb +0 -5
- data/lib/csspool/css/media_feature.rb +14 -0
- data/lib/csspool/css/media_query.rb +19 -0
- data/lib/csspool/css/media_query_list.rb +41 -0
- data/lib/csspool/css/{media.rb → media_type.rb} +6 -4
- data/lib/csspool/css/parser.rb +1272 -671
- data/lib/csspool/css/parser.y +223 -53
- data/lib/csspool/css/rule_set.rb +4 -3
- data/lib/csspool/css/supports_rule.rb +14 -0
- data/lib/csspool/css/tokenizer.rb +92 -16
- data/lib/csspool/css/tokenizer.rex +42 -19
- data/lib/csspool/css.rb +6 -1
- data/lib/csspool/node.rb +22 -0
- data/lib/csspool/selector.rb +5 -4
- data/lib/csspool/selectors/pseudo.rb +2 -2
- data/lib/csspool/terms/function.rb +1 -1
- data/lib/csspool/terms/resolution.rb +13 -0
- data/lib/csspool/terms.rb +1 -0
- data/lib/csspool/visitors/children.rb +16 -2
- data/lib/csspool/visitors/comparable.rb +27 -8
- data/lib/csspool/visitors/iterator.rb +5 -3
- data/lib/csspool/visitors/to_css.rb +73 -20
- data/test/css/test_document_query.rb +37 -38
- data/test/css/test_font_face.rb +16 -0
- data/test/css/test_import_rule.rb +0 -3
- data/test/css/test_media_rule.rb +92 -0
- data/test/css/test_node_position.rb +81 -0
- data/test/css/test_parser.rb +12 -39
- data/test/css/test_supports_rule.rb +133 -0
- data/test/css/test_tokenizer.rb +4 -4
- data/test/css/test_variables.rb +33 -0
- data/test/helper.rb +3 -3
- data/test/sac/test_parser.rb +1 -0
- data/test/test_parser.rb +22 -9
- data/test/test_selector.rb +44 -4
- data/test/test_term.rb +29 -0
- data/test/visitors/test_comparable.rb +8 -0
- data/test/visitors/test_to_css.rb +89 -13
- metadata +54 -58
- data/test/_local_helper.rb +0 -2
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 78a85df3fe179c10647db55fdae56a52458d191c
|
4
|
+
data.tar.gz: 316c13064d6a93280dc4a2ab4b785ddc2e62607f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d472fdf6210e101fde9d8a1c21c5ec10229f8587f06e20878c08d337748e0a671eadeb66d82503739f54c3c32d62670d46824656987d7a3e05422e719d2120be
|
7
|
+
data.tar.gz: 1a96b768e988dc4330cefa5bb51dfe108771204c28e9b8c64be4983d7f4c925368b2c100331b6cca9991328e4b34ff3bfc46156be6d49b4bee2c052ea0d79fa4
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
== 4.0.0
|
2
|
+
|
3
|
+
* New Features
|
4
|
+
|
5
|
+
* Support for parsing many new CSS features, including `:not`, `calc`, and `@supports`.
|
6
|
+
* Line number and context in parser error messages
|
7
|
+
* Some nodes types will remember their start and end positions, allowing developers to retrieve their original code.
|
8
|
+
|
9
|
+
* Bugfixes
|
10
|
+
|
11
|
+
* Updated parsing for unusual syntax.
|
12
|
+
|
1
13
|
== 3.0.2
|
2
14
|
|
3
15
|
* New Features
|
data/Gemfile.lock
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
hoe (3.0
|
5
|
-
rake (
|
6
|
-
hoe-bundler (1.
|
4
|
+
hoe (3.4.0)
|
5
|
+
rake (>= 0.8, < 11.0)
|
6
|
+
hoe-bundler (1.2.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.
|
14
|
-
rake (0.
|
12
|
+
json (1.7.7)
|
13
|
+
racc (1.4.9)
|
14
|
+
rake (10.0.3)
|
15
15
|
rdoc (3.12)
|
16
16
|
json (~> 1.4)
|
17
17
|
rexical (1.0.5)
|
data/Manifest.txt
CHANGED
@@ -13,14 +13,19 @@ lib/csspool/css/declaration.rb
|
|
13
13
|
lib/csspool/css/document.rb
|
14
14
|
lib/csspool/css/document_handler.rb
|
15
15
|
lib/csspool/css/document_query.rb
|
16
|
+
lib/csspool/css/fontface_rule.rb
|
16
17
|
lib/csspool/css/import_rule.rb
|
17
18
|
lib/csspool/css/keyframes_block.rb
|
18
19
|
lib/csspool/css/keyframes_rule.rb
|
19
|
-
lib/csspool/css/
|
20
|
+
lib/csspool/css/media_feature.rb
|
21
|
+
lib/csspool/css/media_query.rb
|
22
|
+
lib/csspool/css/media_query_list.rb
|
23
|
+
lib/csspool/css/media_type.rb
|
20
24
|
lib/csspool/css/namespace_rule.rb
|
21
25
|
lib/csspool/css/parser.rb
|
22
26
|
lib/csspool/css/parser.y
|
23
27
|
lib/csspool/css/rule_set.rb
|
28
|
+
lib/csspool/css/supports_rule.rb
|
24
29
|
lib/csspool/css/tokenizer.rb
|
25
30
|
lib/csspool/css/tokenizer.rex
|
26
31
|
lib/csspool/node.rb
|
@@ -45,6 +50,7 @@ lib/csspool/terms/hash.rb
|
|
45
50
|
lib/csspool/terms/ident.rb
|
46
51
|
lib/csspool/terms/math.rb
|
47
52
|
lib/csspool/terms/number.rb
|
53
|
+
lib/csspool/terms/resolution.rb
|
48
54
|
lib/csspool/terms/rgb.rb
|
49
55
|
lib/csspool/terms/string.rb
|
50
56
|
lib/csspool/terms/uri.rb
|
@@ -54,13 +60,15 @@ lib/csspool/visitors/comparable.rb
|
|
54
60
|
lib/csspool/visitors/iterator.rb
|
55
61
|
lib/csspool/visitors/to_css.rb
|
56
62
|
lib/csspool/visitors/visitor.rb
|
57
|
-
test/_local_helper.rb
|
58
63
|
test/css/test_document.rb
|
59
64
|
test/css/test_document_query.rb
|
65
|
+
test/css/test_font_face.rb
|
60
66
|
test/css/test_import_rule.rb
|
61
67
|
test/css/test_keyframes_rule.rb
|
68
|
+
test/css/test_media_rule.rb
|
62
69
|
test/css/test_namespace_rule.rb
|
63
70
|
test/css/test_parser.rb
|
71
|
+
test/css/test_supports_rule.rb
|
64
72
|
test/css/test_tokenizer.rb
|
65
73
|
test/files/test.css
|
66
74
|
test/helper.rb
|
data/Rakefile
CHANGED
@@ -16,6 +16,7 @@ Hoe.spec('csspool') do
|
|
16
16
|
self.readme_file = 'README.rdoc'
|
17
17
|
self.history_file = 'CHANGELOG.rdoc'
|
18
18
|
self.extra_rdoc_files = FileList['*.rdoc']
|
19
|
+
self.licenses = ['MIT']
|
19
20
|
|
20
21
|
%w{racc rexical hoe-git hoe-gemspec hoe-bundler}.each do |dep|
|
21
22
|
self.extra_dev_deps << [dep, '>= 0']
|
data/lib/csspool/css/document.rb
CHANGED
@@ -22,25 +22,29 @@ module CSSPool
|
|
22
22
|
attr_accessor :charsets
|
23
23
|
attr_accessor :import_rules
|
24
24
|
attr_accessor :document_queries
|
25
|
+
attr_accessor :supports_rules
|
25
26
|
attr_accessor :namespaces
|
26
27
|
attr_accessor :parent
|
27
28
|
attr_accessor :parent_import_rule
|
28
29
|
attr_accessor :keyframes_rules
|
30
|
+
attr_accessor :fontface_rules
|
29
31
|
|
30
32
|
def initialize
|
31
33
|
@rule_sets = []
|
32
34
|
@charsets = []
|
33
35
|
@import_rules = []
|
34
36
|
@document_queries = []
|
37
|
+
@supports_rules = []
|
35
38
|
@namespaces = []
|
36
39
|
@parent = nil
|
37
40
|
@parent_import_rule = nil
|
38
41
|
@keyframes_rules = []
|
42
|
+
@fontface_rules = []
|
39
43
|
end
|
40
44
|
|
41
45
|
def [] selector
|
42
46
|
selectors = CSSPool.CSS("#{selector} {}").rule_sets.first.selectors
|
43
|
-
rule_sets.find_all { |rs| rs.selectors == selectors}
|
47
|
+
rule_sets.find_all { |rs| rs.selectors == selectors }
|
44
48
|
end
|
45
49
|
end
|
46
50
|
end
|
@@ -2,11 +2,13 @@ module CSSPool
|
|
2
2
|
module CSS
|
3
3
|
class DocumentHandler < CSSPool::SAC::Document
|
4
4
|
attr_accessor :document
|
5
|
+
attr_accessor :node_start_pos
|
5
6
|
|
6
7
|
def initialize
|
7
8
|
@document = nil
|
8
9
|
@conditional_stack = []
|
9
10
|
@active_keyframes_block = nil
|
11
|
+
@active_fontface_rule = nil
|
10
12
|
end
|
11
13
|
|
12
14
|
def start_document
|
@@ -17,11 +19,11 @@ module CSSPool
|
|
17
19
|
@document.charsets << CSS::Charset.new(name, location)
|
18
20
|
end
|
19
21
|
|
20
|
-
def import_style
|
22
|
+
def import_style media, uri, ns = nil, loc = {}
|
21
23
|
@document.import_rules << CSS::ImportRule.new(
|
22
24
|
uri,
|
23
25
|
ns,
|
24
|
-
|
26
|
+
media,
|
25
27
|
@document,
|
26
28
|
loc
|
27
29
|
)
|
@@ -38,32 +40,54 @@ module CSSPool
|
|
38
40
|
rs = RuleSet.new(
|
39
41
|
selector_list,
|
40
42
|
[],
|
41
|
-
@conditional_stack.last
|
43
|
+
@conditional_stack.last
|
42
44
|
)
|
43
45
|
@document.rule_sets << rs
|
44
46
|
@conditional_stack.last.rule_sets << rs unless @conditional_stack.empty?
|
45
47
|
end
|
46
48
|
|
47
|
-
def property
|
48
|
-
|
49
|
-
|
49
|
+
def property declaration
|
50
|
+
if !@active_fontface_rule.nil?
|
51
|
+
rs = @active_fontface_rule
|
52
|
+
elsif !@active_keyframes_block.nil?
|
53
|
+
rs = @active_keyframes_block
|
54
|
+
else
|
55
|
+
rs = @document.rule_sets.last
|
56
|
+
end
|
57
|
+
declaration.rule_set = rs
|
58
|
+
rs.declarations << declaration
|
50
59
|
end
|
51
60
|
|
52
|
-
def start_media
|
53
|
-
@conditional_stack <<
|
61
|
+
def start_media media_query_list
|
62
|
+
@conditional_stack << media_query_list
|
54
63
|
end
|
55
64
|
|
56
|
-
def end_media
|
65
|
+
def end_media media_query_list
|
57
66
|
@conditional_stack.pop
|
58
67
|
end
|
59
68
|
|
60
|
-
def start_document_query url_functions
|
69
|
+
def start_document_query url_functions, inner_start_pos = nil
|
61
70
|
dq = CSS::DocumentQuery.new(url_functions)
|
71
|
+
dq.outer_start_pos = @node_start_pos
|
72
|
+
@node_start_pos = nil
|
73
|
+
dq.inner_start_pos = inner_start_pos
|
62
74
|
@document.document_queries << dq
|
63
75
|
@conditional_stack << dq
|
64
76
|
end
|
65
77
|
|
66
|
-
def end_document_query
|
78
|
+
def end_document_query inner_end_pos = nil, outer_end_pos = nil
|
79
|
+
last = @conditional_stack.pop
|
80
|
+
last.inner_end_pos = inner_end_pos
|
81
|
+
last.outer_end_pos = outer_end_pos
|
82
|
+
end
|
83
|
+
|
84
|
+
def start_supports conditions
|
85
|
+
sr = CSS::SupportsRule.new(conditions)
|
86
|
+
@document.supports_rules << sr
|
87
|
+
@conditional_stack << sr
|
88
|
+
end
|
89
|
+
|
90
|
+
def end_supports
|
67
91
|
@conditional_stack.pop
|
68
92
|
end
|
69
93
|
|
@@ -80,6 +104,14 @@ module CSSPool
|
|
80
104
|
@active_keyframes_block = nil
|
81
105
|
end
|
82
106
|
|
107
|
+
def start_fontface_rule
|
108
|
+
@active_fontface_rule = CSS::FontfaceRule.new
|
109
|
+
@document.fontface_rules << @active_fontface_rule
|
110
|
+
end
|
111
|
+
|
112
|
+
def end_fontface_rule
|
113
|
+
@active_fontface_rule = nil
|
114
|
+
end
|
83
115
|
end
|
84
116
|
end
|
85
117
|
end
|
@@ -19,11 +19,6 @@ 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
|
-
# 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
|
27
22
|
new_doc
|
28
23
|
end
|
29
24
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module CSSPool
|
2
|
+
module CSS
|
3
|
+
class MediaFeature < CSSPool::Node
|
4
|
+
attr_accessor :property, :value
|
5
|
+
attr_accessor :parse_location
|
6
|
+
|
7
|
+
def initialize(property, value, parse_location = {})
|
8
|
+
@property = property
|
9
|
+
@value = value
|
10
|
+
@parse_location = parse_location
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module CSSPool
|
2
|
+
module CSS
|
3
|
+
class MediaQuery < CSSPool::Node
|
4
|
+
attr_accessor :only_or_not, :media_expr, :and_exprs
|
5
|
+
attr_accessor :parse_location
|
6
|
+
|
7
|
+
def self.empty
|
8
|
+
new(nil, nil, [])
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(only_or_not, media_expr, and_exprs, parse_location = {})
|
12
|
+
@only_or_not = only_or_not
|
13
|
+
@media_expr = media_expr
|
14
|
+
@and_exprs = and_exprs
|
15
|
+
@parse_location = parse_location
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module CSSPool
|
2
|
+
module CSS
|
3
|
+
class MediaQueryList < CSSPool::Node
|
4
|
+
attr_accessor :media_queries, :parse_location, :rule_sets
|
5
|
+
|
6
|
+
def initialize(media_queries = [], parse_location = {})
|
7
|
+
@media_queries = media_queries
|
8
|
+
@parse_location = parse_location
|
9
|
+
@rule_sets = []
|
10
|
+
end
|
11
|
+
|
12
|
+
def <<(media_query)
|
13
|
+
media_queries << media_query
|
14
|
+
self
|
15
|
+
end
|
16
|
+
alias push <<
|
17
|
+
|
18
|
+
def length
|
19
|
+
media_queries.length
|
20
|
+
end
|
21
|
+
alias size length
|
22
|
+
|
23
|
+
def first
|
24
|
+
media_queries.first
|
25
|
+
end
|
26
|
+
|
27
|
+
def last
|
28
|
+
media_queries.last
|
29
|
+
end
|
30
|
+
|
31
|
+
def [](idx)
|
32
|
+
media_queries[idx]
|
33
|
+
end
|
34
|
+
|
35
|
+
def inspect
|
36
|
+
media_queries.inspect
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -1,15 +1,17 @@
|
|
1
1
|
module CSSPool
|
2
2
|
module CSS
|
3
|
-
class
|
4
|
-
attr_accessor :
|
3
|
+
class MediaType < CSSPool::Node
|
4
|
+
attr_accessor :name
|
5
5
|
attr_accessor :parse_location
|
6
6
|
attr_accessor :rule_sets
|
7
7
|
|
8
|
-
def initialize
|
9
|
-
@
|
8
|
+
def initialize(name, parse_location = {})
|
9
|
+
@name = name
|
10
10
|
@parse_location = parse_location
|
11
11
|
@rule_sets = []
|
12
12
|
end
|
13
|
+
|
14
|
+
alias value name
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|