Module: Taskr

Includes:
Models
Defined in:
lib/taskr/version.rb,
lib/taskr.rb,
lib/taskr.rb,
lib/taskr/actions.rb

Overview

:nodoc:

Defined Under Namespace

Modules: Actions, Controllers, Helpers, Models, VERSION, Views

Constant Summary collapse

@@scheduler =
nil

Class Method Summary collapse

Class Method Details

.authenticate(credentials) ⇒ Object



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

def self.authenticate(credentials)
  credentials[:username] == Taskr::Conf[:authentication][:username] &&
    credentials[:password] == Taskr::Conf[:authentication][:password]
end

.createObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/taskr.rb', line 60

def Taskr.create
  $LOG.info "Initializing Taskr..."
  Taskr::Models::Base.establish_connection(Taskr::Conf.database)
  Taskr::Models.create_schema
  
  if self::Conf[:external_actions]
    if self::Conf[:external_actions].kind_of? Array
      external_actions = self::Conf[:external_actions]
    else
      external_actions = [self::Conf[:external_actions]]
    end
    external_actions.each do |f|
      $LOG.info "Loading additional action definitions from #{self::Conf[:external_actions]}..."
      require f
    end
  end
end

.prestartObject



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/taskr.rb', line 78

def Taskr.prestart
  $LOG.info "Starting Rufus Scheduler..."
  
  Taskr.scheduler = Rufus::Scheduler.new
  Taskr.scheduler.start
  
  $LOG.debug "Scheduler is: #{Taskr.scheduler.inspect}"
  
  tasks = Taskr::Models::Task.find(:all)
  
  $LOG.info "Scheduling #{tasks.length} persisted tasks..."
  
  tasks.each do |t|
    t.schedule! Taskr.scheduler
  end
  
  Taskr.scheduler.instance_variable_get(:@scheduler_thread).run
end

.schedulerObject



29
30
31
# File 'lib/taskr.rb', line 29

def self.scheduler
  @@scheduler
end

.scheduler=(scheduler) ⇒ Object



26
27
28
# File 'lib/taskr.rb', line 26

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