<commit_before>Liquid = require "../liquid"
Promise = require "bluebird"

module.exports = class Liquid.Engine
  constructor: (fileSystem) ->
    @tags = {}
    @Strainer = (@context) ->
    @registerFilters Liquid.StandardFilters

    isSubclassOf = (klass, ofKlass) ->
      unless typeof klass is 'function'
        false
      else if klass == ofKlass
        true
      else
        isSubclassOf klass.__super__?.constructor, ofKlass

    # Assign the passed FileSystem instance or create a new one
    if isSubclassOf fileSystem, Liquid.LocalFileSystem
      @fileSystem = fileSystem
    else
      @fileSystem = new Liquid.LocalFileSystem "./"

    for own tagName, tag of Liquid
      continue unless isSubclassOf(tag, Liquid.Tag)
      isBlockOrTagBaseClass = [Liquid.Tag, Liquid.Block].indexOf(tag.constructor) >= 0
      @registerTag tagName.toLowerCase(), tag unless isBlockOrTagBaseClass

  registerTag: (name, tag) ->
    @tags[name] = tag

  registerFilters: (filters...) ->
    filters.forEach (filter) =>
      for own k, v of filter
        @Strainer::[k] = v if v instanceof Function

  parse: (source) ->
    template = new Liquid.Template
    template.parse @, source<commit_msg>Fixed problem with recognising an instanceof LocalFileSystem<commit_after>Liquid = require "../liquid"
Promise = require "bluebird"

module.exports = class Liquid.Engine
  constructor: (fileSystem) ->
    @tags = {}
    @Strainer = (@context) ->
    @registerFilters Liquid.StandardFilters

    isSubclassOf = (klass, ofKlass) ->
      unless typeof klass is 'function'
        false
      else if klass == ofKlass
        true
      else
        isSubclassOf klass.__super__?.constructor, ofKlass

    # Assign the passed FileSystem instance or create a new one
    if fileSystem instanceof Liquid.LocalFileSystem
      @fileSystem = fileSystem
    else
      @fileSystem = new Liquid.LocalFileSystem "./"

    for own tagName, tag of Liquid
      continue unless isSubclassOf(tag, Liquid.Tag)
      isBlockOrTagBaseClass = [Liquid.Tag, Liquid.Block].indexOf(tag.constructor) >= 0
      @registerTag tagName.toLowerCase(), tag unless isBlockOrTagBaseClass

  registerTag: (name, tag) ->
    @tags[name] = tag

  registerFilters: (filters...) ->
    filters.forEach (filter) =>
      for own k, v of filter
        @Strainer::[k] = v if v instanceof Function

  parse: (source) ->
    template = new Liquid.Template
    template.parse @, source
{'fraction_non_alphanumeric': 0.0986088379705401, 'fraction_numerical': 0.0008183306055646482, 'mean_word_length': 2.975609756097561, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5415670', 'n_tokens_mistral': 732, 'n_tokens_neox': 703, 'n_words': 207}