css_compare 0.1.2 → 0.1.3
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/lib/css_compare/constants.rb +1 -1
- data/lib/css_compare/css/component/value.rb +26 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7870883a1448bb39dcff1dcbb3eb4c6736999d07
|
|
4
|
+
data.tar.gz: 1adfcdbfbf8ff6c45d5e6e682502f1b5377b06d2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4ec908933d4cbc9fa6c51627cf940c7c15824f8768030b70c3580e4afae3b888c1e10c9a8466c9a87821dd3ad566fe7866f4973d045276dc43b56881d567fbb3
|
|
7
|
+
data.tar.gz: be25bdc14bce1a42302c2b440422713727a84a036162133f22f81a50df0db44202ffe3993092fcc1d9cce2e968f39cda829bccde4dba26af92657ace679583e4
|
|
@@ -31,6 +31,7 @@ module CssCompare
|
|
|
31
31
|
# Can't do gsub! because the String gets frozen and can't be further modified by strip
|
|
32
32
|
value = value.gsub(/\s*!important\s*/, '')
|
|
33
33
|
@is_important = value != original_value
|
|
34
|
+
value = sanitize_value(value) if value =~ CONTAIN_STRING
|
|
34
35
|
@value = value
|
|
35
36
|
end
|
|
36
37
|
|
|
@@ -45,6 +46,31 @@ module CssCompare
|
|
|
45
46
|
def to_s
|
|
46
47
|
@value.to_s + (@is_important ? ' !important' : '')
|
|
47
48
|
end
|
|
49
|
+
|
|
50
|
+
private
|
|
51
|
+
|
|
52
|
+
CONTAIN_STRING = /['"](.*)['"]/
|
|
53
|
+
|
|
54
|
+
# Normalizes string values.
|
|
55
|
+
#
|
|
56
|
+
# We can assume, that a value describes a path
|
|
57
|
+
# if following the removal of leading and trailing
|
|
58
|
+
# quotes it begins with a `./`. It can be safely
|
|
59
|
+
# removed without affecting the real value of
|
|
60
|
+
# the CSS property.
|
|
61
|
+
#
|
|
62
|
+
# Examples:
|
|
63
|
+
# "'path/to/file.css'" #=> "path/to/file.css"
|
|
64
|
+
# ""\"path/to/file.css\""" #=> ""path/to/file.css""
|
|
65
|
+
# "./path/to/file.css" #=> "path/to/file.css"
|
|
66
|
+
#
|
|
67
|
+
# @param [String] value the string to sanitize
|
|
68
|
+
# @return [String] sanitized string
|
|
69
|
+
def sanitize_value(value)
|
|
70
|
+
value = value.sub(/\A['"](.*)['"]\Z/, '\1').gsub(/\\"|"|'/, '"') # Solves first two examples
|
|
71
|
+
value = value.sub('./', '') if value.start_with?('url(') # Solves third if it's a url value
|
|
72
|
+
value
|
|
73
|
+
end
|
|
48
74
|
end
|
|
49
75
|
end
|
|
50
76
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: css_compare
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Attila Večerek
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-04-
|
|
11
|
+
date: 2016-04-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: sass
|