Module: Cardio::Generators::ClassMethods

Included in:
Base, Deck::DeckGenerator, ModBase
Defined in:
decko/lib/decko/generators.rb,
card/lib/cardio/generators/class_methods.rb

Overview

methods shared across Generator bases (which inherit from Rails generator classes)

Instance Method Summary collapse

Instance Method Details

Override Rails default banner (using card/decko for the command name).



18
19
20
21
22
# File 'card/lib/cardio/generators/class_methods.rb', line 18

def banner
  usage_arguments = arguments.map(&:usage).join " "
  text = "#{banner_command} generate #{namespace} #{usage_arguments} [options]"
  text.gsub(/\s+/, " ")
end

generator USAGE docs will use “decko” rather than “card” when called with decko



12
13
14
# File 'decko/lib/decko/generators.rb', line 12

def banner_command
  "decko"
end

#namespace(name = nil) ⇒ Object

Override Rails namespace handling so we can put generators in module Cardio



29
30
31
32
# File 'card/lib/cardio/generators/class_methods.rb', line 29

def namespace name=nil
  return super if name
  @namespace ||= super.sub(/cardio:/, "")
end

#source_root(path = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'card/lib/cardio/generators/class_methods.rb', line 7

def source_root path=nil
  if path
    @_card_source_root = path
  else
    @_card_source_root ||= File.expand_path(
      "../../../generators/#{generator_name}/templates", __FILE__
    )
  end
end