Sha256: 47af2e58dda12521e50dbaffc4f9a6e7bc8d56978131118fb96c243872934320

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

module Dashing
  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.with do |redis_connection|
        redis_connection.hset("#{Dashing.config.redis_namespace}.latest", id, event)
        redis_connection.publish("#{Dashing.config.redis_namespace}.create", event)
      end
    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 'dashing-rails'

EOC

require 'dashing/configuration'

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dashing-rails-2.6.2 lib/dashing.rb