GitHub PullRequestReviewCommentEvent at 2014-01-29 23:26:26
Repository: gaia
Actor: gaye
Payload: {"comment":{"url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/9290039","id":9290039,"diff_hunk":"@@ -0,0 +1,119 @@\n+var childProcess = require('child_process'),\n+    fs = require('fs'),\n+    path = require('path'),\n+    os = require('os'),\n+    ejs = require('ejs');\n+\n+const CAL_ICS_TMP_PATH = __dirname + '/template/calendar.ics.ejs',\n+      CONFIG_TMP_PATH = __dirname + '/template/config.ejs';\n+\n+/**\n+ * Radicale inherit CaldavServer.\n+ * It is a kind of CaldavServer implemented by pure Python.\n+ *\n+ * We install it from the gaia-marionette shell script file\n+ * during running the tests.\n+ */\n+function Radicale() {}\n+\n+Radicale.prototype = {\n+  // The instance of the child process.\n+  childProcess: null,\n+  // The path to the config file.\n+  configFilePath: path.join(os.tmpdir(), 'config'),\n+  // The path to the directory of the file system in server.\n+  fileSystemPath: path.join(os.tmpdir(), 'collections'),\n+  // The events storage in the server.\n+  events: [],\n+\n+  /**\n+   * Setup the config file for the Radicale server.\n+   *\n+   * @param {Object} options for the server.\n+   */\n+  setup: function(options) {\n+    // Setup the Radicale config file,\n+    // and we create it at path /radicale/install/path/config in the disk.\n+    var configTemplate,\n+        config,\n+        pickedPort;\n+\n+    if (options && options.port) {\n+      pickedPort = options.port;\n+    } else {\n+      throw new Error('No port allocated.');\n+    }\n+\n+    if (!fs.existsSync(this.fileSystemPath)) {\n+      fs.mkdirSync(this.fileSystemPath);\n+    }\n+\n+    configTemplate = fs.readFileSync(CONFIG_TMP_PATH, 'utf8'),\n+    config = ejs.render(configTemplate, {\n+      port: pickedPort,\n+      filesystemPath: this.fileSystemPath\n+    });\n+\n+    fs.writeFileSync(this.configFilePath, config);\n+  },\n+\n+  /**\n+   * Start the Radicale server with config file.\n+   *\n+   * @param {Object} options for the server.\n+   * @param {Function} callback execute after server is closed.\n+   */\n+  start: function(options, callback) {\n+    this.setup(options);\n+    this.childProcess =\n+      childProcess.spawn('radicale', ['--config', this.configFilePath]);\n+    callback();\n+  },\n+\n+  /**\n+   * Shutdown the Radicale server.\n+   *\n+   * @param {Function} callback execute after server is closed.\n+   */\n+  close: function(callback) {\n+    this.childProcess.on('exit', function() {","path":"apps/calendar/test/marionette/lib/radicale.js","position":79,"original_position":79,"commit_id":"e844db11beb28d781f5b3c7e37167845e03baea2","original_commit_id":"e844db11beb28d781f5b3c7e37167845e03baea2","user":{"login":"gaye","id":535859,"avatar_url":"https://gravatar.com/avatar/e781ab5c4935bc74643c593608505556?d=https%3A%2F%2Fidenticons.github.com%2F1033eb54923520c4658b4e82513043b5.png&r=x","gravatar_id":"e781ab5c4935bc74643c593608505556","url":"https://api.github.com/users/gaye","html_url":"https://github.com/gaye","followers_url":"https://api.github.com/users/gaye/followers","following_url":"https://api.github.com/users/gaye/following{/other_user}","gists_url":"https://api.github.com/users/gaye/gists{/gist_id}","starred_url":"https://api.github.com/users/gaye/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gaye/subscriptions","organizations_url":"https://api.github.com/users/gaye/orgs","repos_url":"https://api.github.com/users/gaye/repos","events_url":"https://api.github.com/users/gaye/events{/privacy}","received_events_url":"https://api.github.com/users/gaye/received_events","type":"User","site_admin":false},"body":"`this.childProcess.on('exit', callback);`?","created_at":"2014-01-29T23:26:26Z","updated_at":"2014-01-29T23:26:26Z","html_url":"https://github.com/mozilla-b2g/gaia/pull/13578#discussion_r9290039","pull_request_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/13578","_links":{"self":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/9290039"},"html":{"href":"https://github.com/mozilla-b2g/gaia/pull/13578#discussion_r9290039"},"pull_request":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/13578"}}}}