Sha256: 7acb6b9140803724bebcfbfb13e4b439b089aaed6fbbf05d3affd51f5efcb075
Contents?: true
Size: 1.97 KB
Versions: 3
Compression:
Stored size: 1.97 KB
Contents
require 'rubygems' require 'thor/group' require 'active_support/inflector' module Couch module Generators class Error < Thor::Error end class Base < Thor::Group include Thor::Actions add_runtime_options! class_option :skip_git, :type => :boolean, :aliases => "-G", :default => false, :desc => "Skip Git ignores and keeps" # Automatically sets the source root based on the class name. # def self.source_root @_couch_source_root ||= begin if generator_name File.expand_path(File.join("../generators", generator_name, 'templates'), File.dirname(__FILE__)) end end end # Tries to get the description from a USAGE file one folder above the source # root otherwise uses a default description. # def self.desc(description=nil) return super if description usage = File.expand_path(File.join(source_root, "..", "USAGE")) @desc ||= if File.exist?(usage) File.read(usage) else "Description:\n Create files for #{generator_name} generator." end end def self.info desc.split(/\n+/)[1].strip end protected # Use Couch default banner. # def self.banner "couch generate|destroy #{generator_name} #{self.arguments.map{ |a| a.usage }.join(' ')} [options]" end # Removes the namespaces and get the generator name. For example, # Couch::Generators::MetalGenerator will return "metal" as generator name. # def self.generator_name @generator_name ||= begin if generator = name.to_s.split('::').last generator.sub!(/Generator$/, '') generator.underscore end end end def empty_directory_with_gitkeep(destination, config = {}) empty_directory(destination, config) create_file("#{destination}/.gitkeep") unless options[:skip_git] end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
couch-0.1.0 | lib/couch/generators/base.rb |
couch-0.0.4 | lib/couch/generators/base.rb |
couch-0.0.3 | lib/couch/generators/base.rb |