Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Describe a component (or file) in the sources section of the manifest #8

Open
wants to merge 1 commit into from

1 participant

@thomasd

For frequently changing external files (libraries, widgets...) which do not follow the mootools package-syntax and have no description-header in their files, I added the ability to describe the components of a file in the manifest file.

Example:
name: "Core"
exports: "mootools-core.js"
web: "mootools.net"
description: "MooTools, The JavaScript framework"
license: "MIT License"
copyright: "© MooTools"
authors: "MooTools Development Team"

sources:
  - "Source/Core/Core.js"
  - 
    - "Source/Types/Array.js"
    - name: Array
      description: Contains Array Prototypes like each, contains, and erase.
      license: MIT-style license.
      requires: Type
      provides: Array
  - "Source/Types/String.js"

Having the description in the manifest the actual source file doesn't need a header.
I decided to handle the file path and the description in an array with 2 elements, but it may also be possible and maybe easier to read if you handle that in a map using the file path as key and the description map as value?!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 17, 2010
  1. Added the ability to read the description for a file from the source-…

    thomasd authored
    …entry in the manifest.
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 1 deletion.
  1. +12 −1 packager.php
View
13 packager.php
@@ -61,6 +61,11 @@ private function parse_manifest($path){
foreach ($manifest['sources'] as $i => $path){
+ // thomasd: if the source-node contains a description we cache it, but we wait if there's also a description-header in the file as this one takes precedence
+ if(is_array($path)){
+ $source_desc = $path[1];
+ $path = $path[0];
+ }
$path = $package_path . $path;
// this is where we "hook" for possible other replacers.
@@ -71,7 +76,13 @@ private function parse_manifest($path){
// get contents of first comment
preg_match('/\/\*\s*^---(.*?)^\.\.\.\s*\*\//ms', $source, $matches);
- if (!empty($matches)) $descriptor = YAML::decode($matches[0]);
+ if (!empty($matches)){
+ $descriptor = YAML::decode($matches[0]);
+ }
+ // thomasd: if the file doesn't contain a proper description-header but the manifest does, we take that description
+ else if(isset($source_desc) && is_array($source_desc)){
+ $descriptor = $source_desc;
+ }
// populate / convert to array requires and provides
$requires = (array)(!empty($descriptor['requires']) ? $descriptor['requires'] : array());
Something went wrong with that request. Please try again.