Module: Mdash

Defined in:
lib/mdash.rb,
lib/mdash/engine.rb,
lib/mdash/version.rb,
app/models/mdash/metric.rb,
lib/mdash/configuration.rb,
app/jobs/mdash/application_job.rb,
app/models/mdash/application_record.rb,
app/helpers/mdash/application_helper.rb,
app/mailers/mdash/application_mailer.rb,
app/controllers/mdash/stats_controller.rb,
lib/generators/mdash/install_generator.rb,
app/controllers/mdash/announce_controller.rb,
app/controllers/mdash/application_controller.rb

Defined Under Namespace

Modules: ApplicationHelper, Generators Classes: AnnounceController, ApplicationController, ApplicationJob, ApplicationMailer, ApplicationRecord, Configuration, Engine, Error, Metric, StatsController

Constant Summary collapse

VERSION =
"0.2.0"

Class Method Summary collapse

Class Method Details

.configObject



14
15
16
# File 'lib/mdash.rb', line 14

def config
  @config ||= Configuration.new
end

.configure {|config| ... } ⇒ Object

Yields:



10
11
12
# File 'lib/mdash.rb', line 10

def configure
  yield config
end

.last_updatedObject



30
31
32
# File 'lib/mdash.rb', line 30

def last_updated
  @last_updated
end

.statsObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/mdash.rb', line 18

def stats
  # Check the last time stats were updated
  # If it's been more than 5 minutes, update the stats
  if @last_updated.nil? || @last_updated < config.cache_expiry.ago
    @stats = config.metrics.each_with_object({}) do |metric, stats|
      stats[metric.id] = metric.data
    end
    @last_updated = Time.now
  end
  @stats
end