[nodejs-millstone] Initial import of nodejs-millstone

Tom Hughes tomh at fedoraproject.org
Mon Mar 11 12:36:28 UTC 2013


commit d8b0e844c2df0e2c02bf4003dbaa86961ca458c5
Author: Tom Hughes <tom at compton.nu>
Date:   Mon Mar 11 12:36:00 2013 +0000

    Initial import of nodejs-millstone

 .gitignore                        |    1 +
 nodejs-millstone-pool.patch       |  159 +++++++++++++++++++++++++++++++++++++
 nodejs-millstone-request.patch    |   19 +++++
 nodejs-millstone-tests.patch      |   36 ++++++++
 nodejs-millstone-underscore.patch |   19 +++++
 nodejs-millstone.spec             |   77 ++++++++++++++++++
 sources                           |    1 +
 7 files changed, 312 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index e69de29..fd7f2fb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/millstone-0.5.15.tgz
diff --git a/nodejs-millstone-pool.patch b/nodejs-millstone-pool.patch
new file mode 100644
index 0000000..b28fa68
--- /dev/null
+++ b/nodejs-millstone-pool.patch
@@ -0,0 +1,159 @@
+commit 7041a6e9292890a2bf09c97b6316ed670f9c2765
+Author: Tom Hughes <tom at compton.nu>
+Date:   Sun Feb 10 20:40:18 2013 +0000
+
+    Update to use v2.x of generic-pool
+
+diff --git a/lib/millstone.js b/lib/millstone.js
+index 7d393a9..1620770 100644
+--- a/lib/millstone.js
++++ b/lib/millstone.js
+@@ -107,71 +107,75 @@ function download(url, options, callback) {
+         return downloads[url].once('done', callback);
+     } else {
+         downloads[url] = new EventEmitter();
+-        pool.acquire(function(obj) {
+-            pool.release(obj);
+-            if (env == 'development') console.error("[millstone] downloading: '" + url + "'");
+-            var make_message = function() {
+-                var msg = "Unable to download '" + url + "'";
+-                if (options.name)
+-                    msg += " for '" + options.name + "'";
+-                return msg;
+-            };
+-            var req;
+-            try {
+-            req = request({
+-                url: url,
+-                proxy: process.env.HTTP_PROXY
+-            });
+-            } catch (err) {
+-                // catch Invalid URI error
+-                downloads[url].emit('done', err);
+-                delete downloads[url];
+-                err.message =  make_message() + " ("+err.message+")";
++        pool.acquire(function(err, obj) {
++            if (err) {
+                 return callback(err);
+-            }
+-            req.on('error', function(err) {
+-                downloads[url].emit('done', err);
+-                delete downloads[url];
+-                err.message =  make_message() + " ("+err.message+")";
+-                return callback(err);
+-            });
+-            req.pipe(fs.createWriteStream(dl)).on('error', function(err) {
+-                downloads[url].emit('done', err);
+-                delete downloads[url];
+-                err.message =  make_message() + " ("+err.message+")";
+-                return callback(err);
+-            }).on('close', function() {
+-                if (!req.response || (req.response && req.response.statusCode >= 400)) {
+-                    var err = new Error(make_message() + ' (server returned ' + req.response.statusCode + ')');
++            } else {
++                pool.release(obj);
++                if (env == 'development') console.error("[millstone] downloading: '" + url + "'");
++                var make_message = function() {
++                    var msg = "Unable to download '" + url + "'";
++                    if (options.name)
++                        msg += " for '" + options.name + "'";
++                    return msg;
++                };
++                var req;
++                try {
++                req = request({
++                    url: url,
++                    proxy: process.env.HTTP_PROXY
++                });
++                } catch (err) {
++                    // catch Invalid URI error
+                     downloads[url].emit('done', err);
+                     delete downloads[url];
++                    err.message =  make_message() + " ("+err.message+")";
+                     return callback(err);
+-                } else {
+-                    fs.rename(dl, options.filepath, function(err) {
+-                        if (err) {
+-                          downloads[url].emit('done', err);
+-                          delete downloads[url];
+-                          return callback(err);
+-                        } else {
+-                            if (env == 'development') console.error("[millstone] finished downloading '" + options.filepath + "'");
+-                            // We store the headers from the download in a hidden file
+-                            // alongside the data for future reference. Currently, we
+-                            // only use the `content-disposition` header to determine
+-                            // what kind of file we downloaded if it doesn't have an
+-                            // extension.
+-                            var req_meta = _(req.req.res.headers).clone();
+-                            if (req.req.res.request && req.req.res.request.path) {
+-                                req_meta.path = req.req.res.request.path;
+-                            }
+-                            fs.writeFile(metapath(options.filepath), JSON.stringify(req_meta), 'utf-8', function(err) {
+-                                downloads[url].emit('done', err, options.filepath);
+-                                delete downloads[url];
+-                                return callback(err, options.filepath);
+-                            });
+-                        }
+-                    });
+                 }
+-            });
++                req.on('error', function(err) {
++                    downloads[url].emit('done', err);
++                    delete downloads[url];
++                    err.message =  make_message() + " ("+err.message+")";
++                    return callback(err);
++                });
++                req.pipe(fs.createWriteStream(dl)).on('error', function(err) {
++                    downloads[url].emit('done', err);
++                    delete downloads[url];
++                    err.message =  make_message() + " ("+err.message+")";
++                    return callback(err);
++                }).on('close', function() {
++                    if (!req.response || (req.response && req.response.statusCode >= 400)) {
++                        var err = new Error(make_message() + ' (server returned ' + req.response.statusCode + ')');
++                        downloads[url].emit('done', err);
++                        delete downloads[url];
++                        return callback(err);
++                    } else {
++                        fs.rename(dl, options.filepath, function(err) {
++                            if (err) {
++                              downloads[url].emit('done', err);
++                              delete downloads[url];
++                              return callback(err);
++                            } else {
++                                if (env == 'development') console.error("[millstone] finished downloading '" + options.filepath + "'");
++                                // We store the headers from the download in a hidden file
++                                // alongside the data for future reference. Currently, we
++                                // only use the `content-disposition` header to determine
++                                // what kind of file we downloaded if it doesn't have an
++                                // extension.
++                                var req_meta = _(req.req.res.headers).clone();
++                                if (req.req.res.request && req.req.res.request.path) {
++                                    req_meta.path = req.req.res.request.path;
++                                }
++                                fs.writeFile(metapath(options.filepath), JSON.stringify(req_meta), 'utf-8', function(err) {
++                                    downloads[url].emit('done', err, options.filepath);
++                                    delete downloads[url];
++                                    return callback(err, options.filepath);
++                                });
++                            }
++                        });
++                    }
++                });
++            }
+         });
+     }
+ }
+diff --git a/package.json b/package.json
+index e8b2607..cd20f04 100644
+--- a/package.json
++++ b/package.json
+@@ -17,7 +17,7 @@
+     "dependencies": {
+         "underscore": "~1.3.3",
+         "step": "~0.0.5",
+-        "generic-pool": "1.0.x",
++        "generic-pool": "~2.0.3",
+         "request": "~2.11.4",
+         "srs": "~0.2.20",
+         "zipfile": "0.x",
diff --git a/nodejs-millstone-request.patch b/nodejs-millstone-request.patch
new file mode 100644
index 0000000..bae24d2
--- /dev/null
+++ b/nodejs-millstone-request.patch
@@ -0,0 +1,19 @@
+commit 35c5790d6dcbf2383f88cdbd09ba300f4777bd18
+Author: Tom Hughes <tom at compton.nu>
+Date:   Sun Feb 10 20:40:54 2013 +0000
+
+    Update to use v2.12.x of request
+
+diff --git a/package.json b/package.json
+index cd20f04..7f2aed7 100644
+--- a/package.json
++++ b/package.json
+@@ -18,7 +18,7 @@
+         "underscore": "~1.3.3",
+         "step": "~0.0.5",
+         "generic-pool": "~2.0.3",
+-        "request": "~2.11.4",
++        "request": "~2.12.0",
+         "srs": "~0.2.20",
+         "zipfile": "0.x",
+         "sqlite3": "2.x",
diff --git a/nodejs-millstone-tests.patch b/nodejs-millstone-tests.patch
new file mode 100644
index 0000000..b058007
--- /dev/null
+++ b/nodejs-millstone-tests.patch
@@ -0,0 +1,36 @@
+diff --git a/test/cache/cache.mml b/test/cache/cache.mml
+index e143761..57a0d7a 100644
+--- a/test/cache/cache.mml
++++ b/test/cache/cache.mml
+@@ -41,12 +41,6 @@
+             }
+         },
+         {
+-            "name": "csv",
+-            "Datasource": {
+-                "file": "https://docs.google.com/a/dbsgeo.com/spreadsheet/pub?hl=en_US&hl=en_US&key=0AqV4OJpywingdFNYLXpKMmxqMG1lWTJzNE45ZUVnNlE&single=true&gid=0&output=csv&ndplr=1"
+-            }
+-        },
+-        {
+             "name": "sqlite",
+             "Datasource": {
+                 "file": "layers/countries.sqlite",
+diff --git a/test/test.js b/test/test.js
+index 33d4dd8..b366b25 100644
+--- a/test/test.js
++++ b/test/test.js
+@@ -226,14 +226,6 @@ it('correctly caches remote files', function(done) {
+                 "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over"
+             },
+             {
+-                "name": "csv",
+-                "Datasource": {
+-                    "file": path.join(__dirname, 'cache/layers/csv.csv'),
+-                    "type": "csv"
+-                },
+-                "srs": "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"
+-            },
+-            {
+                 "name": 'sqlite',
+                 "Datasource": {
+                     "file": path.join(__dirname, 'cache/layers/countries.sqlite'),
diff --git a/nodejs-millstone-underscore.patch b/nodejs-millstone-underscore.patch
new file mode 100644
index 0000000..bb7220b
--- /dev/null
+++ b/nodejs-millstone-underscore.patch
@@ -0,0 +1,19 @@
+commit 9851eed4717f1895a915ddb688c1ab9f4bfeb809
+Author: Tom Hughes <tom at compton.nu>
+Date:   Wed Feb 13 00:05:31 2013 +0000
+
+    Update to use v1.4.x of underscore
+
+diff --git a/package.json b/package.json
+index 7f2aed7..15549bf 100644
+--- a/package.json
++++ b/package.json
+@@ -15,7 +15,7 @@
+       "email": "info at mapbox.com"
+     },
+     "dependencies": {
+-        "underscore": "~1.3.3",
++        "underscore": "~1.4.4",
+         "step": "~0.0.5",
+         "generic-pool": "~2.0.3",
+         "request": "~2.12.0",
diff --git a/nodejs-millstone.spec b/nodejs-millstone.spec
new file mode 100644
index 0000000..ca6e868
--- /dev/null
+++ b/nodejs-millstone.spec
@@ -0,0 +1,77 @@
+%global enable_tests 0
+
+Name:           nodejs-millstone
+Version:        0.5.15
+Release:        1%{?dist}
+Summary:        Prepares data sources in an MML file for consumption in Mapnik
+
+License:        BSD
+URL:            https://npmjs.org/package/millstone
+Source0:        http://registry.npmjs.org/millstone/-/millstone-%{version}.tgz
+# Accepted upstream - see https://github.com/mapbox/millstone/pull/94
+Patch0:         nodejs-millstone-pool.patch
+# Accepted upstream - see https://github.com/mapbox/millstone/pull/94
+Patch1:         nodejs-millstone-request.patch
+# Offered upstream - see https://github.com/mapbox/millstone/pull/96
+Patch2:         nodejs-millstone-underscore.patch
+# Patch out test that fails due to:
+# https://github.com/mikeal/request/issues/459
+Patch3:         nodejs-millstone-tests.patch
+BuildArch:      noarch
+
+BuildRequires:  nodejs-devel
+
+%if 0%{?enable_tests}
+BuildRequires:  npm(mocha)
+BuildRequires:  npm(generic-pool)
+BuildRequires:  npm(mime)
+BuildRequires:  npm(request)
+BuildRequires:  npm(srs)
+BuildRequires:  npm(step)
+BuildRequires:  npm(underscore)
+BuildRequires:  npm(zipfile)
+%endif
+
+%description
+As of carto 0.2.0, the Carto module expects all data sources and
+resources to be localized - remote references like URLs and providers
+are not downloaded when maps are rendered.
+
+Millstone now contains this logic - it provides two functions, resolve
+and flush. Resolve takes an MML file and returns a localized version, and
+flush can be used to clear the cache of a specific resource.
+
+
+%prep
+%setup -q -n package
+%patch0 -p1
+%patch1 -p1 -b .request
+%patch2 -p1 -b .underscore
+%patch3 -p1 -b .tests
+rm -rf node_modules
+
+
+%build
+
+
+%if 0%{?enable_tests}
+%check
+ln -s %{nodejs_sitelib} .
+NODE_PATH=lib %{nodejs_sitelib}/mocha/bin/mocha -R spec --timeout 10000
+%endif
+
+
+%install
+mkdir -p %{buildroot}/%{nodejs_sitelib}/millstone
+cp -pr package.json bin lib %{buildroot}/%{nodejs_sitelib}/millstone
+%nodejs_symlink_deps
+
+
+%files
+%doc LICENSE README.md CHANGELOG.md architecture.txt
+%{nodejs_sitelib}/millstone
+
+
+%changelog
+* Sun Feb 10 2013 Tom Hughes <tom at compton.nu> - 0.5.15-1
+- Initial build of 0.5.15
diff --git a/sources b/sources
index e69de29..c022e4e 100644
--- a/sources
+++ b/sources
@@ -0,0 +1 @@
+3cce69f841b96ac6add4fa96e7524812  millstone-0.5.15.tgz


More information about the scm-commits mailing list