lib/capucine.rb in capucine-0.1.7 vs lib/capucine.rb in capucine-0.2.0

- old
+ new

@@ -1,14 +1,73 @@ -require 'settings.rb' +%w{settings coffeescript compass-sass incloudr tools}.each {|lib| require "#{lib}.rb"} module Capucine - - def new - @settings = Capucine::Settings.new + 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 + + else + self.help + end + + return self + end + + def help + puts 'HELP' + end + end - - def settings - @settings - end - module_function :new, :settings end