Class: Atech::StatsReporter
- Inherits:
-
Object
- Object
- Atech::StatsReporter
- Defined in:
- lib/atech/stats_reporter.rb
Overview
The aTech stats reporter return information about the application which can be access by accessing the stats URL. This should be configured in your application initializer.
Atech::StatsReporter.application_name = ‘my-application’ Atech::StatsReporter.application_key = ‘your random key here’ Atech::StatsReporter.stats = Proc.new do
{
:last_activity => Event.last.created_at,
:projects => Project.count,
:repositories => Repositories::Repository.count,
:disk_usage => Repositories::Repository.sum(:disk_usage)
}
end
Class Attribute Summary collapse
-
.application_key ⇒ Object
Returns the value of attribute application_key.
-
.application_name ⇒ Object
Returns the value of attribute application_name.
-
.stats ⇒ Object
Returns the value of attribute stats.
Class Method Summary collapse
Instance Method Summary collapse
Class Attribute Details
.application_key ⇒ Object
Returns the value of attribute application_key.
21 22 23 |
# File 'lib/atech/stats_reporter.rb', line 21 def application_key @application_key end |
.application_name ⇒ Object
Returns the value of attribute application_name.
20 21 22 |
# File 'lib/atech/stats_reporter.rb', line 20 def application_name @application_name end |
.stats ⇒ Object
Returns the value of attribute stats.
22 23 24 |
# File 'lib/atech/stats_reporter.rb', line 22 def stats @stats end |
Class Method Details
.repo_stats ⇒ Object
34 35 36 37 38 39 |
# File 'lib/atech/stats_reporter.rb', line 34 def repo_stats @repo_stats ||= { :ref => `git log --pretty='%H' -n 1`.chomp, :path => `git remote show -n origin | grep Fetch`.split(/\:\s*/, 2).last.strip } end |
Instance Method Details
#_call(env) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/atech/stats_reporter.rb', line 46 def _call(env) req = Rack::Request.new(env) if req.params['key'] != self.class.application_key return [403, {}, ["Access Denied"]] end hash = { :name => self.class.application_name, :repo => self.class.repo_stats, :props => self.class.stats.call } [200, {}, [ActiveSupport::JSON.encode(hash)]] end |
#call(env) ⇒ Object
42 43 44 |
# File 'lib/atech/stats_reporter.rb', line 42 def call(env) dup._call(env) end |