class Nutella::TemplateCommand
This class describes a template command which can be either install or template It is mostly a commodity class for code reuse.
Public Instance Methods
run(args=nil)
click to toggle source
# File lib/commands/meta/template_command.rb, line 10 def run (args=nil) console.error 'Running generic TemplateCommand!!! WAT?' end
validate_nutella_file_json( json )
click to toggle source
# File lib/commands/meta/template_command.rb, line 39 def validate_nutella_file_json( json ) !json['name'].nil? && !json['version'].nil? && !json['type'].nil? && (json['type']=='bot' || json['type']=='interface') end
validate_template( dir )
click to toggle source
Validates a template in a certain folder @param [String] dir the directory where the template is stored
# File lib/commands/meta/template_command.rb, line 17 def validate_template( dir ) # Parse and validate the template's nutella.json file begin template_nutella_file_json = JSON.parse(IO.read("#{dir}/nutella.json")) rescue return false end return false unless validate_nutella_file_json template_nutella_file_json # If template is a bot, perform the appropriate checks if template_nutella_file_json['type']=='bot' # Is there a mandatory 'startup' script and is it executable return false unless File.executable? "#{dir}/startup" end # If template is an interface, perform the appropriate checks if template_nutella_file_json['type']=='interface' # Is there the mandatory index.html file return false unless File.exist? "#{dir}/index.html" end true end