strip_comments 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/strip_comments/version.rb +1 -1
- data/lib/strip_comments.rb +3 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ec13ae19f0156ef9323fae1380e5679e70fa2efa4a240f008fa4d826c34ffd5
|
4
|
+
data.tar.gz: 8e6aa63f575e1dcd62e94015097b4a2120be898cfc616b389aacf616e230b370
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05e804a98e1988694ca113afea91db5537017eb5fbea14ab1a09837332472a8beb793aec6ef5f0b90ebab2d153301dd8a63e1bcd095bad64bb1874442170b6be
|
7
|
+
data.tar.gz: 530a3af21c142bae70dcc776662b4cc4890d91e47a1956c1d4a30c8b9e7863b59b8202b843431d6a90a911cf1cc64ec4203f905279f7049335f73d97f80143e5
|
data/lib/strip_comments.rb
CHANGED
@@ -25,23 +25,21 @@ module StripComments
|
|
25
25
|
def self.strip_yaml(str)
|
26
26
|
stripped_strings_to_not_be_uncommented = {}
|
27
27
|
|
28
|
-
str.gsub!(/
|
28
|
+
str.gsub!(/"([^\n"]+)"/) do |m|
|
29
29
|
strip_key = "__STRIPPED_KEY_#{stripped_strings_to_not_be_uncommented.size}__"
|
30
30
|
stripped_strings_to_not_be_uncommented[strip_key] = m
|
31
|
-
puts "replacing '#{m}' with '#{strip_key}'"
|
32
31
|
strip_key
|
33
32
|
end
|
34
33
|
|
35
|
-
str.gsub!(/
|
34
|
+
str.gsub!(/'([^\n']+)'/) do |m|
|
36
35
|
strip_key = "__STRIPPED_KEY_#{stripped_strings_to_not_be_uncommented.size}__"
|
37
36
|
stripped_strings_to_not_be_uncommented[strip_key] = m
|
38
|
-
puts "replacing '#{m}' with '#{strip_key}'"
|
39
37
|
strip_key
|
40
38
|
end
|
41
39
|
|
42
40
|
str.gsub!(/#[^\n]+/, '')
|
43
41
|
|
44
|
-
stripped_strings_to_not_be_uncommented.
|
42
|
+
stripped_strings_to_not_be_uncommented.reverse_each do |k,v|
|
45
43
|
str[k] = v
|
46
44
|
end
|
47
45
|
|