module Jobly

Constants

VERSION

Public Class Methods

config_file() click to toggle source
# File lib/jobly/module_functions.rb, line 85
def config_file
  File.expand_path 'jobly.rb', full_config_path
end
configure() { |self| ... } click to toggle source
# File lib/jobly/module_functions.rb, line 3
def configure
  yield self
end
custom_config?() click to toggle source
# File lib/jobly/module_functions.rb, line 89
def custom_config?
  File.exist? config_file
end
default_options() click to toggle source
# File lib/jobly/module_functions.rb, line 11
def default_options
  {
    root: Dir.pwd,
    environment: ENV['JOBLY_ENVIRONMENT'] || 'development',
    api_url: ENV['JOBLY_API_URL'] || 'http://localhost:3000/do',
    app_path: ENV['JOBLY_APP_PATH'] || 'app',
    jobs_path: ENV['JOBLY_JOBS_PATH'] || "jobs",
    config_path: ENV['JOBLY_CONFIG_PATH'] || "config",
    redis_url: ENV['JOBLY_REDIS_URL'] || "redis://localhost:6379/0",
    status_expiration: ENV['JOBLY_STATUS_EXPIRATION']&.to_i || 30,
    jobs_namespace: ENV['JOBLY_JOBS_NAMESPACE'],
    slack_webhook: ENV['JOBLY_SLACK_WEBHOOK'],
    slack_channel: ENV['JOBLY_SLACK_CHANNEL'] || "#general",
    slack_user: ENV['JOBLY_SLACK_USER'] || "Jobly",
    log: ENV['JOBLY_LOG'],
    log_level: ENV['JOBLY_LOG_LEVEL'] || 'info',
    auth: ENV['JOBLY_AUTH'],
    shell_dry_run: ENV['JOBLY_SHELL_DRY_RUN'],
    mounts: nil,
  }
end
full_app_path() click to toggle source
# File lib/jobly/module_functions.rb, line 73
def full_app_path
  File.expand_path app_path, root
end
full_config_path() click to toggle source
# File lib/jobly/module_functions.rb, line 81
def full_config_path
  File.expand_path config_path, root
end
full_jobs_path() click to toggle source
# File lib/jobly/module_functions.rb, line 77
def full_jobs_path
  File.expand_path jobs_path, root
end
load_custom_config() click to toggle source
# File lib/jobly/module_functions.rb, line 7
def load_custom_config
  require config_file if File.exist? config_file
end
log=(target) click to toggle source
# File lib/jobly/module_functions.rb, line 59
def log=(target)
  options[:log] = target
  @logger = if target.is_a? Logger
    target
  elsif target
    Log.new target, :jobly
  else
    nil
  end

  @logger.level = log_level if @logger and @logger.respond_to? :level
  @logger
end
logger() click to toggle source
# File lib/jobly/module_functions.rb, line 55
def logger
  @logger
end
method_missing(method, args=nil, &_block) click to toggle source
Calls superclass method
# File lib/jobly/module_functions.rb, line 33
def method_missing(method, args=nil, &_block)
  key = method.to_s
  assign = key[-1] == "="
  key = key.chomp('=') if assign
  key = key.to_sym

  if options.has_key? key
    assign ? options[key] = args : options[key]
  else
    super
  end
end
options() click to toggle source
# File lib/jobly/module_functions.rb, line 51
def options
  @options ||= default_options.dup
end
respond_to_missing?(method, include_private=false) click to toggle source
Calls superclass method
# File lib/jobly/module_functions.rb, line 46
def respond_to_missing?(method, include_private=false)
  key = method.to_s.chomp('=').to_sym
  options.has_key?(key) ? true : super
end