Sha256: 602628f4e6736d49b620a3c20e60bc245012e44ee0aab861676b914e7ce69d4e

Contents?: true

Size: 1.98 KB

Versions: 6

Compression:

Stored size: 1.98 KB

Contents

# coding: utf-8
module Splash
  module Exiter
    include Splash::Loggers
    EXIT_MAP= {

       # context execution
       :not_root => {:message => "This operation need to be run as root (use sudo or rvmsudo)", :code => 10},
       :options_incompatibility => {:message => "Options incompatibility", :code => 40},
       :service_dependence_missing => {:message => "Splash Service dependence missing", :code => 60},

       # config
       :specific_config_required => {:message => "Specific configuration required", :code => 30},
       :splash_setup_error => {:message => "Splash Setup terminated unsuccessfully", :code => 25},
       :splash_setup_success => {:message => "Splash Setup terminated successfully", :code => 0},
       :splash_sanitycheck_error => {:message => "Splash Sanitycheck terminated unsuccessfully", :code => 20},
       :splash_sanitycheck_success => {:message => "Splash Sanitycheck terminated successfully", :code => 0},
       :configuration_error => {:message => "Splash Configuration Error", :code => 50},


       # global
       :quiet_exit => {:code => 0},

       # events
       :interrupt => {:message => "Splash user operation interrupted", :code => 33},

       # request
       :not_found => {:message => "Object not found", :code => 44},
       :already_exist => {:message => "Object already exist", :code => 48},

       # daemon
       :status_ok => {:message => "Status OK", :code => 0},
       :status_ko => {:message => "Status KO", :code => 31}

    }

    def splash_exit(options = {})
      log = get_logger
      mess = ""
      mess = EXIT_MAP[options[:case]][:message] if EXIT_MAP[options[:case]].include? :message
      mess << " : " unless mess.empty? or not options[:more]
      mess << "#{options[:more]}" if options[:more]
      if  EXIT_MAP[options[:case]][:code] == 0 then
        log.success mess unless mess.empty?
        exit 0
      else
        log.fatal mess unless mess.empty?
        exit EXIT_MAP[options[:case]][:code]
      end
    end



  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
prometheus-splash-0.4.5 lib/splash/exiter.rb
prometheus-splash-0.4.4 lib/splash/exiter.rb
prometheus-splash-0.4.3 lib/splash/exiter.rb
prometheus-splash-0.4.2 lib/splash/exiter.rb
prometheus-splash-0.4.1 lib/splash/exiter.rb
prometheus-splash-0.4.0 lib/splash/exiter.rb