Class: Google::Cloud::Gemserver::Backend::Stats

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/gemserver/backend/stats.rb

Overview

Stats

Stats provides a set of methods that display detailed information about the deployed gemserver. It includes: general Google Cloud Platform project information, how long the gemserver has been running , what private gems are stored, and what gems have been cached.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStats

Initialize a Configuration object and project ID for the Stats object enabling it to fetch detailed information about the gemserver.



42
43
44
45
# File 'lib/google/cloud/gemserver/backend/stats.rb', line 42

def initialize
  @config = Google::Cloud::Gemserver::Configuration.new
  @proj = (@config[:proj_id] || nil).freeze
end

Instance Attribute Details

#projString

The project ID of the project on Google Cloud Platform the gemserver was deployed to.

Returns:

  • (String)


36
37
38
# File 'lib/google/cloud/gemserver/backend/stats.rb', line 36

def proj
  @proj
end

Instance Method Details

#log_app_descriptionObject

Displays information about the project on Google Cloud Platform the gemserver was deployed to.



61
62
63
64
65
66
# File 'lib/google/cloud/gemserver/backend/stats.rb', line 61

def log_app_description
  return "" if ENV["APP_ENV"] == "test"
  puts "Project Information:"
  cmd = "gcloud app describe --project #{@proj}"
  puts run_cmd(cmd).gsub("\n", "\n\t").prepend "\t"
end

#runObject

Displays various sets of information about the gemserver such as how long it has been running, currently stored, private gems and their status, and cached gems.



51
52
53
54
55
56
# File 'lib/google/cloud/gemserver/backend/stats.rb', line 51

def run
  resp = ""
  resp << log_uptime
  resp << log_private_gems
  resp << log_cached_gems
end