require 'inline_template_loader'

module MrMongo
  class Loader
    def initialize(context)
      @context = context
    end

    def load(file)
      dsl_script = ::File.read(file).sub!(/^__END__\n.*\Z/m, '')

      map_reduce = load_from_string(dsl_script)

      InlineTemplateLoader.load(file).each do |key, val|
        map_reduce.send("#{key}=".to_sym, val)
      end

      map_reduce
    end

    def load_from_string(dsl_script, file = "(Mr. Mongo DSL)")
      dsl = Dsl.new(@context)

      eval "dsl.parse {\n" + dsl_script + "\n}.map_reduce", binding, file, 0
    end
  end
end

require 'inline_template_loader'

module MrMongo
  class Loader
    def initialize(context)
      @context = context
    end

    def load(file)
      dsl_script = ::File.read(file).sub!(/^__END__\n.*\Z/m, '')

      map_reduce = load_from_string(dsl_script, file)

      InlineTemplateLoader.load(file).each do |key, val|
        map_reduce.send("#{key}=".to_sym, val)
      end

      map_reduce
    end

    def load_from_string(dsl_script, file = "(Mr. Mongo DSL)")
      dsl = Dsl.new(@context)

      eval "dsl.parse {\n" + dsl_script + "\n}.map_reduce", binding, file, 0
    end
  end
end

Fix to set DSL file path as __FILE__
Fix to set DSL file path as __FILE__
