Sha256: 91a0e1de6df8804cc019b514f1e8d40efd47bb15267d4b37842157fc686869e2

Contents?: true

Size: 1.64 KB

Versions: 1

Compression:

Stored size: 1.64 KB

Contents

module ActiveScripts
  module Packages
    class Ruby < ActiveScripts::Packages::Base

      # INFO: ActiveScripts::Packages::Ruby contains code that
      #   execute the ruby package.

      private

      def install
        output = ask("   [?] Which version? ") { |q| q.default = "2.2.2" }

        if package_installed?("ruby -v", includes: output)
          notify_package_exists!
        else
          case $operating_system
          when :macosx, :linux
            begin
              Timeout::timeout(600) do
                execute_command!("rbenv install #{output}") unless package_installed?("rbenv versions", includes: output)
              end
            rescue Timeout::Error => e
              ##
            ensure
              execute_command!("rbenv rehash")
              execute_command!("rbenv global #{output}")
              execute_command!("echo 'gem: --no-ri --no-rdoc' >> ~/.gemrc")
              execute_command!("gem update --system")
              say_ok("   Installation complete!")
            end
          else
            notify_package_unavailable!
          end
        end
      end

      def upgrade
        if package_installed?("ruby -v")
          execute_command!("gem update --system")
          say_ok("   Upgrade complete!")
        else
          notify_package_missing!
        end
      end

      def uninstall
        if package_installed?("ruby -v")
          output = ask("   [?] Which version? ") { |q| q.default = "2.2.2" }
          execute_command!("rbenv uninstall #{output}")
          say_ok("   Uninstallation complete!")
        else
          notify_package_missing!
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_scripts-0.1.0 lib/active_scripts/packages/ruby.rb