Sha256: 10d5bc59f9e1cbdd4778e3ec8fd7f4882a806675c340bd429f56b57886818fbc

Contents?: true

Size: 1.1 KB

Versions: 7

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_file)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
invoker-1.4.1 lib/invoker/power/setup.rb
invoker-1.4.0 lib/invoker/power/setup.rb
invoker-1.3.2 lib/invoker/power/setup.rb
invoker-1.3.1 lib/invoker/power/setup.rb
invoker-1.3.0 lib/invoker/power/setup.rb
invoker-1.2.0 lib/invoker/power/setup.rb
invoker-1.2.0.pre2 lib/invoker/power/setup.rb