Module: Kernel

Defined in:
lib/gems/builder-2.1.2/lib/blankslate.rb,
lib/mack/core_extensions/kernel.rb,
lib/gems/abstract-1.0.0/lib/abstract.rb,
lib/gems/polyglot-0.2.3/lib/polyglot.rb,
lib/gems/cucumber-0.1.15/lib/cucumber/formatters/unicode.rb,
lib/gems/configatron-2.2.2/lib/configatron/core_ext/kernel.rb

Overview

Since Ruby is very dynamic, methods added to the ancestors of BlankSlate after BlankSlate is defined will show up in the list of available BlankSlate methods. We handle this by defining a hook in the Object and Kernel classes that will hide any method defined after BlankSlate has been loaded.

Defined Under Namespace

Classes: DeprecatedRegistryList

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.blank_slate_method_addedObject



61
# File 'lib/gems/builder-2.1.2/lib/blankslate.rb', line 61

alias_method :blank_slate_method_added, :method_added

.method_added(name) ⇒ Object

Detect method additions to Kernel and remove them in the BlankSlate class.



65
66
67
68
69
70
# File 'lib/gems/builder-2.1.2/lib/blankslate.rb', line 65

def method_added(name)
  result = blank_slate_method_added(name)
  return result if self != Kernel
  BlankSlate.hide(name)
  result
end

Instance Method Details

#alias_deprecated_method(deprecated_method, new_method, version_deprecrated = nil, version_to_be_removed = nil) ⇒ Object

Aliases the deprecated method to the new method and logs a warning.



40
41
42
43
44
45
46
47
# File 'lib/mack/core_extensions/kernel.rb', line 40

def alias_deprecated_method(deprecated_method, new_method, version_deprecrated = nil, version_to_be_removed = nil)
  eval %{
    def #{deprecated_method}(*args)
      deprecate_method(:#{deprecated_method}, :#{new_method}, "#{version_deprecrated}", "#{version_to_be_removed}")
      #{new_method}(*args)
    end
  }
end

#assets_mgrObject

Return the instance of the AssetManager class.



25
26
27
# File 'lib/mack/core_extensions/kernel.rb', line 25

def assets_mgr
  return Mack::Assets::Manager.instance
end

#configatronObject

Provides access to the Configatron storage system.



4
5
6
# File 'lib/gems/configatron-2.2.2/lib/configatron/core_ext/kernel.rb', line 4

def configatron
  Configatron.instance
end

#cucumber_printObject



16
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/formatters/unicode.rb', line 16

alias cucumber_print print

#cucumber_putsObject



25
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/formatters/unicode.rb', line 25

alias cucumber_puts puts

#deprecate_method(deprecated_method, new_method = nil, version_deprecrated = nil, version_to_be_removed = nil) ⇒ Object

Logs a warning that a method has been deprecated. Warnings will only get logged once.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/mack/core_extensions/kernel.rb', line 50

def deprecate_method(deprecated_method, new_method = nil, version_deprecrated = nil, version_to_be_removed = nil)
  message = "DEPRECATED: '#{deprecated_method}'."
  if new_method
    message << " Please use '#{new_method}' instead."
  end
  if version_deprecrated
    message << " Deprecated in version: '#{version_deprecrated}'."
    if version_to_be_removed.nil?
      version_to_be_removed = ">=#{version_deprecrated.succ}"
    end
  end
  if version_to_be_removed
    message << " To be removed in version: '#{version_to_be_removed}'."
  end
  unless Kernel::DeprecatedRegistryList.registered_items.include?(message)
    Mack.logger.warn(message)
    Kernel::DeprecatedRegistryList.add(message)
  end
end

#init_message(message) ⇒ Object

:nodoc:



3
4
5
6
7
8
9
10
# File 'lib/mack/core_extensions/kernel.rb', line 3

def init_message(message) # :nodoc:
  message = "Initializing '#{message}' ..."
  if Mack.methods.include?('logger')
    Mack.logger.debug(message) unless configatron.mack.log.disable_initialization_logging
  else
    puts message
  end
end

#polyglot_original_requireObject



50
# File 'lib/gems/polyglot-0.2.3/lib/polyglot.rb', line 50

alias polyglot_original_require require


17
18
19
20
21
22
23
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/formatters/unicode.rb', line 17

def print(*a)
  begin
    cucumber_print *Iconv.iconv(Cucumber::CODEPAGE, "UTF-8", *a)
  rescue Iconv::IllegalSequence
    cucumber_print(*a)
  end
end

#puts(*a) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/formatters/unicode.rb', line 26

def puts(*a)
  begin
    cucumber_puts *Iconv.iconv(Cucumber::CODEPAGE, "UTF-8", *a)
  rescue Iconv::IllegalSequence
    cucumber_puts(*a)
  end
end

#require(*a, &b) ⇒ Object



52
53
54
55
56
57
58
59
60
61
# File 'lib/gems/polyglot-0.2.3/lib/polyglot.rb', line 52

def require(*a, &b)
  polyglot_original_require(*a, &b)
rescue LoadError => load_error
  begin
    Polyglot.load(*a, &b)
  rescue
    # Raise the original exception, possibly a MissingSourceFile with a path
    raise load_error
  end
end

#require_gems {|Mack::Utils::GemManager.instance| ... } ⇒ Object

Returns Mack::Utils::GemManager

Yields:



30
31
32
# File 'lib/mack/core_extensions/kernel.rb', line 30

def require_gems
  yield Mack::Utils::GemManager.instance
end

#require_portlets {|Mack::Portlet::Manager.instance| ... } ⇒ Object

Returns Mack::Portlets::Manager

Yields:



13
14
15
# File 'lib/mack/core_extensions/kernel.rb', line 13

def require_portlets
  yield Mack::Portlet::Manager.instance
end

#required_gem_listObject

Returns an Array of gems required by the Mack::Utils::GemManager



35
36
37
# File 'lib/mack/core_extensions/kernel.rb', line 35

def required_gem_list
  Mack::Utils::GemManager.instance.required_gem_list
end

#required_portlets_listObject

Returns an Array of gems required by the Mack::Portlets::Manager



18
19
20
# File 'lib/mack/core_extensions/kernel.rb', line 18

def required_portlets_list
  Mack::Portlet::Manager.instance.required_portlet_list
end