Class: SleepingKingStudios::Tools::CoreTools
- Defined in:
- lib/sleeping_king_studios/tools/core_tools.rb
Overview
Tools for working with an application or working environment.
Defined Under Namespace
Classes: DeprecationError
Instance Attribute Summary collapse
-
#deprecation_caller_depth ⇒ Integer
readonly
The number of backtrace lines to display when outputting a deprecation warning.
-
#deprecation_strategy ⇒ String
readonly
The current deprecation strategy.
Instance Method Summary collapse
- #deprecate(*args, format: nil, message: nil) ⇒ Object
-
#empty_binding ⇒ Binding
Generates an empty Binding object with an Object as the receiver.
-
#initialize(deprecation_caller_depth: nil, deprecation_strategy: nil) ⇒ CoreTools
constructor
A new instance of CoreTools.
-
#require_each(*file_patterns) ⇒ Object
Expands each file pattern and requires each file.
Methods inherited from Base
Constructor Details
#initialize(deprecation_caller_depth: nil, deprecation_strategy: nil) ⇒ CoreTools
Returns a new instance of CoreTools.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/sleeping_king_studios/tools/core_tools.rb', line 23 def initialize( deprecation_caller_depth: nil, deprecation_strategy: nil ) super() @deprecation_caller_depth = deprecation_caller_depth || ENV.fetch('DEPRECATION_CALLER_DEPTH', '3').to_i @deprecation_strategy = deprecation_strategy || ENV.fetch('DEPRECATION_STRATEGY', 'warn') end |
Instance Attribute Details
#deprecation_caller_depth ⇒ Integer (readonly)
Returns the number of backtrace lines to display when outputting a deprecation warning.
38 39 40 |
# File 'lib/sleeping_king_studios/tools/core_tools.rb', line 38 def deprecation_caller_depth @deprecation_caller_depth end |
#deprecation_strategy ⇒ String (readonly)
Returns the current deprecation strategy.
41 42 43 |
# File 'lib/sleeping_king_studios/tools/core_tools.rb', line 41 def deprecation_strategy @deprecation_strategy end |
Instance Method Details
#deprecate(name, message: nil) ⇒ Object #deprecate(*args, format: , message: nil) ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/sleeping_king_studios/tools/core_tools.rb', line 58 def deprecate(*args, format: nil, message: nil) send( :"deprecate_as_#{deprecation_strategy}", *args, format: format, message: ) end |
#empty_binding ⇒ Binding
Generates an empty Binding object with an Object as the receiver.
70 71 72 |
# File 'lib/sleeping_king_studios/tools/core_tools.rb', line 70 def empty_binding Object.new.instance_exec { binding } end |
#require_each(*file_patterns) ⇒ Object
Expands each file pattern and requires each file.
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/sleeping_king_studios/tools/core_tools.rb', line 77 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 else Kernel.require file_pattern end end end |