Module: Labor

Defined in:
lib/labor/config.rb,
lib/labor.rb,
lib/labor/worker.rb,
lib/labor/ability.rb,
lib/labor/helpers.rb,
lib/labor/version.rb

Overview

Configuration manager for the worker. Treat it like a Hash. A hash that has a tiny DSL for setting values to it and supports grouping.

For example:

config = Config.new
config[:foo] = "bar"
config.set :hello, "world"
config.group :a_group do
  set :three_two_one, "let's jam!"
end

config.foo #=> "bar"
config.hello #=> "world"
config.a_group.three_two_one #=> "let's jam"

Defined Under Namespace

Modules: Helpers Classes: Ability, Config, Worker

Constant Summary collapse

VERSION =
Version = "0.1.3"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.verboseObject

Returns the value of attribute verbose.



57
58
59
# File 'lib/labor.rb', line 57

def verbose
  @verbose
end

Class Method Details

.configObject

Returns the configuration object for our application.

Returns the Labor::Config instance. Defaults to a new config

if nothing has been set.


52
53
54
# File 'lib/labor.rb', line 52

def self.config
  @config ||= Labor::Config.new
end

.config=(file_name) ⇒ Object

Loads in a config file.

file_name - The String path to the file.

Examples

Labor.config 'settings.rb'

Returns the Labor::Config instance.



44
45
46
# File 'lib/labor.rb', line 44

def self.config=(file_name)
  @config = Labor::Config.new.load file_name
end

.serversObject

Returns the list of server addresses we’d like to connect to.

Returns the Array of server addresses. Defaults to localhost:4730

if nothing has been set.


31
32
33
# File 'lib/labor.rb', line 31

def self.servers
  @servers || ["localhost:#{Gearman::Util::DEFAULT_PORT}"]
end

.servers=(servers) ⇒ Object

Sets the server addresses that we’d like to connect to.

servers - The String address of the server or an Array

of server addresses.

Examples

Labor.servers '10.3.4.19:4730'
Labor.servers ['10.3.4.19:4730', '10.3.4.20:4730']

Returns the Array of server addresses or String if only one was given.



23
24
25
# File 'lib/labor.rb', line 23

def self.servers=(servers)
  @servers = servers 
end