Class: Licit::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/licit/command.rb

Instance Method Summary collapse

Instance Method Details

#check(licenser) ⇒ Object



13
14
15
16
17
# File 'lib/licit/command.rb', line 13

def check(licenser)
  (licenser.check_files | licenser.check_headers).each do |severity, file, message|
    puts message
  end
end

#find_file(probes) ⇒ Object



33
34
35
36
37
38
# File 'lib/licit/command.rb', line 33

def find_file probes
  probes.each do |file|
    return file if File.exist? file
  end
  nil
end

#fix(licenser) ⇒ Object



19
20
21
22
# File 'lib/licit/command.rb', line 19

def fix(licenser)
  licenser.fix_files
  licenser.fix_headers
end

#load_configObject



24
25
26
27
28
29
30
31
# File 'lib/licit/command.rb', line 24

def load_config
  config_file = find_file ['licit.yml', 'config/licit.yml']
  unless config_file
    puts "Could not find licit.yml config file"
    exit 1
  end
  YAML.load_file(config_file).each_with_object({}) { |(k,v), h| h[k.to_sym] = v }
end

#runObject



4
5
6
7
8
9
10
11
# File 'lib/licit/command.rb', line 4

def run
  licenser = Licit::Licenser.new load_config
  if ARGV[0] == 'fix'
    fix licenser
  else
    check licenser
  end
end