Class: Compass::Commands::CSSLintProject

Inherits:
ProjectBase
  • Object
show all
Includes:
CSSLint
Defined in:
lib/compass-csslint.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(working_path, options) ⇒ CSSLintProject

Returns a new instance of CSSLintProject.



71
72
73
74
# File 'lib/compass-csslint.rb', line 71

def initialize(working_path, options)
  super
  assert_project_directory_exists!
end

Class Method Details

.description(command) ⇒ Object



132
133
134
# File 'lib/compass-csslint.rb', line 132

def description(command)
  "Run CSS Lint against your generated css."
end

.option_parser(arguments) ⇒ Object



122
123
124
125
126
# File 'lib/compass-csslint.rb', line 122

def option_parser(arguments)
  parser = Compass::Exec::CommandOptionParser.new(arguments)
  parser.extend(Compass::Exec::ProjectOptionsParser)
  parser.extend(CSSLintOptionsParser)
end

.parse!(arguments) ⇒ Object



136
137
138
139
140
141
# File 'lib/compass-csslint.rb', line 136

def parse!(arguments)
  parser = option_parser(arguments)
  parser.parse!
  parse_arguments!(parser, arguments)
  parser.options
end

.parse_arguments!(parser, arguments) ⇒ Object



143
144
145
146
147
148
149
150
151
# File 'lib/compass-csslint.rb', line 143

def parse_arguments!(parser, arguments)
  if arguments.size == 1
    parser.options[:project_name] = arguments.shift
  elsif arguments.size == 0
    # default to the current directory.
  else
    raise Compass::Error, "Too many arguments were specified."
  end
end

.usageObject



128
129
130
# File 'lib/compass-csslint.rb', line 128

def usage
  option_parser([]).to_s
end

Instance Method Details

#performObject



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/compass-csslint.rb', line 76

def perform
  @options_str = ''

  if options[:format]
    @options_str << '--format=' + options[:format] + ' '
  end

  if options[:list_rules]
    @options_str << '--list-rules'
  end

  if options[:quiet]
    @options_str << '--quiet '
  end

  if options[:errors]
    @options_str << '--errors=' + options[:errors] + ' '
  end

  if options[:warnings]
    @options_str << '--warnings=' + options[:warnings] + ' '
  end

  if options[:ignore]
    @options_str << '--ignore=' + options[:ignore] + ' '
  end

  if options[:exclude_list]
    @options_str << '--exclude-list=' + options[:exclude_list] + ' '
  end

  if options[:version]
    @options_str << '--version'
  end

  if not(options[:nocompile])
    UpdateProject.new(working_path, options).perform
  end

  Dir.chdir Compass.configuration.project_path do
    Lint.new(project_css_subdirectory).execute(@options_str)
  end
end