class DaemonKit::Generators::Base

Public Class Methods

desc(description=nil) click to toggle source

Tries to get the description from a USAGE file one folder above the source root otherwise uses a default description.

Calls superclass method
# File lib/daemon_kit/generators/base.rb, line 15
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 #{base_name.humanize.downcase} files for #{generator_name} generator."
  end
end

Protected Class Methods

add_shebang_option!() click to toggle source

Small macro to add ruby as an option to the generator with proper default value plus an instance helper method called shebang.

# File lib/daemon_kit/generators/base.rb, line 35
def self.add_shebang_option!
  class_option :ruby, :type => :string, :aliases => "-r", :default => Thor::Util.ruby_command,
                      :desc => "Path to the Ruby binary of your choice", :banner => "PATH"

  no_tasks {
    define_method :shebang do
      @shebang ||= begin
        command = if options[:ruby] == Thor::Util.ruby_command
          "/usr/bin/env #{File.basename(Thor::Util.ruby_command)}"
        else
          options[:ruby]
        end
        "#!#{command}"
      end
    end
  }
end
namespace(name = nil) click to toggle source
Calls superclass method
# File lib/daemon_kit/generators/base.rb, line 53
def self.namespace(name = nil)
  return super if name
  @namespace ||= super.sub(/_generator$/, '').sub(/:generators:/, ':').sub(/^daemon_kit:/, '')
end

Protected Instance Methods

app_name() click to toggle source
# File lib/daemon_kit/generators/base.rb, line 28
def app_name
  @app_name = File.basename( destination_root )
end