crass 1.0.4 → 1.0.6
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 +4 -4
- data/.travis.yml +8 -5
- data/HISTORY.md +15 -0
- data/LICENSE +1 -1
- data/README.md +0 -22
- data/crass.gemspec +8 -2
- data/lib/crass/tokenizer.rb +32 -13
- data/lib/crass/version.rb +1 -1
- metadata +9 -66
- data/test/css-parsing-tests/An+B.json +0 -156
- data/test/css-parsing-tests/LICENSE +0 -8
- data/test/css-parsing-tests/README.rst +0 -301
- data/test/css-parsing-tests/color3.json +0 -142
- data/test/css-parsing-tests/color3_hsl.json +0 -3890
- data/test/css-parsing-tests/color3_keywords.json +0 -803
- data/test/css-parsing-tests/component_value_list.json +0 -432
- data/test/css-parsing-tests/declaration_list.json +0 -44
- data/test/css-parsing-tests/make_color3_hsl.py +0 -17
- data/test/css-parsing-tests/make_color3_keywords.py +0 -191
- data/test/css-parsing-tests/one_component_value.json +0 -27
- data/test/css-parsing-tests/one_declaration.json +0 -46
- data/test/css-parsing-tests/one_rule.json +0 -36
- data/test/css-parsing-tests/rule_list.json +0 -48
- data/test/css-parsing-tests/stylesheet.json +0 -44
- data/test/css-parsing-tests/stylesheet_bytes.json +0 -146
- data/test/shared/parse_rules.rb +0 -463
- data/test/support/common.rb +0 -170
- data/test/support/serialization/animate.css +0 -3158
- data/test/support/serialization/bootstrap-theme.css +0 -384
- data/test/support/serialization/bootstrap.css +0 -6805
- data/test/support/serialization/html5-boilerplate.css +0 -268
- data/test/support/serialization/misc.css +0 -9
- data/test/support/serialization/pure.css +0 -1662
- data/test/test_crass.rb +0 -31
- data/test/test_css_parsing_tests.rb +0 -150
- data/test/test_parse_properties.rb +0 -310
- data/test/test_parse_rules.rb +0 -17
- data/test/test_parse_stylesheet.rb +0 -17
- data/test/test_serialization.rb +0 -71
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: def285e9f3d16e7222dce13f004b8ad8b936c76ecec909306cf15078f6ec8999
|
4
|
+
data.tar.gz: 6fbb08644b3ff290d66012bbfa9afa249ab565f9e67240e13d433715d1b535b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43daba64a022574e3ac4b439c5dca3cc329e2217e47df9eeaf79987748fa949feeaccb4745a212ebb9e91f01d4b5ec433947b57380efda233d078a9f1f1ea8ab
|
7
|
+
data.tar.gz: aa88544b1374fa5fb774970e5b714e6913c23e750a0e84767548e9c8076d25851f9f8861b38dfef0c9262a8c7785bce82436ad19c951ea4a9836fcee4a163199
|
data/.travis.yml
CHANGED
data/HISTORY.md
CHANGED
@@ -1,6 +1,21 @@
|
|
1
1
|
Crass Change History
|
2
2
|
====================
|
3
3
|
|
4
|
+
1.0.6 (2020-01-12)
|
5
|
+
------------------
|
6
|
+
|
7
|
+
* Number values are now limited to a maximum of `Float::MAX` and a minimum of
|
8
|
+
negative `Float::MAX`. (#11)
|
9
|
+
|
10
|
+
* Added project metadata to the gemspec. (#9 - @orien)
|
11
|
+
|
12
|
+
|
13
|
+
1.0.5 (2019-10-15)
|
14
|
+
------------------
|
15
|
+
|
16
|
+
* Removed test files from the gem. (#8 - @t-richards)
|
17
|
+
|
18
|
+
|
4
19
|
1.0.4 (2018-04-08)
|
5
20
|
------------------
|
6
21
|
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -190,25 +190,3 @@ tokenizing and parsing rules that Crass implements.
|
|
190
190
|
[simon]:http://exyr.org/about/
|
191
191
|
[spec]:http://www.w3.org/TR/css-syntax-3/
|
192
192
|
[tab]:http://www.xanthir.com/contact/
|
193
|
-
|
194
|
-
License
|
195
|
-
-------
|
196
|
-
|
197
|
-
Copyright (c) 2017 Ryan Grove (ryan@wonko.com)
|
198
|
-
|
199
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
200
|
-
this software and associated documentation files (the ‘Software’), to deal in
|
201
|
-
the Software without restriction, including without limitation the rights to
|
202
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
203
|
-
the Software, and to permit persons to whom the Software is furnished to do so,
|
204
|
-
subject to the following conditions:
|
205
|
-
|
206
|
-
The above copyright notice and this permission notice shall be included in all
|
207
|
-
copies or substantial portions of the Software.
|
208
|
-
|
209
|
-
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
210
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
211
|
-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
212
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
213
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
214
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/crass.gemspec
CHANGED
@@ -11,13 +11,19 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.homepage = 'https://github.com/rgrove/crass/'
|
12
12
|
s.license = 'MIT'
|
13
13
|
|
14
|
+
s.metadata = {
|
15
|
+
'bug_tracker_uri' => 'https://github.com/rgrove/crass/issues',
|
16
|
+
'changelog_uri' => "https://github.com/rgrove/crass/blob/v#{s.version}/HISTORY.md",
|
17
|
+
'documentation_uri' => "https://www.rubydoc.info/gems/crass/#{s.version}",
|
18
|
+
'source_code_uri' => "https://github.com/rgrove/crass/tree/v#{s.version}",
|
19
|
+
}
|
20
|
+
|
14
21
|
s.platform = Gem::Platform::RUBY
|
15
22
|
s.required_ruby_version = Gem::Requirement.new('>= 1.9.2')
|
16
23
|
|
17
24
|
s.require_paths = ['lib']
|
18
25
|
|
19
|
-
s.files
|
20
|
-
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
26
|
+
s.files = `git ls-files -z`.split("\x0").grep_v(%r{^test/})
|
21
27
|
|
22
28
|
# Development dependencies.
|
23
29
|
s.add_development_dependency 'minitest', '~> 5.0.8'
|
data/lib/crass/tokenizer.rb
CHANGED
@@ -429,27 +429,36 @@ module Crass
|
|
429
429
|
# 4.3.3. http://dev.w3.org/csswg/css-syntax/#consume-a-numeric-token
|
430
430
|
def consume_numeric
|
431
431
|
number = consume_number
|
432
|
+
repr = number[0]
|
433
|
+
value = number[1]
|
434
|
+
type = number[2]
|
435
|
+
|
436
|
+
if type == :integer
|
437
|
+
value = value.to_i
|
438
|
+
else
|
439
|
+
value = value.to_f
|
440
|
+
end
|
432
441
|
|
433
442
|
if start_identifier?(@s.peek(3))
|
434
443
|
create_token(:dimension,
|
435
|
-
:repr
|
436
|
-
:type
|
437
|
-
:unit
|
438
|
-
:value =>
|
444
|
+
:repr => repr,
|
445
|
+
:type => type,
|
446
|
+
:unit => consume_name,
|
447
|
+
:value => value)
|
439
448
|
|
440
449
|
elsif @s.peek == '%'
|
441
450
|
@s.consume
|
442
451
|
|
443
452
|
create_token(:percentage,
|
444
|
-
:repr
|
445
|
-
:type
|
446
|
-
:value =>
|
453
|
+
:repr => repr,
|
454
|
+
:type => type,
|
455
|
+
:value => value)
|
447
456
|
|
448
457
|
else
|
449
458
|
create_token(:number,
|
450
|
-
:repr
|
451
|
-
:type
|
452
|
-
:value =>
|
459
|
+
:repr => repr,
|
460
|
+
:type => type,
|
461
|
+
:value => value)
|
453
462
|
end
|
454
463
|
end
|
455
464
|
|
@@ -588,9 +597,19 @@ module Crass
|
|
588
597
|
t = matches[:exponent_sign] == '-' ? -1 : 1
|
589
598
|
e = matches[:exponent].to_i
|
590
599
|
|
591
|
-
# I know this looks nutty, but it's exactly what's defined in the
|
592
|
-
# and it works.
|
593
|
-
s * (i + f * 10**-d) * 10**(t * e)
|
600
|
+
# I know this formula looks nutty, but it's exactly what's defined in the
|
601
|
+
# spec, and it works.
|
602
|
+
value = s * (i + f * 10**-d) * 10**(t * e)
|
603
|
+
|
604
|
+
# Maximum and minimum values aren't defined in the spec, but are enforced
|
605
|
+
# here for sanity.
|
606
|
+
if value > Float::MAX
|
607
|
+
value = Float::MAX
|
608
|
+
elsif value < -Float::MAX
|
609
|
+
value = -Float::MAX
|
610
|
+
end
|
611
|
+
|
612
|
+
value
|
594
613
|
end
|
595
614
|
|
596
615
|
# Creates and returns a new token with the given _properties_.
|
data/lib/crass/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Grove
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -60,40 +60,14 @@ files:
|
|
60
60
|
- lib/crass/token-scanner.rb
|
61
61
|
- lib/crass/tokenizer.rb
|
62
62
|
- lib/crass/version.rb
|
63
|
-
- test/css-parsing-tests/An+B.json
|
64
|
-
- test/css-parsing-tests/LICENSE
|
65
|
-
- test/css-parsing-tests/README.rst
|
66
|
-
- test/css-parsing-tests/color3.json
|
67
|
-
- test/css-parsing-tests/color3_hsl.json
|
68
|
-
- test/css-parsing-tests/color3_keywords.json
|
69
|
-
- test/css-parsing-tests/component_value_list.json
|
70
|
-
- test/css-parsing-tests/declaration_list.json
|
71
|
-
- test/css-parsing-tests/make_color3_hsl.py
|
72
|
-
- test/css-parsing-tests/make_color3_keywords.py
|
73
|
-
- test/css-parsing-tests/one_component_value.json
|
74
|
-
- test/css-parsing-tests/one_declaration.json
|
75
|
-
- test/css-parsing-tests/one_rule.json
|
76
|
-
- test/css-parsing-tests/rule_list.json
|
77
|
-
- test/css-parsing-tests/stylesheet.json
|
78
|
-
- test/css-parsing-tests/stylesheet_bytes.json
|
79
|
-
- test/shared/parse_rules.rb
|
80
|
-
- test/support/common.rb
|
81
|
-
- test/support/serialization/animate.css
|
82
|
-
- test/support/serialization/bootstrap-theme.css
|
83
|
-
- test/support/serialization/bootstrap.css
|
84
|
-
- test/support/serialization/html5-boilerplate.css
|
85
|
-
- test/support/serialization/misc.css
|
86
|
-
- test/support/serialization/pure.css
|
87
|
-
- test/test_crass.rb
|
88
|
-
- test/test_css_parsing_tests.rb
|
89
|
-
- test/test_parse_properties.rb
|
90
|
-
- test/test_parse_rules.rb
|
91
|
-
- test/test_parse_stylesheet.rb
|
92
|
-
- test/test_serialization.rb
|
93
63
|
homepage: https://github.com/rgrove/crass/
|
94
64
|
licenses:
|
95
65
|
- MIT
|
96
|
-
metadata:
|
66
|
+
metadata:
|
67
|
+
bug_tracker_uri: https://github.com/rgrove/crass/issues
|
68
|
+
changelog_uri: https://github.com/rgrove/crass/blob/v1.0.6/HISTORY.md
|
69
|
+
documentation_uri: https://www.rubydoc.info/gems/crass/1.0.6
|
70
|
+
source_code_uri: https://github.com/rgrove/crass/tree/v1.0.6
|
97
71
|
post_install_message:
|
98
72
|
rdoc_options: []
|
99
73
|
require_paths:
|
@@ -109,39 +83,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
83
|
- !ruby/object:Gem::Version
|
110
84
|
version: '0'
|
111
85
|
requirements: []
|
112
|
-
|
113
|
-
rubygems_version: 2.7.3
|
86
|
+
rubygems_version: 3.0.3
|
114
87
|
signing_key:
|
115
88
|
specification_version: 4
|
116
89
|
summary: CSS parser based on the CSS Syntax Level 3 spec.
|
117
|
-
test_files:
|
118
|
-
- test/css-parsing-tests/An+B.json
|
119
|
-
- test/css-parsing-tests/LICENSE
|
120
|
-
- test/css-parsing-tests/README.rst
|
121
|
-
- test/css-parsing-tests/color3.json
|
122
|
-
- test/css-parsing-tests/color3_hsl.json
|
123
|
-
- test/css-parsing-tests/color3_keywords.json
|
124
|
-
- test/css-parsing-tests/component_value_list.json
|
125
|
-
- test/css-parsing-tests/declaration_list.json
|
126
|
-
- test/css-parsing-tests/make_color3_hsl.py
|
127
|
-
- test/css-parsing-tests/make_color3_keywords.py
|
128
|
-
- test/css-parsing-tests/one_component_value.json
|
129
|
-
- test/css-parsing-tests/one_declaration.json
|
130
|
-
- test/css-parsing-tests/one_rule.json
|
131
|
-
- test/css-parsing-tests/rule_list.json
|
132
|
-
- test/css-parsing-tests/stylesheet.json
|
133
|
-
- test/css-parsing-tests/stylesheet_bytes.json
|
134
|
-
- test/shared/parse_rules.rb
|
135
|
-
- test/support/common.rb
|
136
|
-
- test/support/serialization/animate.css
|
137
|
-
- test/support/serialization/bootstrap-theme.css
|
138
|
-
- test/support/serialization/bootstrap.css
|
139
|
-
- test/support/serialization/html5-boilerplate.css
|
140
|
-
- test/support/serialization/misc.css
|
141
|
-
- test/support/serialization/pure.css
|
142
|
-
- test/test_crass.rb
|
143
|
-
- test/test_css_parsing_tests.rb
|
144
|
-
- test/test_parse_properties.rb
|
145
|
-
- test/test_parse_rules.rb
|
146
|
-
- test/test_parse_stylesheet.rb
|
147
|
-
- test/test_serialization.rb
|
90
|
+
test_files: []
|
@@ -1,156 +0,0 @@
|
|
1
|
-
[
|
2
|
-
|
3
|
-
"", null,
|
4
|
-
" \n", null,
|
5
|
-
|
6
|
-
"odd", [2, 1],
|
7
|
-
"even", [2, 0],
|
8
|
-
"ödd", null,
|
9
|
-
"éven", null,
|
10
|
-
" /**/\t OdD /**/\n", [2, 1],
|
11
|
-
" /**/\t EveN /**/\n", [2, 0],
|
12
|
-
|
13
|
-
|
14
|
-
"3", [0, 3],
|
15
|
-
"+2 ", [0, 2],
|
16
|
-
" -14 ", [0, -14],
|
17
|
-
"+ 2 ", null,
|
18
|
-
"- 14 ", null,
|
19
|
-
"3.1", null,
|
20
|
-
|
21
|
-
"3N", [3, 0],
|
22
|
-
"+2N ", [2, 0],
|
23
|
-
" -14n ", [-14, 0],
|
24
|
-
"+ 2N ", null,
|
25
|
-
"- 14N ", null,
|
26
|
-
"3.1N", null,
|
27
|
-
"3 n", null,
|
28
|
-
|
29
|
-
" N", [1, 0],
|
30
|
-
" +n", [1, 0],
|
31
|
-
" -n", [-1, 0],
|
32
|
-
"+ n", null,
|
33
|
-
"- n", null,
|
34
|
-
|
35
|
-
|
36
|
-
"3N+1", [3, 1],
|
37
|
-
"+2n+1 ", [2, 1],
|
38
|
-
" -14n+1 ", [-14, 1],
|
39
|
-
"+ 2N+1 ", null,
|
40
|
-
"- 14n+1 ", null,
|
41
|
-
"3.1n+1", null,
|
42
|
-
"3 n+1", null,
|
43
|
-
|
44
|
-
" n+1", [1, 1],
|
45
|
-
" +N+1", [1, 1],
|
46
|
-
" -n+1", [-1, 1],
|
47
|
-
"+ N+1", null,
|
48
|
-
"- N+1", null,
|
49
|
-
|
50
|
-
"3n-1", [3, -1],
|
51
|
-
"+2N-1 ", [2, -1],
|
52
|
-
" -14n-1 ", [-14, -1],
|
53
|
-
"+ 2N-1 ", null,
|
54
|
-
"- 14N-1 ", null,
|
55
|
-
"3.1n-1", null,
|
56
|
-
"3 n-1", null,
|
57
|
-
"3n-1foo", null,
|
58
|
-
|
59
|
-
" n-1", [1, -1],
|
60
|
-
" +n-1", [1, -1],
|
61
|
-
" -n-1", [-1, -1],
|
62
|
-
"+ n-1", null,
|
63
|
-
"- n-1", null,
|
64
|
-
" +n-1foo", null,
|
65
|
-
" -n-1foo", null,
|
66
|
-
|
67
|
-
|
68
|
-
"3N +1", [3, 1],
|
69
|
-
"+2N +1 ", [2, 1],
|
70
|
-
" -14n +1 ", [-14, 1],
|
71
|
-
"+ 2N +1 ", null,
|
72
|
-
"- 14n +1 ", null,
|
73
|
-
"3.1N +1", null,
|
74
|
-
"3 n +1", null,
|
75
|
-
"3n foo", null,
|
76
|
-
"3n + foo", null,
|
77
|
-
|
78
|
-
" n +1", [1, 1],
|
79
|
-
" +N +1", [1, 1],
|
80
|
-
" -n +1", [-1, 1],
|
81
|
-
"+ n +1", null,
|
82
|
-
"- N +1", null,
|
83
|
-
|
84
|
-
"3N -1", [3, -1],
|
85
|
-
"+2n -1 ", [2, -1],
|
86
|
-
" -14n -1 ", [-14, -1],
|
87
|
-
"+ 2n -1 ", null,
|
88
|
-
"- 14N -1 ", null,
|
89
|
-
"3.1N -1", null,
|
90
|
-
"3 N -1", null,
|
91
|
-
|
92
|
-
" N -1", [1, -1],
|
93
|
-
" +N -1", [1, -1],
|
94
|
-
" -n -1", [-1, -1],
|
95
|
-
"+ n -1", null,
|
96
|
-
"- n -1", null,
|
97
|
-
|
98
|
-
|
99
|
-
"3n+ 1", [3, 1],
|
100
|
-
"+2n+ 1 ", [2, 1],
|
101
|
-
" -14n+ 1 ", [-14, 1],
|
102
|
-
"+ 2n+ 1 ", null,
|
103
|
-
"- 14N+ 1 ", null,
|
104
|
-
"3.1n+ 1", null,
|
105
|
-
"3 N+ 1", null,
|
106
|
-
|
107
|
-
" N+ 1", [1, 1],
|
108
|
-
" +N+ 1", [1, 1],
|
109
|
-
" -N+ 1", [-1, 1],
|
110
|
-
"+ n+ 1", null,
|
111
|
-
"- N+ 1", null,
|
112
|
-
|
113
|
-
"3n- 1", [3, -1],
|
114
|
-
"+2N- 1 ", [2, -1],
|
115
|
-
" -14N- 1 ", [-14, -1],
|
116
|
-
"+ 2N- 1 ", null,
|
117
|
-
"- 14n- 1 ", null,
|
118
|
-
"3.1n- 1", null,
|
119
|
-
"3 n- 1", null,
|
120
|
-
|
121
|
-
" N- 1", [1, -1],
|
122
|
-
" +N- 1", [1, -1],
|
123
|
-
" -n- 1", [-1, -1],
|
124
|
-
"+ n- 1", null,
|
125
|
-
"- N- 1", null,
|
126
|
-
|
127
|
-
|
128
|
-
"3N + 1", [3, 1],
|
129
|
-
"+2N + 1 ", [2, 1],
|
130
|
-
" -14n + 1 ", [-14, 1],
|
131
|
-
"+ 2n + 1 ", null,
|
132
|
-
"- 14N + 1 ", null,
|
133
|
-
"3.1n + 1", null,
|
134
|
-
"3 N + 1", null,
|
135
|
-
|
136
|
-
" n + 1", [1, 1],
|
137
|
-
" +n + 1", [1, 1],
|
138
|
-
" -N + 1", [-1, 1],
|
139
|
-
"+ N + 1", null,
|
140
|
-
"- N + 1", null,
|
141
|
-
|
142
|
-
"3N - 1", [3, -1],
|
143
|
-
"+2n - 1 ", [2, -1],
|
144
|
-
" -14n - 1 ", [-14, -1],
|
145
|
-
"+ 2N - 1 ", null,
|
146
|
-
"- 14N - 1 ", null,
|
147
|
-
"3.1N - 1", null,
|
148
|
-
"3 n - 1", null,
|
149
|
-
|
150
|
-
" N - 1", [1, -1],
|
151
|
-
" +n - 1", [1, -1],
|
152
|
-
" -n - 1", [-1, -1],
|
153
|
-
"+ N - 1", null,
|
154
|
-
"- N - 1", null
|
155
|
-
|
156
|
-
]
|