Module: IRFSDash

Defined in:
lib/irfsdash.rb,
lib/irfsdash/version.rb

Constant Summary collapse

VERSION =
"0.1.2"

Class Method Summary collapse

Class Method Details

.activity(opts = {}) ⇒ Object

Publish to the activity stream Minimum: :source, :content

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
# File 'lib/irfsdash.rb', line 18

def self.activity(opts={})
  msg = opts.merge!(@defaults)
  raise ArgumentError, "No source specified" unless msg[:source]
  raise ArgumentError, "No content specified" unless msg[:content]
  raise ArgumentError, "No type specified" unless msg[:type]
  self.amqp.exchange("irfs-dashboard.activity", type: :fanout).publish(JSON.dump(msg))
end

.amqpObject

Returns an AMQP channel



6
7
8
9
10
11
# File 'lib/irfsdash.rb', line 6

def self.amqp
  return @b if @b
  @b = Bunny.new(host: 'localhost')
  @b.start
  return @b
end

.project(opts = {}) ⇒ Object

Publish a project update Minimum: :source, :project, :happy

Raises:

  • (ArgumentError)


27
28
29
30
31
32
33
# File 'lib/irfsdash.rb', line 27

def self.project(opts={})
  msg = opts.merge!(@defaults)
  raise ArgumentError, "No source specified" unless msg[:source]
  raise ArgumentError, "No project specified" unless msg[:project]
  raise ArgumentError, "No happy specified" unless msg.keys.include? :happy
  self.amqp.exchange("irfs-dashboard.projects", type: :fanout).publish(JSON.dump(msg))
end

.setup(opts = {}) ⇒ Object

Setup the library’s defaults



13
14
15
# File 'lib/irfsdash.rb', line 13

def self.setup(opts={})
  @defaults = opts
end

.ticker(opts = {}) ⇒ Object

Publish to the ticker Minimum: :source, :content, :ticker_type

Raises:

  • (ArgumentError)


36
37
38
39
40
41
42
# File 'lib/irfsdash.rb', line 36

def self.ticker(opts={})
  msg = opts.merge!(@defaults)
  raise ArgumentError, "No source specified" unless msg[:source]
  raise ArgumentError, "No content specified" unless msg[:content]
  raise ArgumentError, "No ticker type specified" unless msg[:ticker_type]
  self.amqp.exchange("irfs-dashboard.tickers", type: :fanout).publish(JSON.dump(msg))
end

.widget(opts = {}) ⇒ Object

Publish a widget Minimum: :source, (:content OR :url)

Raises:

  • (ArgumentError)


45
46
47
48
49
50
# File 'lib/irfsdash.rb', line 45

def self.widget(opts={})
  msg = opts.merge!(@defaults)
  raise ArgumentError, "No source specified" unless msg[:source]
  raise ArgumentError, "No content or URL specified" unless msg[:url] or msg[:content]
  self.amqp.exchange("irfs-dashboard.widgets", type: :fanout).publish(JSON.dump(msg))
end