Sha256: 2a96170476607fdcdc0171dbe7846a126cd5491d89596e235521496e32d4e46b
Contents?: true
Size: 1.3 KB
Versions: 6
Compression:
Stored size: 1.3 KB
Contents
require_relative './skill' module Ralyxa class RegisterIntents DEFAULT_INTENTS_DIRECTORY = "./intents".freeze def initialize(intents_directory, alexa_skill_class) @intents_directory = intents_directory @alexa_skill_class = alexa_skill_class end def self.run(intents_directory = DEFAULT_INTENTS_DIRECTORY, alexa_skill_class = Ralyxa::Skill) new(intents_directory, alexa_skill_class).run end def run warn NO_INTENT_DECLARATIONS_FOUND if intent_declarations.empty? intent_declarations.each do |intent_declaration| alexa_skill_class.class_eval intent_declaration end end private attr_reader :intents_directory, :alexa_skill_class def intent_declarations @intent_declarations ||= Dir.glob("#{ intents_directory }/*.rb") .map { |relative_path| File.expand_path(relative_path) } .map { |intent_declaration_path| File.open(intent_declaration_path).read } end NO_INTENT_DECLARATIONS_FOUND = <<~HEREDOC \e[33m WARNING: You haven't defined any intents. Please define intents inside a directory called 'intents', on the same directory level as the runfile for your server application, or change the default intents directory in alexa/register_intents.rb. \e[0m HEREDOC end end
Version data entries
6 entries across 6 versions & 1 rubygems