Module: RadiusRB

Included in:
Attribute, Dictionary, Value, Vendor
Defined in:
lib/radiusrb.rb,
lib/radiusrb/packet.rb,
lib/radiusrb/vendor.rb,
lib/radiusrb/request.rb,
lib/radiusrb/version.rb,
lib/radiusrb/dictionary.rb,
lib/radiusrb/dictionary/values.rb,
lib/radiusrb/dictionary/attributes.rb

Overview

This file is part of the RadiusRB library for Ruby. Copyright © 2012 Davide Guerri <[email protected]>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Defined Under Namespace

Modules: Version Classes: Attribute, AttributesCollection, Dictionary, Packet, Request, Value, ValuesCollection, Vendor, VendorCollection

Constant Summary collapse

LIBPATH =

:stopdoc:

::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
PATH =
::File.dirname(LIBPATH) + ::File::SEPARATOR

Class Method Summary collapse

Class Method Details

.libpath(*args, &block) ⇒ Object

Returns the library path for the module. If any arguments are given, they will be joined to the end of the library path using File.join.



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/radiusrb.rb', line 29

def self.libpath( *args, &block )
  rv =  args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
  if block
    begin
      $LOAD_PATH.unshift LIBPATH
      rv = block.call
    ensure
      $LOAD_PATH.shift
    end
  end
  return rv
end

.path(*args, &block) ⇒ Object

Returns the lpath for the module. If any arguments are given, they will be joined to the end of the path using File.join.



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/radiusrb.rb', line 46

def self.path( *args, &block )
  rv = args.empty? ? PATH : ::File.join(PATH, args.flatten)
  if block
    begin
      $LOAD_PATH.unshift PATH
      rv = block.call
    ensure
      $LOAD_PATH.shift
    end
  end
  return rv
end

.require_all_libs_relative_to(fname, dir = nil) ⇒ Object

Utility method used to require all files ending in .rb that lie in the directory below this file that has the same name as the filename passed in. Optionally, a specific directory name can be passed in such that the filename does not have to be equivalent to the directory.



64
65
66
67
68
69
70
# File 'lib/radiusrb.rb', line 64

def self.require_all_libs_relative_to( fname, dir = nil )
  dir ||= ::File.basename(fname, '.*')
  search_me = ::File.expand_path(
      ::File.join(::File.dirname(fname), dir, '**', '*.rb'))

  Dir.glob(search_me).sort.each {|rb| require rb}
end