Module: Labor

Defined in:
lib/labor/config.rb,
lib/labor.rb,
lib/labor/worker.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: Config, Worker

Constant Summary collapse

VERSION =
Version = "0.1.2"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.verboseObject

Returns the value of attribute verbose.



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

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.


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

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.



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

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.


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

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.



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

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