compass-csslint 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/compass-csslint.rb +147 -0
  2. metadata +82 -0
@@ -0,0 +1,147 @@
1
+ require 'compass'
2
+ require 'compass/commands/registry'
3
+ require 'compass/commands/project_base'
4
+ require 'compass/commands/update_project'
5
+
6
+ module Compass
7
+ module Commands
8
+ module CSSLintOptionsParser
9
+ def set_options(opts)
10
+ opts.banner = %Q{
11
+ Usage: compass csslint [options]* [path/to/project]*
12
+
13
+ Description:
14
+ Compile project at the path specified or the current
15
+ directory if not specified and then run CSS Lint
16
+ against the generated CSS.
17
+
18
+ Options:
19
+ }.strip.split("\n").map{|l| l.gsub(/^ {0,10}/,'')}.join("\n")
20
+
21
+ opts.on("-?", "-h", "--help", "Displays this information.") do
22
+ puts opts
23
+ exit
24
+ end
25
+
26
+ opts.on("--format=<format>", "Indicate which format to use for output.",
27
+ " One of: text, compact, lint-xml, csslint-xml, checkstyle-xml") do |format|
28
+ self.options[:format] = format
29
+ end
30
+
31
+ opts.on("--list-rules", "Outputs all of the rules available.") do
32
+ self.options[:list_rules] = true
33
+ self.options[:nocompile] = true
34
+ end
35
+
36
+ opts.on("--quiet", "Only output when errors are present.") do
37
+ self.options[:quiet] = true
38
+ end
39
+
40
+ opts.on("--errors=<rule[,rule]+>", "Indicate which rules to include as errors.") do |errors|
41
+ self.options[:errors] = errors
42
+ end
43
+
44
+ opts.on("--warnings=<rule[,rule]+>", "Indicate which rules to include as warnings.") do |warnings|
45
+ self.options[:warnings] = warnings
46
+ end
47
+
48
+ opts.on("--ignore=<rule,[,rule]+>", "Indicate which rules to ignore completely.") do |ignore|
49
+ self.options[:ignore] = ignore
50
+ end
51
+
52
+ opts.on("--version", "Outputs the current version number of CSS Lint.\n\n") do
53
+ self.options[:version] = true
54
+ self.options[:nocompile] = true
55
+ end
56
+
57
+ super
58
+ end
59
+ end
60
+ class CSSLintProject < ProjectBase
61
+
62
+ require 'css_lint'
63
+ include CSSLint
64
+
65
+ register :csslint
66
+
67
+ def initialize(working_path, options)
68
+ super
69
+ assert_project_directory_exists!
70
+ end
71
+
72
+ def perform
73
+ @options_str = ''
74
+
75
+ if options[:format]
76
+ @options_str << '--format=' + options[:format] + ' '
77
+ end
78
+
79
+ if options[:list_rules]
80
+ @options_str << '--list-rules'
81
+ end
82
+
83
+ if options[:quiet]
84
+ @options_str << '--quiet '
85
+ end
86
+
87
+ if options[:errors]
88
+ @options_str << '--errors=' + options[:errors] + ' '
89
+ end
90
+
91
+ if options[:warnings]
92
+ @options_str << '--warnings=' + options[:warnings] + ' '
93
+ end
94
+
95
+ if options[:ignore]
96
+ @options_str << '--ignore=' + options[:ignore] + ' '
97
+ end
98
+
99
+ if options[:version]
100
+ @options_str << '--version'
101
+ end
102
+
103
+ if not(options[:nocompile])
104
+ UpdateProject.new(working_path, options).perform
105
+ end
106
+
107
+ Dir.chdir Compass.configuration.project_path do
108
+ Lint.new(project_css_subdirectory).execute(@options_str)
109
+ end
110
+ end
111
+
112
+ class << self
113
+
114
+ def option_parser(arguments)
115
+ parser = Compass::Exec::CommandOptionParser.new(arguments)
116
+ parser.extend(Compass::Exec::ProjectOptionsParser)
117
+ parser.extend(CSSLintOptionsParser)
118
+ end
119
+
120
+ def usage
121
+ option_parser([]).to_s
122
+ end
123
+
124
+ def description(command)
125
+ "Run CSS Lint against your generated css."
126
+ end
127
+
128
+ def parse!(arguments)
129
+ parser = option_parser(arguments)
130
+ parser.parse!
131
+ parse_arguments!(parser, arguments)
132
+ parser.options
133
+ end
134
+
135
+ def parse_arguments!(parser, arguments)
136
+ if arguments.size == 1
137
+ parser.options[:project_name] = arguments.shift
138
+ elsif arguments.size == 0
139
+ # default to the current directory.
140
+ else
141
+ raise Compass::Error, "Too many arguments were specified."
142
+ end
143
+ end
144
+ end
145
+ end
146
+ end
147
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: compass-csslint
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - John Riviello
9
+ - Mike Ball
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-10-17 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: compass
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: css_lint
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ description: Runs CSS Lint against the CSS that Sass/Compass generates
48
+ email:
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - ./lib/compass-csslint.rb
54
+ homepage: http://comcast.github.com/compass-csslint/
55
+ licenses: []
56
+ post_install_message: ! "---------------------------------------------------------------------------------------------------\n
57
+ \ Thank you for installing CSS Lint for Sass & Compass!\n Please note there
58
+ is currently a bug in Compass that prevents this from working out of the box.\n
59
+ \ A custom version of Compass is required to run (just a one line change).\n See
60
+ http://comcast.github.com/compass-csslint/ for further details.\n---------------------------------------------------------------------------------------------------\n"
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 1.8.24
79
+ signing_key:
80
+ specification_version: 3
81
+ summary: Easily integrate CSS Lint into your projects that use the Compass CSS Framework
82
+ test_files: []