Module: VersionLS

Defined in:
lib/vls.rb,
lib/vls/version.rb

Overview

The Version LiSt utility module.

Constant Summary collapse

STRING =
VERSION = "0.4.2"
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

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
# 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

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