root = File.join(File.dirname(__FILE__), "..") require "fileutils" # Copy files if defined?(Rails::Generators::Base) require "edge/install_generator" end module Edge require "edge/message" @message = Edge::Message.new def self.message(key) return @message.get_message(key); end # Create project def self.create(type, name) # If name is specified, create new directory if name FileUtils.mkdir( name ) destination = File.join( Dir.pwd, name ) # If type is specified, create new file in the current directory elsif type puts "[create] \t #{type} template" destination = Dir.pwd else puts message(: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 "[error] \t Template not found" puts message(: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 ) puts "[success] \t Run `compass watch` to generate the CSS" end # Help message def self.help() puts message(:help) end # Error message for non-existance command def self.not_found(command) puts "The command '#{command}' does not exist. Run #{ log("edge -h") } for help" end # Generic message for command that is too long def self.command_too_long() puts "Passed parameters exceed limits. If your #{ log('project_name') } contains space, enclose it with double-quote (\")" end if defined?(Rails::Engine) require "edge/engine" elsif defined?(Sprockets) require "edge/sprockets" end end if defined?(Compass) Compass::Frameworks.register("edge", :stylesheets_directory => File.join(root,"assets/sass"), :templates_directory => File.join(root,"templates") ) end