Class: Roundhouse::Script

Inherits:
Wolverine::Script
  • Object
show all
Defined in:
lib/roundhouse/script.rb

Overview

Modifies the Shopify Wolverine library. The Roundhouse::Script will take a string and load it up to redis directly. No method-missing, no autoloading, no templating. Optionally pass a :name, so we can collect stats. Otherwise it will be the SHA1 hash

Defined Under Namespace

Classes: Configuration

Instance Method Summary collapse

Constructor Details

#initialize(content, options = {}) ⇒ Script

Returns a new instance of Script.



10
11
12
13
14
15
# File 'lib/roundhouse/script.rb', line 10

def initialize content, options = {}
  @content = content
  @digest  = Digest::SHA1.hexdigest @content
  @config  = options[:config] || fail('Must supply a Wolverine::Configuration object')
  @name    = options[:name] || @digest
end

Instance Method Details

#instrument(eval_type) ⇒ Object



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

def instrument eval_type
  ret = nil
  runtime = Benchmark.realtime { ret = yield }
  @config.instrumentation.call @name, runtime, eval_type
  ret
end

#statsdObject



17
18
19
# File 'lib/roundhouse/script.rb', line 17

def statsd
  "Wolverine.#{@name}"
end