aboutsummaryrefslogtreecommitdiff
path: root/start.rb
blob: 3ec3c48b7b1c054ecf4c7ba0750d974c6fb9e80d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""
This file is part of cassiopeia and licensed
under the GNU Public License 3.0 (or later)

cassiopeia-start - start working on an account

This file is included and run from cass(1)
"""

require "time"
require_relative "time_util"

def start(account, round, file = [])
  rel = file.select { |i| i[:title].to_s.include? account }

  # This is a kind of fuzzy find
  account = rel[0][:title].to_s[0..-2]

  # Check if there's any ling jobs
  jobs = rel.select { |i| i[:stop] == nil }.length
  STDERR.puts \
    "[Warn]: #{jobs} dangling jobs for account #{account}" if jobs > 0

  "#{account}:    #{round ? Time.now.round : Time.now} - "
end