css_counter 0.0.1 → 0.0.2

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: c98217fa8af20c35dcf512f7b84c759f7394b11f
4
- data.tar.gz: 7a34b9593ac9838a09b71c29e85b50770fc21b1e
3
+ metadata.gz: d29466a22fbcba30013eb4e93c7b52ac8ab2f7f9
4
+ data.tar.gz: 5e46547c7b27fc99ac7a9cc5c1cde88ca2e9195b
5
5
  SHA512:
6
- metadata.gz: 19e4b7c4ed115c746306525fd34b4c74fb93c9062a86272690d58896babf19f59a43a1b2cba97f6e84ce4403928db0648b88acc2d22521254464746c289b3e12
7
- data.tar.gz: 0d03040c15af2b811b4d91a98ec4cab0e9ee99bba31dd03e604e4c2d464d2197c379b2f6b448c81d4490754340e83a4707db69cc24bdaa2099e9808b0a562832
6
+ metadata.gz: f737014b43feac1c75bb6d190a4f13f8052291c7c9bd7e90cd9fe9d37e32a5719a621641f5d26c216365fbac6ff328987c5508c3ef3c64cbea67fad9fa3a5478
7
+ data.tar.gz: 72f6f09383d8386b86277e8792cbb8d20241e5137526a073013e0209b8838808641b9a5fba9df99bbd5b82678c367e879b9c059744b11d6b67d08871015bba19
data/CHANGELOG CHANGED
@@ -1,2 +1,5 @@
1
+ v0.0.2 (14th February 2013)
2
+ * added a rake task for checking the CSS selector count from rails
3
+
1
4
  v0.0.1 (14th February 2013)
2
5
  * initial release
data/README.rdoc CHANGED
@@ -19,3 +19,11 @@ selector limit imposed by Internet Explorer 9 and lower.
19
19
  CssCounter.new(css).selectors
20
20
  => 2
21
21
 
22
+ == Rails
23
+
24
+ To ensure none of the compiled CSS files in your rails app exceed the IE selector limit,
25
+ there's a rake task you can run as part of a build process.
26
+
27
+ Add css_counter to your application Gemfile, and then run:
28
+
29
+ bundle exec rake css_counter:check_selectors
data/lib/css_counter.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'crass'
2
- require 'ir_b'
2
+ require 'css_counter/railtie' if defined?(Rails)
3
3
 
4
4
  class CssCounter
5
5
 
@@ -0,0 +1,23 @@
1
+ IE_SELECTOR_LIMIT = 4095
2
+
3
+ namespace :css_counter do
4
+ task default: :check_selectors
5
+
6
+ desc "Ensure no compiled CSS file has more than 4095 selectors"
7
+ task check_selectors: [:environment] do
8
+ sprockets = Rails.application.assets
9
+
10
+ css_paths = %w{application.css}
11
+ css_paths += Rails.application.config.assets.precompile.select { |item|
12
+ item.is_a?(String) && item[-4,4] == ".css"
13
+ }
14
+ css_paths.each do |path|
15
+ css = sprockets[path].body
16
+ selector_count = CssCounter.new(css).selectors
17
+ if selector_count > IE_SELECTOR_LIMIT
18
+ $stderr.puts "#{path} has #{selector_count} CSS selectors, must not exceed #{IE_SELECTOR_LIMIT}"
19
+ exit(1)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,9 @@
1
+ class CssCounter
2
+ class Railtie < Rails::Railtie
3
+ railtie_name :css_counter
4
+
5
+ rake_tasks do
6
+ load "css_counter/css_counter.rake"
7
+ end
8
+ end
9
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: css_counter
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
  - James Healy
@@ -63,6 +63,8 @@ files:
63
63
  - MIT-LICENSE
64
64
  - README.rdoc
65
65
  - lib/css_counter.rb
66
+ - lib/css_counter/css_counter.rake
67
+ - lib/css_counter/railtie.rb
66
68
  - spec/css_counter_spec.rb
67
69
  homepage: http://github.com/yob/css_counter
68
70
  licenses: