Module: SleepingKingStudios::Tools::CoreTools

Extended by:
CoreTools
Included in:
CoreTools
Defined in:
lib/sleeping_king_studios/tools/core_tools.rb

Overview

Tools for working with an application or working environment.

Instance Method Summary collapse

Instance Method Details

#deprecate(name, message: nil) ⇒ Object #deprecate(*args, format: , message: nil) ⇒ Object

Overloads:

  • #deprecate(name, message: nil) ⇒ Object

    Prints a deprecation warning.

    Parameters:

    • name (String)

      The name of the object, method, or feature that has been deprecated.

    • message (String) (defaults to: nil)

      An optional message to print after the formatted string. Defaults to nil.

  • #deprecate(*args, format: , message: nil) ⇒ Object

    Prints a deprecation warning with the specified format.

    Parameters:

    • args (Array)

      The arguments to pass into the format string.

    • format (String) (defaults to: )

      The format string.

    • message (String) (defaults to: nil)

      An optional message to print after the formatted string. Defaults to nil.



25
26
27
28
29
30
31
32
33
34
# File 'lib/sleeping_king_studios/tools/core_tools.rb', line 25

def deprecate *args, format: nil, message: nil
  format ||= "[WARNING] %s has been deprecated."

  str = format % args
  str << ' ' << message if message

  str << "\n  called from #{caller[1]}"

  Kernel.warn str
end

#require_each(*file_patterns) ⇒ Object

Expands each file pattern and requires each file.

Parameters:

  • file_patterns (Array)

    The files to require.



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/sleeping_king_studios/tools/core_tools.rb', line 39

def require_each *file_patterns
  file_patterns.each do |file_pattern|
    if file_pattern.include?('*')
      Dir[file_pattern].each do |file_name|
        Kernel.require file_name
      end # each
    else
      Kernel.require file_pattern
    end # unless
  end # each
end