Sha256: 4dc708b5282f758fdc1fe16b68ed895db78e3d5f4ac7e9eb02e22cdb2865f3f0

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

require "eventmachine"

module Invoker
  module Power
    class Setup
      attr_accessor :port_finder
      def self.install
        selected_installer_klass = installer_klass
        selected_installer_klass.new.install
      end

      def self.uninstall
        selected_installer_klass = installer_klass
        selected_installer_klass.new.uninstall_invoker
      end

      def self.installer_klass
        if Invoker.darwin?
          Invoker::Power::OsxSetup
        else
          Invoker::Power::LinuxSetup
        end
      end

      def install
        if check_if_setup_can_run?
          setup_invoker
        else
          Invoker::Logger.puts("The setup has been already run.".color(:red))
        end
        self
      end

      def drop_to_normal_user
        EventMachine.set_effective_user(ENV["SUDO_USER"])
      end

      def find_open_ports
        port_finder.find_ports()
      end

      def port_finder
        @port_finder ||= Invoker::Power::PortFinder.new()
      end

      def check_if_setup_can_run?
        !File.exists?(Invoker::Power::Config::CONFIG_LOCATION)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
invoker-1.2.0.pre1 lib/invoker/power/setup.rb
invoker-1.2.0.pre lib/invoker/power/setup.rb