wakoopa-bogus_sass_checker 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Justin Halsall
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,20 @@
1
+ Bogus Sass Checker
2
+ ===============
3
+
4
+ This is a little ruby script that checks your rails project's Sass files for #ids and .classes and checks if you are using them in the rest of your rails project.
5
+ ack needs to be installed first (http://petdance.com/ack/)
6
+
7
+ Example
8
+ =======
9
+ Navigate to your rails project root and run:
10
+ checksass
11
+
12
+ The output you receive are CSS classes and ids that probably aren't used in your rails project.
13
+
14
+ Contributing
15
+ ============
16
+
17
+ Git source repository: http://github.com/wakoopa/bogus-sass-checker/tree/master
18
+ Please feel free to fork the project at GitHub and submit pull requests or patches.
19
+
20
+ Copyright (c) 2007-2008 Justin Halsall, released under the MIT license
@@ -0,0 +1,28 @@
1
+ require "rake"
2
+ require "rake/clean"
3
+ require "rake/gempackagetask"
4
+ require 'rubygems'
5
+
6
+ ################################################################################
7
+ ### Gem
8
+ ################################################################################
9
+
10
+ begin
11
+ # Parse gemspec using the github safety level.
12
+ file = Dir['*.gemspec'].first
13
+ data = File.read(file)
14
+ spec = nil
15
+ Thread.new { spec = eval("$SAFE = 3\n%s" % data)}.join
16
+
17
+ # Create the gem tasks
18
+ Rake::GemPackageTask.new(spec) do |package|
19
+ package.gem_spec = spec
20
+ end
21
+ rescue Exception => e
22
+ printf "WARNING: Error caught (%s): %s\n%s", e.class.name, e.message, e.backtrace[0...5].map {|l| ' %s' % l}.join("\n")
23
+ end
24
+
25
+ desc 'Package and install the gem for the current version'
26
+ task :install => :gem do
27
+ system "sudo gem install -l pkg/%s-%s.gem" % [spec.name, spec.version]
28
+ end
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bogus_sass_checker'
3
+
4
+ PROJECT_PATH = Dir.pwd
5
+ SASS_DIRECTORY_PATH = File.join(PROJECT_PATH, "public/stylesheets/sass/")
6
+
7
+ stylesheets = Dir.new(SASS_DIRECTORY_PATH).entries - ['.', '..']
8
+ stylesheets.each do |sass_file|
9
+ stylesheet = open(SASS_DIRECTORY_PATH + sass_file).read
10
+ stylesheet.scan(/^(?:[^:]*)([#\.](?:[\w]*))/).each do |match|
11
+ result = search_contents_for(match)
12
+ if result == ""
13
+ puts match
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,36 @@
1
+ Gem::Specification.new do |s|
2
+ # Project
3
+ s.name = 'bogus_sass_checker'
4
+ s.summary = "Checks your rails projects Sass files for #ids and .classes and checks if you are using them in the rest of your rails project."
5
+ s.description = "Checks your rails projects Sass files for #ids and .classes and checks if you are using them in the rest of your rails project. (Depends on ACK)"
6
+ s.version = '0.1.0'
7
+ s.date = '2008-12-08'
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Justin Halsall"]
10
+ s.email = "zero200@gmail.com"
11
+ s.homepage = "http://www.github.com/Wakoopa/bogus-sass-checker"
12
+
13
+ # Files
14
+ root_files = %w[MIT-LICENSE README Rakefile bogus-sass-checker.gemspec]
15
+ bin_files = %w[checksass]
16
+ lib_files = %w[bogus_sass_checker]
17
+ test_files = %w[]
18
+ spec_files = %w[]
19
+ other_files = %w[]
20
+ s.bindir = "bin"
21
+ s.require_path = "lib"
22
+ s.executables = bin_files
23
+ s.test_files = test_files.map {|f| 'test/%s_test.rb' % f} + spec_files.map {|f| 'spec/%s_spec.rb' % f}
24
+ s.files = root_files + s.test_files + other_files + bin_files.map {|f| 'bin/%s' % f} + lib_files.map {|f| 'lib/%s.rb' % f}
25
+
26
+ # rdoc
27
+ s.has_rdoc = true
28
+ s.extra_rdoc_files = %w[ README MIT-LICENSE]
29
+ s.rdoc_options << '--inline-source' << '--line-numbers' << '--main' << 'README'
30
+
31
+ # Dependencies
32
+ # s.add_dependency 'rspec', "> 0.0.0"
33
+
34
+ # Requirements
35
+ s.required_ruby_version = ">= 1.8.0"
36
+ end
@@ -0,0 +1,20 @@
1
+ require 'rubygems'
2
+ require 'open-uri'
3
+
4
+ unless system('which ack > /dev/null')
5
+ puts "You must install ACK! http://petdance.com/ack/"
6
+ exit 1
7
+ end
8
+
9
+ def search_contents_for(string = '')
10
+ string = string.to_s
11
+ search_string = string[1..(string.size)]
12
+ search_query = case string[0...1]
13
+ when '#'
14
+ %{id="#{search_string.gsub(/"/, '\\"')}"|id='#{search_string.gsub(/'/, '\\\'')}'|:id\\s*=>\\s*"#{search_string.gsub(/"/, '\\"')}"|:id\\s*=>\\s*'#{search_string.gsub(/'/, '\\\'')}'}
15
+ when '.'
16
+ %{class="#{search_string.gsub(/"/, '\\"')}"|class='#{search_string.gsub(/'/, '\\\'')}'|:class\\s*=>\\s*"#{search_string.gsub(/"/, '\\"')}"|:class\\s*=>\\s*'#{search_string.gsub(/'/, '\\\'')}'}
17
+ end
18
+ # puts search_query
19
+ `cd #{PROJECT_PATH}; ack "#{search_query.to_s.gsub(/"/, '\\"')}" --ignore-dir=log --ignore-dir=tmp --ignore-dir=doc --ignore-dir=vendor --ignore-dir=.git`
20
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wakoopa-bogus_sass_checker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Justin Halsall
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-12-08 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: "Checks your rails projects Sass files for #ids and .classes and checks if you are using them in the rest of your rails project. (Depends on ACK)"
17
+ email: zero200@gmail.com
18
+ executables:
19
+ - checksass
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ - MIT-LICENSE
25
+ files:
26
+ - MIT-LICENSE
27
+ - README
28
+ - Rakefile
29
+ - bogus-sass-checker.gemspec
30
+ - bin/checksass
31
+ - lib/bogus_sass_checker.rb
32
+ has_rdoc: true
33
+ homepage: http://www.github.com/Wakoopa/bogus-sass-checker
34
+ post_install_message:
35
+ rdoc_options:
36
+ - --inline-source
37
+ - --line-numbers
38
+ - --main
39
+ - README
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 1.8.0
47
+ version:
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ version:
54
+ requirements: []
55
+
56
+ rubyforge_project:
57
+ rubygems_version: 1.2.0
58
+ signing_key:
59
+ specification_version: 2
60
+ summary: "Checks your rails projects Sass files for #ids and .classes and checks if you are using them in the rest of your rails project."
61
+ test_files: []
62
+