Class: Compass::Commands::CsscssProject

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(working_path, options) ⇒ CsscssProject

Returns a new instance of CsscssProject.



87
88
89
90
# File 'lib/compass-csscss.rb', line 87

def initialize(working_path, options)
  super
  assert_project_directory_exists!
end

Class Method Details

.description(command) ⇒ Object



183
184
185
# File 'lib/compass-csscss.rb', line 183

def description(command)
  "Run csscss against your sass or generated css."
end

.option_parser(arguments) ⇒ Object



173
174
175
176
177
# File 'lib/compass-csscss.rb', line 173

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

.parse!(arguments) ⇒ Object



187
188
189
190
191
192
# File 'lib/compass-csscss.rb', line 187

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

.parse_arguments!(parser, arguments) ⇒ Object



194
195
196
197
198
199
200
201
202
# File 'lib/compass-csscss.rb', line 194

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



179
180
181
# File 'lib/compass-csscss.rb', line 179

def usage
  option_parser([]).to_s
end

Instance Method Details

#performObject



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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/compass-csscss.rb', line 92

def perform
  @args = []

  if !options[:verbose].nil?
    @args << '--' + (options[:verbose] ? '' : 'no-') + 'verbose'
  end

  if !options[:color].nil?
    @args << '--' + (options[:color] ? '' : 'no-') + 'color'
  end

  if options[:num]
    @args << '--num'
    @args << options[:num]
  end

  if !options[:match_shorthand].nil?
    @args << '--' + (options[:match_shorthand] ? '' : 'no-') + 'match-shorthand'
  end

  if !options[:json].nil?
    @args << '--' + (options[:json] ? '' : 'no-') + 'json'
  end

  if options[:ignore_sass_mixins]
    @args << '--ignore-sass-mixins'
  end

  if options[:file]
    @args << '--require'
    @args << options[:file]
  end

  if options[:ignored_properties]
    @args << '--ignore-properties'
    @args << options[:ignored_properties]
  end

  if options[:ignored_selectors]
    @args << '--ignore-selectors'
    @args << options[:ignored_selectors]
  end

  if options[:show_parser_errors]
    @args << '--show-parser-errors'
  end

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

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

  Dir.chdir Compass.configuration.project_path do

    if options[:sass]

      if Compass.configuration.inherited_data.name.nil?
        @args << '--compass'
      else
        @args << '--compass-with-config'
        @args << Compass.configuration.inherited_data.name
      end

      @args << Dir.glob(project_src_subdirectory+"/**/*.s{a,c}ss")

    elsif not(options[:nocompile])

      @args << Dir.glob(project_css_subdirectory+"/**/*.css")

    end

    Csscss::CLI.run(@args.flatten)

  end
end