Class: Daemonizer::Dsl
- Inherits:
-
Object
- Object
- Daemonizer::Dsl
- Defined in:
- lib/daemonizer/dsl.rb
Class Method Summary collapse
Instance Method Summary collapse
- #after_init(&blk) ⇒ Object
- #before_init(&blk) ⇒ Object
- #engine(name) ⇒ Object
- #handler(handler) ⇒ Object
-
#initialize ⇒ Dsl
constructor
A new instance of Dsl.
- #log_file(log) ⇒ Object
- #not_cow_friendly ⇒ Object
- #pid_file(pid) ⇒ Object
- #poll_period(seconds) ⇒ Object
- #pool(name, &blk) ⇒ Object
- #set_option(option, value = nil, &block) ⇒ Object
- #workers(num) ⇒ Object
Constructor Details
#initialize ⇒ Dsl
Returns a new instance of Dsl.
10 11 12 13 14 15 |
# File 'lib/daemonizer/dsl.rb', line 10 def initialize @source = nil @options = {} @pool = :default @configs = {} end |
Class Method Details
.evaluate(gemfile) ⇒ Object
4 5 6 7 8 |
# File 'lib/daemonizer/dsl.rb', line 4 def self.evaluate(gemfile) builder = new builder.instance_eval(File.read(gemfile.to_s), gemfile.to_s, 1) builder.instance_variable_get("@configs") end |
Instance Method Details
#after_init(&blk) ⇒ Object
56 57 58 |
# File 'lib/daemonizer/dsl.rb', line 56 def after_init(&blk) @options[:after_init] = blk end |
#before_init(&blk) ⇒ Object
52 53 54 |
# File 'lib/daemonizer/dsl.rb', line 52 def before_init(&blk) @options[:before_init] = blk end |
#engine(name) ⇒ Object
48 49 50 |
# File 'lib/daemonizer/dsl.rb', line 48 def engine(name) @options[:engine] = name.to_sym end |
#handler(handler) ⇒ Object
32 33 34 |
# File 'lib/daemonizer/dsl.rb', line 32 def handler(handler) @options[:handler] = handler end |
#log_file(log) ⇒ Object
40 41 42 |
# File 'lib/daemonizer/dsl.rb', line 40 def log_file(log) @options[:log_file] = log end |
#not_cow_friendly ⇒ Object
28 29 30 |
# File 'lib/daemonizer/dsl.rb', line 28 def not_cow_friendly @options[:cow_friendly] = false end |
#pid_file(pid) ⇒ Object
60 61 62 |
# File 'lib/daemonizer/dsl.rb', line 60 def pid_file(pid) @options[:pid_file] = pid end |
#poll_period(seconds) ⇒ Object
36 37 38 |
# File 'lib/daemonizer/dsl.rb', line 36 def poll_period(seconds) @options[:poll_period] = seconds.to_i end |
#pool(name, &blk) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/daemonizer/dsl.rb', line 64 def pool(name, &blk) @pool = name.to_sym = @options.dup yield @configs[@pool] = Daemonizer::Config.new(@pool, @options) rescue Daemonizer::Config::ConfigError => e puts "* Error in pool \"#{@pool}\": #{e.to_s}. Skipping..." ensure @options = @pool = nil end |
#set_option(option, value = nil, &block) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/daemonizer/dsl.rb', line 17 def set_option(option, value = nil, &block) @options[:handler_options] ||= {} if value @options[:handler_options][option.to_sym] = Daemonizer::Option.new(option, value) elsif block_given? @options[:handler_options][option.to_sym] = Daemonizer::Option.new(option, block, true) else raise DslError, "you should supply block or value to :set_option" end end |
#workers(num) ⇒ Object
44 45 46 |
# File 'lib/daemonizer/dsl.rb', line 44 def workers(num) @options[:workers] = num.to_i end |