scrap-css 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/scrap_css.rb +9 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abe2d347ff1d32ac9e038aa80161c9bcb26a8756
|
4
|
+
data.tar.gz: d8dcfdb2db58f17ebb3b30a1b0f502030a05a7c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d9d809eb8c62c213b2764e7e94df02e2fdf706b9a03864a0eb4babc92e137f20a4a1725b673ea4ff53c3c48ebfb230e638b0226d918c4a460788b7d61af8d08
|
7
|
+
data.tar.gz: cd35ac2549667d8f0281d82665cf769679bcca7b02e42f7d3905f6270609c3df59c5cb186fee3f1eac5702fe341fa7ada95c5a7e0cdb54106a366957dd531465
|
data/lib/scrap_css.rb
CHANGED
@@ -38,28 +38,27 @@ end
|
|
38
38
|
class ScrapCss::Css
|
39
39
|
def initialize(path="")
|
40
40
|
@file_lines ||= IO.readlines(path)
|
41
|
-
@
|
41
|
+
@css_parts = @file_lines.join("").split("\n\n")
|
42
|
+
@css_parts_used = []
|
42
43
|
end
|
43
44
|
|
44
45
|
def select_css(css_clases_useds)
|
45
|
-
|
46
|
-
|
47
|
-
if ScrapCss::Css.str_contain_css(
|
48
|
-
@css_clases_used << get_css_class(index, index_close_tag(index))
|
49
|
-
end
|
46
|
+
css_clases_useds.each do |css_clase|
|
47
|
+
@css_parts.each do |css_part|
|
48
|
+
@css_parts_used << css_part if ScrapCss::Css.str_contain_css(css_part, css_clase)
|
50
49
|
end
|
51
|
-
|
52
|
-
@
|
50
|
+
end
|
51
|
+
@css_parts_used.uniq
|
53
52
|
end
|
54
53
|
|
55
54
|
def save_select_css
|
56
55
|
File.open("output.css", 'w+') do |file|
|
57
|
-
@
|
56
|
+
@css_parts_used.each{|css_clase_used| file.write("#{css_clase_used}\n\n") }
|
58
57
|
end
|
59
58
|
end
|
60
59
|
|
61
60
|
def self.str_contain_css(str, css_class)
|
62
|
-
str.include?(".#{css_class} ") || str.include?(".#{css_class}.")
|
61
|
+
str.include?(".#{css_class} ") || str.include?(".#{css_class}.") || str.include?(".#{css_class}:")
|
63
62
|
end
|
64
63
|
|
65
64
|
def get_css_class(first_line, last_line)
|