Module: VersionLS
- Defined in:
- lib/vls.rb,
lib/vls/version.rb
Overview
The Version LiSt utility module.
Constant Summary collapse
- STRING =
VERSION = "0.4.0"
- DESCRIPTION =
"A CLI and Rails console utility that lists the versions of " + "modules used by the specified gems/ruby files or Rails project."
Class Method Summary collapse
-
.modules(filter) ⇒ Object
Get a list of modules that have VERSION info.
-
.print_vls(filter) ⇒ Object
Perform a Versioned LiSt to the console.
-
.vls(filter = /./) ⇒ Object
Execute the core of the vls command and return an array of [module, version] arrays.
Class Method Details
.modules(filter) ⇒ Object
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.
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/vls.rb', line 37 def self.modules(filter) mods = ObjectSpace.each_object(Module). select do |mod| mod.const_defined?("VERSION") && mod.name.partition(filter)[1] != "" end. sort do |first, second| first.name <=> second.name end mods end |
.print_vls(filter) ⇒ Object
Perform a Versioned LiSt to the console.
Parameters
-
filter - a string or regex used to filter the list of modules.
11 12 13 14 |
# File 'lib/vls.rb', line 11 def self.print_vls(filter) vls(filter).each{|mod| puts "#{mod[0]}, #{mod[1]}"} nil end |
.vls(filter = /./) ⇒ Object
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.
20 21 22 23 24 25 26 27 28 29 30 |
# 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 |