class Viperaptor::Rambafile
Public Class Methods
exist()
click to toggle source
# File lib/viperaptor/helpers/rambafile.rb, line 23 def self.exist Dir[RAMBAFILE_NAME + "*"].count > 0 end
rambafile()
click to toggle source
# File lib/viperaptor/helpers/rambafile.rb, line 32 def self.rambafile if @@rambafile == nil if @@rambafile_name == nil files = Dir[RAMBAFILE_NAME + "*"] if files.count == 0 puts("No Rambafile found".red) exit end if files.count == 1 @@rambafile_name = files[0] else prompt = TTY::Prompt.new choices = files.sort @@rambafile_name = prompt.select("Select Rambafile?", choices, per_page: choices.count) end end if @@rambafile_name.start_with?(RAMBAFILE_NAME) @@rambafile_name_suffix = @@rambafile_name[RAMBAFILE_NAME.length..-1] else @@rambafile_name_suffix = "_" + @@rambafile_name end self.validate @@rambafile = YAML.load_file(@@rambafile_name) self.load_defaults end @@rambafile end
suffix(name)
click to toggle source
# File lib/viperaptor/helpers/rambafile.rb, line 27 def self.suffix(name) self.rambafile name + @@rambafile_name_suffix end
use(name)
click to toggle source
# File lib/viperaptor/helpers/rambafile.rb, line 19 def self.use(name) @@rambafile_name = name end
Private Class Methods
load_defaults()
click to toggle source
# File lib/viperaptor/helpers/rambafile.rb, line 76 def self.load_defaults @@rambafile[CATALOGS_KEY] = rambafile[CATALOGS_KEY] || [] @@rambafile[TEMPLATES_KEY] = rambafile[TEMPLATES_KEY] || [] @@rambafile[COMPANY_KEY] = @@rambafile[COMPANY_KEY] || '' end
validate()
click to toggle source
# File lib/viperaptor/helpers/rambafile.rb, line 71 def self.validate rambafile_validator = Viperaptor::RambafileValidator.new rambafile_validator.validate(@@rambafile_name) end