Sha256: 2f9e70ace186212304afc1f1a9a4ca3adca6b378aa89e4450d07efc0b90693a0

Contents?: true

Size: 743 Bytes

Versions: 10

Compression:

Stored size: 743 Bytes

Contents

# frozen_string_literal: true

module StatsLite
  class App < Sinatra::Base
    before do
      password = params[:password]
      conf_pass = StatsLite.configure.password

      if conf_pass && conf_pass != password
        halt 404, { "Content-Type" => "text/plain" }, ""
      end
    end

    get "/" do
      content_type :json

      result.to_json
    end

    private
      def result
        default = Default
        result = {
          time_utc: Time.now.utc.strftime("%e %b %Y %H:%M:%S%p").strip,
          host: default.host,
          cpu: default.cpu,
          ram: default.ram,
          hdd: default.hdd
        }

        data = StatsLite.configure.data
        data.call(result) if data
        result
      end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
stats_lite-0.7.0 lib/stats_lite/app.rb
stats_lite-0.6.2 lib/stats_lite/app.rb
stats_lite-0.6.1 lib/stats_lite/app.rb
stats_lite-0.6.0 lib/stats_lite/app.rb
stats_lite-0.5.4 lib/stats_lite/app.rb
stats_lite-0.5.3 lib/stats_lite/app.rb
stats_lite-0.5.2 lib/stats_lite/app.rb
stats_lite-0.5.1 lib/stats_lite/app.rb
stats_lite-0.5.0 lib/stats_lite/app.rb
stats_lite-0.1.0 lib/stats_lite/app.rb