Module: Ronin::Support

Defined in:
lib/ronin/support/version.rb,
lib/ronin/support/inflector.rb

Constant Summary collapse

VERSION =

ronin-support version

'0.3.0'
INFLECTORS =

The Inflectors supported by ronin-support

{
  :datamapper => {
    :path => 'dm-core',
    :const => 'DataMapper::Inflector'
  },
  :active_support => {
    :path => 'active_support/inflector',
    :const => 'ActiveSupport::Inflector'
  },
  :extlib => {
    :path => 'extlib/inflection',
    :const => 'Extlib::Inflection'
  }
}

Class Method Summary collapse

Class Method Details

.load_inflector!(name) ⇒ true

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Loads an Inflector library and sets the Ronin::Support::Inflector constant.

Parameters:

  • name (Symbol, String)

    The name of the Inflector library to load. May be either :datamapper, :active_support or :extlib.

Returns:

  • (true)

    Specifies that the Inflector library was successfully loaded.

Raises:

  • (ArgumentError)

    The Inflector library is not supported.

  • (LoadError)

    The Inflector library could not be loaded.

  • (NameError)

    The constant could not be found.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/ronin/support/inflector.rb', line 60

def Support.load_inflector!(name)
  name = name.to_sym

  unless (inflector = INFLECTORS[name])
    raise(ArgumentError,"unsupported Inflector: #{name}")
  end

  begin
    require inflector[:path]
  rescue Gem::LoadError => e
    raise(e)
  rescue ::LoadError
    raise(LoadError,"unable to load #{inflector[:path]}")
  end

  begin
    const_set('Inflector', eval("::#{inflector[:const]}"))
  rescue NameError
    raise(NameError,"unable to find #{inflector[:const]}")
  end

  return true
end