Sha256: f0aa567e27c5189c8009916617191f2ed857b97e19850272f5d0a703a7d12bf7

Contents?: true

Size: 1.27 KB

Versions: 8

Compression:

Stored size: 1.27 KB

Contents

require_relative "../commands/rbenv"
require_relative "../commands/vcs"

require_relative "fs"
require_relative "vcs"

module Autowow
  module Features
    module Rbenv
      include EasyLogging
      include Commands::Rbenv
      include Executor
      include StringDecorator

      def ruby_versions
        logger.info(used_versions)
      end

      def used_versions
        rubies = []
        Fs.in_place_or_subdirs(Vcs.is_git?) do
          result = quiet.run!(version)
          rubies.concat(result.out.clean_lines) if result.success?
        end
        rubies.uniq
      end

      def ruby_aliases
        ret = {}
        result = quiet.run!(aliases)
        return ret unless result.success?
        result.out.clean_lines.each do |line|
          ret[line.split(" => ")[0]] = line.split(" => ")[1]
        end
        ret
      end

      def obsolete_versions
        alias_map = ruby_aliases
        used_versions_and_aliases = used_versions
        used_versions.each do |v|
          used_versions_and_aliases.push(alias_map[v]) if alias_map.has_key?(v)
        end
        quiet.run(installed_versions).out.clean_lines - used_versions_and_aliases
      end

      include ReflectionUtils::CreateModuleFunctions
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
autowow-0.14.2 lib/autowow/features/rbenv.rb
autowow-0.14.1 lib/autowow/features/rbenv.rb
autowow-0.14.0 lib/autowow/features/rbenv.rb
autowow-0.13.2 lib/autowow/features/rbenv.rb
autowow-0.13.1 lib/autowow/features/rbenv.rb
autowow-0.13.0 lib/autowow/features/rbenv.rb
autowow-0.9.0 lib/autowow/features/rbenv.rb
autowow-0.8.1 lib/autowow/features/rbenv.rb