GitHub PullRequestReviewCommentEvent at 2014-05-13 03:27:59
Repository: gaia
Actor: yurenju
Payload: {"comment":{"url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/12565536","id":12565536,"diff_hunk":"@@ -0,0 +1,282 @@\n+'use strict';\n+\n+/* global require, exports */\n+const utils = require('utils');\n+const { Cc, Ci } = require('chrome');\n+\n+function getHash(str) {\n+  var converter =\n+    Cc['@mozilla.org/intl/scriptableunicodeconverter'].\n+      createInstance(Ci.nsIScriptableUnicodeConverter);\n+\n+  converter.charset = 'UTF-8';\n+\n+  var result = {};\n+  var data = converter.convertToByteArray(str, result);\n+  var ch = Cc['@mozilla.org/security/hash;1'].createInstance(Ci.nsICryptoHash);\n+  ch.init(ch.SHA1);\n+  ch.update(data, data.length);\n+  var hash = ch.finish(false);\n+\n+  return toHexString(hash);\n+}\n+\n+function toHexString(str) {\n+  var hex = '';\n+  for (var i = 0; i < str.length; i++) {\n+    hex += ('0' + str.charCodeAt(i).toString(16)).slice(-2);\n+  }\n+  return hex;\n+}\n+\n+// Resources helper constructor\n+var Resources = function(gaia, settings) {\n+  this.gaia = gaia;\n+  this.settings = settings;\n+  this.fileList = [];\n+  this.json = {};\n+};\n+\n+// Parse and get resources for a given JSON configuration of one operator.\n+// Also create an output JSON configuration for the processed resources. \n+Resources.prototype.getResources = function(conf) {\n+  this.operatorJSON = {};\n+\n+  this.copyResource(conf.default_contacts, 'default_contacts');\n+  this.copyResource(conf.support_contacts, 'support_contacts');\n+  this.copyResource(conf.network_type, 'network_type');\n+  this.copyResource(conf.known_networks, 'known_networks');\n+  this.copyResource(conf.nfc, 'nfc');\n+  this.copyResource(conf.sms, 'sms');\n+  this.getWallpaperResource(conf.wallpaper);\n+  this.getRingtoneResource(conf.ringtone);\n+  this.getPowerResource(conf.power);\n+  this.getKeyboardResource(conf.keyboard);\n+  this.getDataFtu(conf.data_ftu);\n+\n+  conf['mcc-mnc'].forEach(function(mcc) {\n+    if (Object.keys(this.operatorJSON).length !== 0) {\n+      this.json[mcc] = this.operatorJSON;\n+    }\n+  }.bind(this));\n+};\n+\n+// Get file object for a given path.\n+Resources.prototype.getFile = function(path) {\n+  var distDir = this.gaia.distributionDir;\n+  var file = utils.getFile(distDir, path);\n+  if (!file.exists()) {\n+    throw new Error('Invalid single variant configuration: ' +\n+                    file.path + ' not found');\n+  }\n+\n+  return file;\n+};\n+\n+// Add new resource entry in the output JSON configuration (key / value)\n+// and add the resource path to the resources list.\n+Resources.prototype.addEntry = function(resources, name, key) {\n+    if (resources instanceof Array) {\n+      this.fileList.push.apply(this.fileList, resources);\n+    } else {\n+      this.fileList.push(resources);\n+    }\n+\n+    this.operatorJSON[key] = '/resources/' + name;\n+};\n+\n+// Add file to resources object\n+Resources.prototype.copyResource = function(path, key) {","path":"apps/operatorvariant/build/build.js","position":89,"original_position":89,"commit_id":"bd5bf7e2e444fc2eebb5edafb7cd00b703b82998","original_commit_id":"bd5bf7e2e444fc2eebb5edafb7cd00b703b82998","user":{"login":"yurenju","id":22155,"avatar_url":"https://avatars.githubusercontent.com/u/22155?","gravatar_id":"a357616c0a9197fccbaf5aceb92d94f3","url":"https://api.github.com/users/yurenju","html_url":"https://github.com/yurenju","followers_url":"https://api.github.com/users/yurenju/followers","following_url":"https://api.github.com/users/yurenju/following{/other_user}","gists_url":"https://api.github.com/users/yurenju/gists{/gist_id}","starred_url":"https://api.github.com/users/yurenju/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yurenju/subscriptions","organizations_url":"https://api.github.com/users/yurenju/orgs","repos_url":"https://api.github.com/users/yurenju/repos","events_url":"https://api.github.com/users/yurenju/events{/privacy}","received_events_url":"https://api.github.com/users/yurenju/received_events","type":"User","site_admin":false},"body":"this function is not used to copy resource, maybe `addFile()` or `addResourceFile()`","created_at":"2014-05-13T03:27:59Z","updated_at":"2014-05-13T03:27:59Z","html_url":"https://github.com/mozilla-b2g/gaia/pull/18417#discussion_r12565536","pull_request_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/18417","_links":{"self":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/12565536"},"html":{"href":"https://github.com/mozilla-b2g/gaia/pull/18417#discussion_r12565536"},"pull_request":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/18417"}}}}