Class: Lono::ProjectChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/lono/project_checker.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.checkObject

If not, provide a friendly message and exit.



4
5
6
# File 'lib/lono/project_checker.rb', line 4

def self.check
  new.check
end

Instance Method Details

#checkObject



8
9
10
11
12
# File 'lib/lono/project_checker.rb', line 8

def check
  config_folder_exist
  templates_folder_exist
  empty_folders
end

#config_folder_existObject



14
15
16
17
18
19
# File 'lib/lono/project_checker.rb', line 14

def config_folder_exist
  unless File.exist?("#{Lono.root}/config")
    puts "The config folder does not exist in this project.  Are you sure this is a lono project?"
    quit
  end
end

#empty_foldersObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/lono/project_checker.rb', line 28

def empty_folders
  if Dir["#{Lono.root}/config/**/*.rb"].empty?
    puts "The config folder does not contain any lono template definitions."
    quit
  end
  if Dir["#{Lono.root}/templates/**/*"].empty?
    puts "The templates folder does not contain any lono template definitions."
    quit
  end
end

#quitObject



39
40
41
42
43
44
45
# File 'lib/lono/project_checker.rb', line 39

def quit
  if ENV['TEST'] == '1'
    raise("Not in lono project")
  else
    exit 1
  end
end

#templates_folder_existObject



21
22
23
24
25
26
# File 'lib/lono/project_checker.rb', line 21

def templates_folder_exist
  unless File.exist?("#{Lono.root}/templates")
    puts "The templates folder does not exist in this project.  Are you sure this is a lono project?"
    quit
  end
end