%w{settings coffeescript compass-sass incloudr tools}.each {|lib| require "#{lib}.rb"} module Capucine class Main attr_accessor :settings attr_accessor :coffee attr_accessor :sass attr_accessor :incloudr attr_accessor :tools def initialize self.settings = Capucine::Settings.new self.tools = Capucine::Tools.new(self) self.sass = Capucine::CompassSass.new(self) self.coffee = Capucine::CoffeeScript.new(self) self.incloudr = Capucine::Incloudr.new(self) return self end def run_command(command) # command = ['c', '/path/to/file.yaml'] # command = ['c:sass', '/path/to/file.yaml'] # ... run = command[0].to_s.split(':') # Rake like capucine compile:sass config_or_name = command[1] # second part (the capucine.yaml file or template name/url) main = run[0] # c, w, compile, watch, new, init run.shift # all, coffee, sass or incloudr | sinatra, wordpress, etc ... scope = run # all, coffee, sass or incloudr | sinatra, wordpress, etc ... if %w{i init}.include?(main) self.tools.init(scope[0], config_or_name) elsif %w{n new}.include?(main) self.tools.new_project(scope[0], config_or_name) self.tools.compile elsif %w{c compile}.include?(main) self.settings.set_user_config_file(config_or_name) self.tools.compile(scope[0]) elsif %w{j js}.include?(main) self.settings.set_user_config_file(config_or_name) self.tools.js(scope, config_or_name) elsif %w{w watch}.include?(main) self.settings.set_user_config_file(config_or_name) self.tools.watch(scope[0]) elsif %w{cl clean}.include?(main) self.settings.set_user_config_file(config_or_name) self.tools.clean elsif %w{u update}.include?(main) self.settings.set_user_config_file(config_or_name) self.tools.update elsif %w{h help}.include?(main) self.help else self.help end return self end def help version = File.open(File.join(self.settings.root_dir, 'VERSION')).read template_file = File.join self.settings.content_dir, 'templates', 'cmd_help.erb' result = self.tools.render_template template_file, version puts result end end end