Module: Rgentpl

Defined in:
lib/rgentpl.rb,
lib/rgentpl/version.rb,
lib/rgentpl/command/base.rb,
lib/rgentpl/core_ext/string.rb,
lib/rgentpl/boot/application.rb,
lib/rgentpl/boot/initializer.rb,
lib/rgentpl/command/generate.rb,
lib/rgentpl/core/configuration.rb,
lib/rgentpl/exception/critical.rb

Overview

Rgentpl

Defined Under Namespace

Modules: Application, Command, CoreExt, Exception, Initializer Classes: Configuration

Constant Summary collapse

VERSION =

Version

'1.2.5'

Class Method Summary collapse

Class Method Details

.add_new_attribute(exc, method) ⇒ void

This method returns an undefined value.

Implementation for adding new attribute in configuration block

Parameters:

  • exc (NoMethodError)

    the exception

  • method (String)

    the writter method name



35
36
37
38
39
40
# File 'lib/rgentpl/core/configuration.rb', line 35

def add_new_attribute(exc, method)
  @config.extend Virtus.model
  @config.attribute method.to_sym, String, default: exc.args.first,
                                           lazy: true
  @config.send(exc.name, exc.args.first)
end

.add_new_attribute_from_exception(exc) ⇒ void

This method returns an undefined value.

Interface for adding new attribute in configuration block

Parameters:

  • exc (NoMethodError)

    the exception



26
27
28
# File 'lib/rgentpl/core/configuration.rb', line 26

def add_new_attribute_from_exception(exc)
  add_new_attribute(exc, exc.name.to_s.gsub(/=$/, ''))
end

.configRgentpl::Configuration

Configuration object

Returns:



18
19
20
# File 'lib/rgentpl/core/configuration.rb', line 18

def config
  @config ||= Rgentpl::Configuration.new
end

.configure(&_block) ⇒ Rgentpl::Configuration

Configure

Parameters:

  • _block (Proc)

    the configuration options

Returns:

Raises:

  • (NoMethodError)

    when new options are inside configuration block



9
10
11
12
13
# File 'lib/rgentpl/core/configuration.rb', line 9

def configure(&_block)
  yield @config ||= Rgentpl::Configuration.new
rescue NoMethodError => exc
  add_new_attribute_from_exception exc
end

.envString

Environment

Returns:

  • (String)

    the current environment



32
33
34
35
36
37
# File 'lib/rgentpl.rb', line 32

def env
  unless defined?(TEMPLATE_ENV)
    load File.expand_path('../../config/environment.rb',  __FILE__)
  end
  TEMPLATE_ENV
end

.loggerLogger

Logger

Returns:

  • (Logger)

    the logger



42
43
44
45
46
# File 'lib/rgentpl.rb', line 42

def logger
  @_logger ||= Logger.new(
    "#{File.dirname(__FILE__)}/../log/#{config.log_file}"
  )
end