class Rounders::Generators::Base
Protected Class Methods
inherited(klass)
click to toggle source
# File lib/rounders/generators/base.rb, line 38 def inherited(klass) klass.define_singleton_method(:source_root) do default_source_root end klass.define_singleton_method(:generator_name) do @generator_name ||= feature_name.split('_').first end klass.define_singleton_method(:default_source_root) do return unless base_name && generator_name return unless default_generator_root path = Pathname.new(default_generator_root).join('templates') path if path.exist? end klass.define_singleton_method(:base_name) do @base_name ||= begin base = name.to_s.split('::').first Rounders::Util.infrect(base).underscore unless base.nil? end end klass.define_singleton_method(:default_generator_root) do path = Pathname(__FILE__).dirname.join(generator_name).expand_path path if path.exist? end end
Protected Instance Methods
class_name()
click to toggle source
# File lib/rounders/generators/base.rb, line 12 def class_name Util.infrect(name).classify end
empty_directory_with_keep_file(destination, config = {})
click to toggle source
# File lib/rounders/generators/base.rb, line 20 def empty_directory_with_keep_file(destination, config = {}) empty_directory(destination, config) keep_file(destination) end
feature_path()
click to toggle source
# File lib/rounders/generators/base.rb, line 16 def feature_path Pathname("#{Rounders::APP_PATH}/#{self.class.directory_name}") end
keep_file(destination)
click to toggle source
# File lib/rounders/generators/base.rb, line 25 def keep_file(destination) create_file("#{destination}/.keep") end
namespaced_name()
click to toggle source
# File lib/rounders/generators/base.rb, line 33 def namespaced_name @namespaced_name ||= Util.infrect(name.tr('-', '/')).classify end
underscored_name()
click to toggle source
# File lib/rounders/generators/base.rb, line 29 def underscored_name @underscored_name ||= Util.infrect(name).underscore end