root = File.join(File.dirname(__FILE__), "..") require "edge/version" require "win32console" # Command line color for Windows require "fileutils" # Copy files module Edge require "edge/console" require "edge/version" require "edge/message" @console = Edge::Console.new # Create project def self.create(type, name) # If name is specified, create new directory if name puts "Creating #{ @console.magenta(name) } as #{ @console.yellow(type) } project..." FileUtils.mkdir( name ) destination = File.join( Dir.pwd, name ) # If type is specified, create new file in the current directory elsif type puts "Generating #{ @console.yellow(type) } template..." destination = Dir.pwd else puts CREATE_WRONG_SYNTAX return false end # Gem home directory home = File.expand_path( "..", File.dirname(__FILE__) ) template = File.join( home, "template" ) # Copy template files template_type = File.join( template, type ) # If directory doesn't exist if !File.directory?(template_type) puts "#{ @console.red('Template not found') }" puts AVAILABLE_TEMPLATE return false end FileUtils.cp_r( Dir["#{template_type}/*"], destination ) # Copy base files base = File.join( template, "base" ) FileUtils.cp_r( Dir["#{base}/*"], destination ) # Copy javascript files js_source = File.join( home, "assets", "js" ) js_destination = File.join( destination, "assets", "js") FileUtils.cp_r( Dir["#{js_source}/*"], js_destination ) if name.nil? compass_command = "#{ @console.cyan('compass watch') }" elsif name.match(/\s/) compass_command = "#{ @console.cyan('compass watch') } #{ @console.cyan('"'+name+'"') }" elsif name compass_command = "#{ @console.cyan('compass watch') } #{ @console.cyan(name) }" else compass_command = "#{ @console.cyan('compass watch') }" end puts "#{ @console.green('Done!') } For starter, you can run #{ @console.cyan(compass_command) } to generate the CSS" end # Help message def self.help() puts HELP end # Error message for non-existance command def self.not_found(command) puts "The command '#{command}' does not exist. Run #{ @console.cyan("edge -h") } for available commands." end # Generic message for command that is too long def self.command_too_long() puts "Passed parameters exceed limits. If your #{ @console.cyan("project_name") } contains space, enclose it with double-quote (\")" end end if defined?(Compass) Compass::Frameworks.register("edge", :stylesheets_directory => File.join(root,"assets/sass"), :templates_directory => File.join(root,"templates") ) end