Module: Whirl

Defined in:
lib/whirl.rb,
lib/whirl/redis.rb,
lib/whirl/version.rb,
lib/whirl/job/base.rb

Defined Under Namespace

Modules: Job Classes: Redis

Constant Summary collapse

VERSION =
'0.0.4'

Class Method Summary collapse

Class Method Details

.jobsObject



15
16
17
18
19
20
21
# File 'lib/whirl.rb', line 15

def self.jobs
  jobs = Whirl::Job.constants.
    map { |d| Whirl::Job.const_get(d) }.
    select { |d| d.respond_to? :perform }

  jobs -= [Whirl::Job::Base]
end

.loop?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/whirl.rb', line 42

def self.loop?
  true
end

.runObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/whirl.rb', line 23

def self.run
  trap("SIGINT") do
    Whirl::Job::Base.newline
    Whirl::Job::Base.say "Whirled.", :green
    Whirl::Job::Base.newline
    exit 0
  end

  begin
    jobs.each do |j|
      fork do
        j.perform
      end
    end

    sleep whirl_interval.to_i
  end while loop?
end

.whirl_intervalObject



46
47
48
# File 'lib/whirl.rb', line 46

def self.whirl_interval
  ENV['WHIRL_LOOP_INTERVAL'] || 10
end