| 262 | // Stores implies for a given package and returns them to the caller in a given |
| 263 | // format. Takes in the dependencies from the package. |
| 264 | var PkgImplies = function (pkgDeps) { |
| 265 | var self = this; |
| 266 | self.data = []; |
| 267 | // Go through all the package dependencies. If a dependency has any implied |
| 268 | // references, add it to the list. |
| 269 | _.each(pkgDeps, function (ref, name) { |
| 270 | var architectures = []; |
| 271 | // We want to select the references that are implied (instead of just used) |
| 272 | // and save their architectures. Also, we want to replace 'os' with |
| 273 | // 'server', as with exports. |
| 274 | _.each(ref.references, function (r) { |
| 275 | if (! r.implied) { |
| 276 | return; |
| 277 | } |
| 278 | var archName = (r.arch === "os") ? "server" : r.arch; |
| 279 | architectures.push(archName); |
| 280 | }); |
| 281 | // Sort architecures alphabetically. |
| 282 | architectures.sort(); |
| 283 | if (! _.isEmpty(architectures)) { |
| 284 | self.data.push({ name: name, architectures: architectures }); |
| 285 | } |
| 286 | }); |
| 287 | // Sort by name. |
| 288 | self.data = _.sortBy(self.data, "name"); |
| 289 | }; |
| 290 | |
| 291 | // Extend BasePkgDatum. |
| 292 | PkgImplies.prototype = new BasePkgDatum(); |