Method: ElchScan::Application::Dispatch#dispatch_info

Defined in:
lib/elch_scan/application/dispatch.rb

#dispatch_infoObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/elch_scan/application/dispatch.rb', line 35

def dispatch_info
  logger.log_without_timestr do
    log ""
    log "     Your version: #{your_version = Gem::Version.new(ElchScan::VERSION)}"

    # get current version
    logger.log_with_print do
      log "  Current version: "
      if cfg("application.check_version")
        require "net/http"
        log c("checking...", :blue)

        begin
          current_version = Gem::Version.new Net::HTTP.get_response(URI.parse(ElchScan::UPDATE_URL)).body.strip

          if current_version > your_version
            status = c("#{current_version} (consider update)", :red)
          elsif current_version < your_version
            status = c("#{current_version} (ahead, beta)", :green)
          else
            status = c("#{current_version} (up2date)", :green)
          end
        rescue
          status = c("failed (#{$!.message})", :red)
        end

        logger.raw "#{"\b" * 11}#{" " * 11}#{"\b" * 11}", :print # reset cursor
        log status
      else
        log c("check disabled", :red)
      end
    end

    # more info
    log ""
    log "  ElchScan is brought to you by #{c "bmonkeys.net", :green}"
    log "  Contribute @ #{c "github.com/2called-chaos/elch_scan", :cyan}"
    log "  Eat bananas every day!"
    log ""
  end
end