Sha256: 19d423270b92df5b32bfb84f867fc5a60dcc5bc97f28d9c4455dc86c4aed3d6b

Contents?: true

Size: 1.97 KB

Versions: 8

Compression:

Stored size: 1.97 KB

Contents

require 'autoproj/cli/base'
require 'rubygems'

module Autoproj
module CLI
    class Version < Base
        # List the version of autoproj and optionally include
        # the installed dependencies with information about the requirement
        # and the actual used version
        def run(args, options = Hash.new)
            puts "autoproj version: #{Autoproj::VERSION}"
            return unless options[:deps]

            dependency = Gem::Deprecate.skip_during do
                Gem::Dependency.new "autoproj", Autoproj::VERSION
            end
            autoproj_spec = dependency.matching_specs
            return if autoproj_spec.empty?

            installed_deps = collect_dependencies(dependency)
            puts "    specified dependencies:"
            autoproj_spec.first.dependencies.each do |dep|
                puts "        #{dep}: #{installed_deps[dep.name] || 'n/a'}"
                installed_deps.delete(dep.name)
            end
            puts "    implicit dependencies:"
            installed_deps.keys.sort.each do |name|
                puts "        #{name}: #{installed_deps[name]}" unless name == "autoproj"
            end
        end

        # Collect the dependencies of a given dependency
        # @param [Gem::Dependency] dependency a gem depencency
        # @param [Array<Gem::Dependency] list of already known dependencies
        #
        # @return [Array<Gem::Dependency>] all known dependencies
        def collect_dependencies(dependency, known_dependencies: {})
            dep_spec = dependency.matching_specs
            return known_dependencies if dep_spec.empty?

            dep_spec = dep_spec.first
            known_dependencies[dep_spec.name] = dep_spec.version
            dep_spec.dependencies.each do |dep|
                if !known_dependencies.has_key?(dep.name)
                    collect_dependencies(dep, known_dependencies: known_dependencies)
                end
            end
            known_dependencies
        end
    end
end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
autoproj-2.14.0 lib/autoproj/cli/version.rb
autoproj-2.13.0 lib/autoproj/cli/version.rb
autoproj-2.12.1 lib/autoproj/cli/version.rb
autoproj-2.12.0 lib/autoproj/cli/version.rb
autoproj-2.11.0 lib/autoproj/cli/version.rb
autoproj-2.10.2 lib/autoproj/cli/version.rb
autoproj-2.10.1 lib/autoproj/cli/version.rb
autoproj-2.10.0 lib/autoproj/cli/version.rb