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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/scrap_css.rb +9 -10
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f4e49b7bb08f4c8f2d4d381aa678b03acaf5e676
4
- data.tar.gz: 008575496f5752b157e5ba7c136ea134420f3f45
3
+ metadata.gz: abe2d347ff1d32ac9e038aa80161c9bcb26a8756
4
+ data.tar.gz: d8dcfdb2db58f17ebb3b30a1b0f502030a05a7c1
5
5
  SHA512:
6
- metadata.gz: beca8e68c76ff26310a72e5465f37151dc839bba42c58fd2c25163b5946bb4742d2802c00d829af8fe17bdb8f51b03cd3ccf54461a5e5bc657371a4447ed4b7f
7
- data.tar.gz: 970bd99cef162068452290eb545ca24f4f5efb8bc1c3443d0b01fb5f057d8a3a11a62753aaa0b21e157085693da32ac999047b92fc06e727fdd895c2418680c9
6
+ metadata.gz: 0d9d809eb8c62c213b2764e7e94df02e2fdf706b9a03864a0eb4babc92e137f20a4a1725b673ea4ff53c3c48ebfb230e638b0226d918c4a460788b7d61af8d08
7
+ data.tar.gz: cd35ac2549667d8f0281d82665cf769679bcca7b02e42f7d3905f6270609c3df59c5cb186fee3f1eac5702fe341fa7ada95c5a7e0cdb54106a366957dd531465
@@ -38,28 +38,27 @@ end
38
38
  class ScrapCss::Css
39
39
  def initialize(path="")
40
40
  @file_lines ||= IO.readlines(path)
41
- @css_clases_used = []
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
- @file_lines.each_with_index do |file_line, index|
46
- css_clases_useds.each do |css_clase|
47
- if ScrapCss::Css.str_contain_css(file_line, css_clase)
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
- end
52
- @css_clases_used
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
- @css_clases_used.each{|css_clase_used| file.write(css_clase_used) }
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrap-css
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Savignano