Top Level Namespace

Includes:
Config, RbConfig

Defined Under Namespace

Classes: GemHadar

Instance Method Summary collapse

Instance Method Details

#GemHadar(&block) ⇒ GemHadar

The GemHadar method serves as the primary entry point for configuring and initializing a gem project using the GemHadar framework.

This method creates a new instance of the GemHadar class, passes the provided block to configure the gem settings, and then invokes the create_all_tasks method to set up all the necessary Rake tasks for the project.

Parameters:

  • block (Proc)

    a configuration block used to define gem properties and settings

Returns:

  • (GemHadar)

    the configured GemHadar instance after all tasks have been created



1991
1992
1993
# File 'lib/gem_hadar.rb', line 1991

def GemHadar(&block)
  GemHadar.new(&block).create_all_tasks
end

#template(pathname) {|block| ... } ⇒ Pathname

The template method processes an ERB template file and creates a Rake task for its compilation.

This method takes a template file path, removes its extension to determine the output file name, and sets up a Rake file task that compiles the template using the provided block configuration. It ensures the source file has an extension and raises an error if not.

Parameters:

  • pathname (String)

    the path to the template file to be processed

Yields:

  • (block)

    the configuration block for the template compiler

Returns:

  • (Pathname)

    the Pathname object representing the destination file path



2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
# File 'lib/gem_hadar.rb', line 2008

def template(pathname, &block)
  template_src = Pathname.new(pathname)
  template_dst = template_src.sub_ext('') # ignore ext, we just support erb anyway
  template_src == template_dst and raise ArgumentError,
    "pathname #{pathname.inspect} needs to have a file extension"
  file template_dst.to_s => template_src.to_s do
    GemHadar::TemplateCompiler.new(&block).compile(template_src, template_dst)
  end
  template_dst
end