<commit_before>

var Jack = {
  run : function(app){
    return ('function' == typeof(app)) ? app(Jack.env) : app.call(Jack.env)
  },

  up: function(js_app_files, options) {
    var app = Ruby.Proc.new(function(env) {
      Jack.env = env;
      var js_app_code = js_app_files.map(function(file) {
        return Ruby.File.read(Ruby.File.expand_path(file));
      }).join(";\n");
      return eval(js_app_code);
    });
    Ruby.puts("Running " + js_app_files.join(", "));
    Ruby.Rack.Handler.Mongrel.run(app, options);
  }
}<commit_msg>adding comments and fixing the problem where env was outside a closure<commit_after>

var Jack = {

  up: function(js_app_files, options) {

    // a Jack app is really just a ruby Proc/lambda
    var app = Ruby.Proc.new(function(env) {

      // set up a local Jack object because Jack.run() is used by app code
      // and we need the env both defined and called in the same closure
      var Jack = {run : function(app){ return ('function' == typeof(app)) ? app(env) : app.call(env) } }

      // build a string of app code
      var js_app_code = js_app_files.map(function(file) {
        return Ruby.File.read(Ruby.File.expand_path(file));
      }).join(";\n");
      // shoot the whole string through eval() to run the app
      return eval(js_app_code);
    });

    Ruby.puts("Running " + js_app_files.join(", "));
    Ruby.Rack.Handler.Mongrel.run(app, options);
  }
}
{'fraction_non_alphanumeric': 0.1459802538787024, 'fraction_numerical': 0.0, 'mean_word_length': 2.941666666666667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '166859', 'n_tokens_mistral': 481, 'n_tokens_neox': 469, 'n_words': 122}