module VersionLS
The Version LiSt utility module.
Constants
- DESCRIPTION
- STRING
Public Class Methods
modules(filter)
click to toggle source
Get a list of modules that have VERSION info.
Parameters
-
filter - a string or regex used to filter the list of modules.
Returns
-
An array of module objects.
# File lib/vls.rb, line 37 def self.modules(filter) regex = Regexp.new(filter) ObjectSpace.each_object(Module) .select {|mod| mod.const_defined?("VERSION") && mod.name =~ regex} .sort {|first, second| first.name <=> second.name} end
print_vls(filter)
click to toggle source
Perform a Versioned LiSt to the console.
Parameters
-
filter - a string or regex used to filter the list of modules.
# File lib/vls.rb, line 11 def self.print_vls(filter) vls(filter).each{|mod| puts "#{mod[0]}, #{mod[1]}"} nil end
vls(filter=/./)
click to toggle source
Execute the core of the vls command and return an array of
- module, version
-
arrays.
Parameters
-
filter - a string or regex used to filter the list of modules.
# File lib/vls.rb, line 20 def self.vls(filter=/./) modules(filter).map do |mod| begin version = mod::VERSION rescue version = 'version ???' end [mod, version.to_vls_version_string] end end