lib/elephrame/mix/tracery.rb
def setup_tracery dir_path
      raise "Provided path not a directory" unless Dir.exist?(dir_path)

      @grammar = {}
      Dir.open(dir_path) do |dir|
        dir.each do |file|
          # skip our current and parent dir
          next if file =~ /^\.\.?$/

          # read the rule file into the files hash
          @grammar[file.split('.').first] =
            createGrammar(JSON.parse(File.read("#{dir_path}/#{file}")))
        end
      end

      # go ahead and makes a default mention-handler
      #  if we have a reply rule file
      unless @grammar['reply'].nil?
        on_reply { |bot|
          bot.reply_with_mentions('#default#', rules: 'reply')
        }
      end
    end
def setup_tracery dir_path
      raise "Provided path not a directory" unless Dir.exist?(dir_path)

      @grammar = {}
      Dir.open(dir_path) do |dir|
        dir.each do |file|
          # skip our current and parent dir
          next if file =~ /^\.\.?$/

          # read the rule file into the files hash
          @grammar[file.split('.').first] =
            createGrammar(JSON.parse(File.read("#{dir_path}/#{file}")))
        end
      end

      # go ahead and makes a default mention-handler
      #  if we have a reply rule file
      unless @grammar['reply'].nil?
        on_reply { |bot|
          bot.reply_with_mentions('#default#', rules: 'reply')
        }
      end
    end
loads all of our tracery files into our +files+ hash
 if a file is named 'default' then we load that into +grammar+

 @param dir [String] path to the directory containing the tracery rules