An abstrac class that encapsulates the code specific to the `haml` and `sass` executables.
Processes the options set by the command-line arguments. In particular, sets `@options[:for_engine][:filename]` to the input filename and requires the appropriate file.
This is meant to be overridden by subclasses so they can run their respective programs.
# File lib/haml/exec.rb, line 259 259: def process_result 260: super 261: @options[:for_engine][:filename] = @options[:filename] if @options[:filename] 262: require File.dirname(__FILE__) + "/../#{@name.downcase}" 263: end
Tells optparse how to parse the arguments available for the `haml` and `sass` executables.
This is meant to be overridden by subclasses so they can add their own options.
@param opts [OptionParser]
# File lib/haml/exec.rb, line 189 189: def set_opts(opts) 190: opts.banner = Usage: #{@name.downcase} [options] [INPUT] [OUTPUT]Description: Uses the #{@name} engine to parse the specified template and outputs the result to the specified file.Options: 191: 192: opts.on('--rails RAILS_DIR', "Install Haml and Sass from the Gem to a Rails project") do |dir| 193: original_dir = dir 194: 195: env = File.join(dir, "config", "environment.rb") 196: if File.exists?(File.join(dir, "Gemfile")) 197: puts("haml --rails isn't needed for Rails 3 or greater.", 198: "Add 'gem \"haml\"' to your Gemfile instead.", "", 199: "haml --rails will no longer work in the next version of #{@name}.", "") 200: elsif File.exists?(env) && File.open(env) {|env| env.grep(/config\.gem/)} 201: puts("haml --rails isn't needed for Rails 2.1 or greater.", 202: "Add 'gem \"haml\"' to config/environment.rb instead.", "", 203: "haml --rails will no longer work in the next version of #{@name}.", "") 204: end 205: 206: dir = File.join(dir, 'vendor', 'plugins') 207: 208: unless File.exists?(dir) 209: puts "Directory #{dir} doesn't exist" 210: exit 1 211: end 212: 213: dir = File.join(dir, 'haml') 214: 215: if File.exists?(dir) 216: print "Directory #{dir} already exists, overwrite [y/N]? " 217: exit 2 if gets !~ /y/ 218: FileUtils.rm_rf(dir) 219: end 220: 221: begin 222: Dir.mkdir(dir) 223: rescue SystemCallError 224: puts "Cannot create #{dir}" 225: exit 1 226: end 227: 228: File.open(File.join(dir, 'init.rb'), 'w') do |file| 229: file << File.read(File.dirname(__FILE__) + "/../../init.rb") 230: end 231: 232: puts "Haml plugin added to #{original_dir}" 233: exit 234: end 235: 236: opts.on('-c', '--check', "Just check syntax, don't evaluate.") do 237: require 'stringio' 238: @options[:check_syntax] = true 239: @options[:output] = StringIO.new 240: end 241: 242: super 243: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.