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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e83f7576f73a2cf226d0daaf3175bd8e8ffe9a6a
4
- data.tar.gz: ff07aef3047cd2e8cd257f307c2c3908f8782582
3
+ metadata.gz: 7870883a1448bb39dcff1dcbb3eb4c6736999d07
4
+ data.tar.gz: 1adfcdbfbf8ff6c45d5e6e682502f1b5377b06d2
5
5
  SHA512:
6
- metadata.gz: b418225b008b5850fae00431a4bdeb493594c86fb073399099ffe8e7fc1e57e0d2a317f56fc02b173d25f559eb57ee73553d78c6f115dedc54020d256565cae6
7
- data.tar.gz: 1f37d0a034d1db5caced9920e6b7b4f1159a1e70d446bbe2191927335c3d315c02616432b6720ccbffe55008eecc360df9f399e20fbc1fedf336e5e042818d19
6
+ metadata.gz: 4ec908933d4cbc9fa6c51627cf940c7c15824f8768030b70c3580e4afae3b888c1e10c9a8466c9a87821dd3ad566fe7866f4973d045276dc43b56881d567fbb3
7
+ data.tar.gz: be25bdc14bce1a42302c2b440422713727a84a036162133f22f81a50df0db44202ffe3993092fcc1d9cce2e968f39cda829bccde4dba26af92657ace679583e4
@@ -1,5 +1,5 @@
1
1
  module CssCompare
2
2
  # The root directory of the Less2Sass source tree.
3
3
  ROOT_DIR = File.expand_path(File.join(__FILE__, '../../..'))
4
- VERSION = '0.1.2'.freeze
4
+ VERSION = '0.1.3'.freeze
5
5
  end
@@ -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.2
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-20 00:00:00.000000000 Z
11
+ date: 2016-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sass