Module: Hyperfocal

Defined in:
lib/hyperfocal.rb,
lib/hyperfocal/version.rb,
lib/hyperfocal/commands.rb,
lib/hyperfocal/transmitter.rb

Defined Under Namespace

Modules: Transmitter Classes: Commands, Configuration

Constant Summary collapse

VERSION =
"0.4.1"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject

Returns the value of attribute configuration.



8
9
10
# File 'lib/hyperfocal.rb', line 8

def configuration
  @configuration
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Yields:



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

def configure
  self.configuration ||= Configuration.new
  yield(configuration)
end

.event(event, attrs = {}) ⇒ Object



21
22
23
24
25
26
# File 'lib/hyperfocal.rb', line 21

def event(event, attrs = {})
  send_request do
    event_params = { event: attrs.merge(title: event) }
    Transmitter.send('event', event_params)
  end
end

.hostObject



15
16
17
18
19
# File 'lib/hyperfocal.rb', line 15

def host
  raise 'App ID Not Set' if configuration.app_id.nil?

  configuration.host + '/track/' + configuration.app_id
end

.loggerObject



43
44
45
# File 'lib/hyperfocal.rb', line 43

def logger
  Logger.new(STDOUT)
end

.metric(metric, value, attrs = {}) ⇒ Object



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

def metric(metric, value, attrs = {})
  send_request do
    metric_params = { metric: attrs.merge(title: metric, value: value) }
    Transmitter.send('metric', metric_params)
  end
end

.send_request(&block) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/hyperfocal.rb', line 35

def send_request(&block)
  thr = Thread.new do
    yield
  end
  thr.join
  thr.exit
end