Module: Gemlock::Config

Defined in:
lib/gemlock/config.rb

Class Method Summary collapse

Class Method Details

.emailObject



14
15
16
17
18
19
20
21
22
# File 'lib/gemlock/config.rb', line 14

def email
  email = parsed['email'] if parsed

  if email =~ /^[^@]+@[^@]+$/
    email
  else
    nil
  end
end

.fileObject



4
5
6
7
8
# File 'lib/gemlock/config.rb', line 4

def file
  if defined?(Rails) && File.exists?(Rails.root.join('config', 'gemlock.yml'))
    Rails.root.join('config', 'gemlock.yml')
  end
end

.parsedObject



10
11
12
# File 'lib/gemlock/config.rb', line 10

def parsed
  parsed = YAML.load_file(file) if file
end

.update_intervalObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/gemlock/config.rb', line 24

def update_interval
  if parsed
    if parsed["interval"]
      interval = parsed["interval"][0]

      num_hours = interval.match(/\d*/)[0].to_i
      if interval =~ /hour/
        delay = 60*60
      elsif interval =~ /day/
        delay = 60*60*24
      elsif interval =~ /week/
        delay = 60*60*24*7
      elsif interval =~ /month/
        delay = 60*60*24*30
      end
      if delay && num_hours > 0
        delay *= num_hours
        return delay
      elsif delay
        return delay
      end
    end
  end
  60*60*24*7*2 #Seconds in 2 weeks
end