compass-selector-warn 0.1

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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +17 -0
  3. data/lib/compass-selector-warn.rb +41 -0
  4. metadata +60 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ab51e66e5fe43880ffd4945706ab0ecdb542818d
4
+ data.tar.gz: 172b9c81f42e0326b62d55ed582adb39e6d0fde3
5
+ SHA512:
6
+ metadata.gz: e551087cb331fa5114f7c6fd8e906364fc80b7ca84d5b8c8c83358cd0bda0f4b876b9bd30a20723aaadae274f612648c99c608f03d94a74d735402aa24932a6e
7
+ data.tar.gz: 97bd1c870e403fa4ccaa809cbb90cc3238431a5f922f3e2b0208d4c8953f9c3c9af2ee6b1c24e3e3204b0e91b9171b6f23ba605a0bc976efbc9374d645f55dbf
data/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # compass-selector-warn
2
+ ============
3
+
4
+ This is a [compass](http://www.compass-style.org/ "compass") extension that warns you if you're using to many css selectors.
5
+
6
+ ## Installation
7
+ Just go to your terminal an type this
8
+
9
+ sudo gem install compass-selector-warn
10
+
11
+ ## How to use
12
+ In your compass config file add this line
13
+
14
+ require "compass-selector-warn"
15
+
16
+ ## Note
17
+ This is one of my first compass extension, so if you have some annotations don't hesitate and write it here.
@@ -0,0 +1,41 @@
1
+ # REQUIREMENTS
2
+ require 'compass'
3
+ require 'css_parser'
4
+
5
+ # INCLUDES
6
+ include CssParser
7
+
8
+ # EXDENDS
9
+ extend Compass::Actions
10
+
11
+ # SET LOGGER COLOR
12
+ Compass::Logger::ACTION_COLORS[:"too many selectors"] = :red
13
+
14
+ # CUSTOM VARS
15
+ max_sel_count = 4096
16
+ warning_txt = "\n\tAccording to IE 6-9 architecture, maximum number of CSS selectors in one file is #{max_sel_count}."
17
+
18
+ # Relativizing a path requires us to specify the working path.
19
+ def working_path
20
+ Dir.pwd
21
+ end
22
+
23
+ # CREATE THE PARSER
24
+ Compass.configuration.on_stylesheet_saved do |css_file|
25
+ contents = File.read(css_file)
26
+ parser = CssParser::Parser.new
27
+ parser.add_block!(contents)
28
+ selector_count = 0
29
+ prop_count = 0
30
+
31
+ parser.each_selector do |selector, declarations, specificity|
32
+ sels = selector.split(/,/).size
33
+ props = declarations.split(/;/).size
34
+ selector_count += sels
35
+ prop_count += props
36
+ end
37
+
38
+ if selector_count > max_sel_count
39
+ Compass::Logger.new.record(:"too many selectors", " => #{selector_count} => in file #{relativize(css_file)}" + warning_txt)
40
+ end
41
+ end
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: compass-selector-warn
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Tino Wehe
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-01-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: compass
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.12.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.12.2
27
+ description: compass extension that warns you if you're using to many css selectors
28
+ email: tino.wehe@brandrockers.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - README.md
34
+ - lib/compass-selector-warn.rb
35
+ homepage: https://github.com/pixel-shock/compass-selector-warn
36
+ licenses:
37
+ - MIT
38
+ metadata: {}
39
+ post_install_message: "\n\tThanks for installing compass-selector-warn!\n\tJust add\n\t\trequire
40
+ \"compass-selector-warn\"\n\tto your compass config file and enjoy!\n\n"
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubyforge_project:
56
+ rubygems_version: 2.0.3
57
+ signing_key:
58
+ specification_version: 4
59
+ summary: compass extension that warns you if you're using to many css selectors
60
+ test_files: []