Sha256: 80430ec1b35784221749e5dfc9f02ef51408bc5744f772dc74a51bd53e33ed78

Contents?: true

Size: 1015 Bytes

Versions: 4

Compression:

Stored size: 1015 Bytes

Contents

module MyDashboard
  class << self

    delegate :scheduler, :redis, to: :config

    attr_accessor :configuration

    def config
      self.configuration ||= Configuration.new
    end

    def configure
      yield config if block_given?
    end

    def first_dashboard
      files = Dir[config.dashboards_views_path.join('*')].collect { |f| File.basename(f, '.*') }
      files.sort.first
    end

    def send_event(id, data)
      event = data.merge(id: id, updatedAt: Time.now.utc.to_i).to_json
      redis.hset("#{MyDashboard.config.redis_namespace}.latest", id, event)
      redis.publish("#{MyDashboard.config.redis_namespace}.create", event)
    end

  end
end

begin
  require 'rails'
rescue LoadError
end

$stderr.puts <<-EOC if !defined?(Rails)
warning: no framework detected.

Your Gemfile might not be configured properly.
---- e.g. ----
Rails:
    gem 'my_dashboard'

EOC

require 'my_dashboard/configuration'

if defined? Rails
  require 'my_dashboard/engine'
  require 'my_dashboard/railtie'
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
my_dashboard-0.5.1 lib/my_dashboard.rb
my_dashboard-0.5.0 lib/my_dashboard.rb
my_dashboard-0.4.2 lib/my_dashboard.rb
my_dashboard-0.4.1 lib/my_dashboard.rb