Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit 1e64429e9ae8924a55496c191795052a94f64b68 0 parents
@twolfson authored
2  .gitignore
@@ -0,0 +1,2 @@
+/node_modules/
+/test/actual/
22 LICENSE-MIT
@@ -0,0 +1,22 @@
+Copyright (c) 2013 Todd Wolfson
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
25 README.md
@@ -0,0 +1,25 @@
+# grunt-curl
+
+Download files from the internet via grunt.
+
+## Getting Started
+Install this grunt plugin next to your project's [grunt.js gruntfile][getting_started] with: `npm install grunt-curl`
+
+Then add this line to your project's `grunt.js` gruntfile:
+
+```javascript
+grunt.loadNpmTasks('grunt-curl');
+```
+
+[grunt]: http://gruntjs.com/
+[getting_started]: https://github.com/gruntjs/grunt/blob/master/docs/getting_started.md
+
+## Documentation
+_(Coming soon)_
+
+## Contributing
+In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint your code using [grunt][grunt] and test via `npm test`.
+
+## License
+Copyright (c) 2013 Todd Wolfson
+Licensed under the MIT license.
2  bin/grunt-curl
@@ -0,0 +1,2 @@
+#!/usr/bin/env node
+require('grunt').npmTasks('grunt-curl').cli();
40 grunt.js
@@ -0,0 +1,40 @@
+module.exports = function(grunt) {
+
+ // Project configuration.
+ grunt.initConfig({
+ test: {
+ files: ['test/**/*.js']
+ },
+ lint: {
+ files: ['grunt.js', 'tasks/**/*.js', 'test/**/*.js']
+ },
+ watch: {
+ files: '<config:lint.files>',
+ tasks: 'default'
+ },
+ jshint: {
+ options: {
+ curly: true,
+ eqeqeq: true,
+ immed: true,
+ latedef: true,
+ newcap: true,
+ noarg: true,
+ sub: true,
+ undef: true,
+ boss: true,
+ eqnull: true,
+ node: true,
+ es5: true
+ },
+ globals: {}
+ }
+ });
+
+ // Load local tasks.
+ grunt.loadTasks('tasks');
+
+ // Default task.
+ grunt.registerTask('default', 'lint test');
+
+};
45 package.json
@@ -0,0 +1,45 @@
+{
+ "name": "grunt-curl",
+ "description": "Download files from the internet via grunt.",
+ "version": "0.1.0",
+ "homepage": "https://github.com/twolfson/grunt-curl",
+ "author": {
+ "name": "Todd Wolfson",
+ "email": "todd@twolfson.com",
+ "url": "http://twolfson.com/"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/twolfson/grunt-curl.git"
+ },
+ "bugs": {
+ "url": "https://github.com/twolfson/grunt-curl/issues"
+ },
+ "licenses": [
+ {
+ "type": "MIT",
+ "url": "https://github.com/twolfson/grunt-curl/blob/master/LICENSE-MIT"
+ }
+ ],
+ "main": "grunt.js",
+ "bin": "bin/grunt-curl",
+ "engines": {
+ "node": "*"
+ },
+ "scripts": {
+ "test": "grunt --base ./test/ --config ./test/grunt.js"
+ },
+ "devDependencies": {
+ "grunt": "~0.3.17"
+ },
+ "keywords": [
+ "gruntplugin",
+ "grunt",
+ "curl",
+ "download",
+ "request",
+ "file",
+ "url",
+ "uri"
+ ]
+}
49 tasks/curl.js
@@ -0,0 +1,49 @@
+/*
+ * grunt-curl
+ * https://github.com/twolfson/grunt-curl
+ *
+ * Copyright (c) 2013 Todd Wolfson
+ * Licensed under the MIT license.
+ */
+
+module.exports = function(grunt) {
+
+ // Please see the grunt documentation for more information regarding task and
+ // helper creation: https://github.com/gruntjs/grunt/blob/master/docs/toc.md
+
+ // ==========================================================================
+ // TASKS
+ // ==========================================================================
+
+ grunt.registerMultiTask('curl', 'Your task description goes here.', function() {
+ // Collect the filepaths we need
+ var file = this.file,
+ data = this.data,
+ src = file.src,
+ srcFiles = grunt.file.expand(src),
+ dest = file.dest;
+
+ // Concatenate the srcFiles, process the blob through our helper,
+ var separator = data.separator || '\n',
+ srcBlob = grunt.helper('concat', srcFiles, {separator: separator}),
+ content = grunt.helper('curl', srcBlob);
+
+ // Write out the content
+ grunt.file.write(dest, content);
+
+ // Fail task if errors were logged.
+ if (this.errorCount) { return false; }
+
+ // Otherwise, print a success message.
+ grunt.log.writeln('File "' + this.file.dest + '" created.');
+ });
+
+ // ==========================================================================
+ // HELPERS
+ // ==========================================================================
+
+ grunt.registerHelper('curl', function (content) {
+ return content;
+ });
+
+};
36 test/curl_test.js
@@ -0,0 +1,36 @@
+var grunt = require('grunt');
+
+/*
+ ======== A Handy Little Nodeunit Reference ========
+ https://github.com/caolan/nodeunit
+
+ Test methods:
+ test.expect(numAssertions)
+ test.done()
+ Test assertions:
+ test.ok(value, [message])
+ test.equal(actual, expected, [message])
+ test.notEqual(actual, expected, [message])
+ test.deepEqual(actual, expected, [message])
+ test.notDeepEqual(actual, expected, [message])
+ test.strictEqual(actual, expected, [message])
+ test.notStrictEqual(actual, expected, [message])
+ test.throws(block, [error], [message])
+ test.doesNotThrow(block, [error], [message])
+ test.ifError(value)
+*/
+
+exports['curl'] = {
+ setUp: function(done) {
+ // setup here
+ done();
+ },
+ 'multiTask': function(test) {
+ test.expect(1);
+ // tests here
+ var expectedContent = grunt.file.read('expected/file.js'),
+ actualContent = grunt.file.read('actual/file.js');
+ test.equal(actualContent, expectedContent, 'should return the correct value.');
+ test.done();
+ }
+};
1  test/expected/file.js
@@ -0,0 +1 @@
+console.log('Hello World!');
21 test/grunt.js
@@ -0,0 +1,21 @@
+module.exports = function (grunt) {
+
+ // Project configuration.
+ grunt.initConfig({
+ 'curl': {
+ all: {
+ src: ['test_files/file.js'],
+ dest: 'actual/file.js'
+ }
+ },
+ test: {
+ all: '*_test.js'
+ }
+ });
+
+ // Load local tasks.
+ grunt.loadTasks('../tasks');
+
+ // Run project task then tests.
+ grunt.registerTask('default', 'curl test');
+};
1  test/test_files/file.js
@@ -0,0 +1 @@
+console.log('Hello World!');
Please sign in to comment.
Something went wrong with that request. Please try again.