Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit d77f9bf3d7ad2fee950174a972f9c3652d555271 @jgallen23 committed Dec 13, 2012
Showing with 326 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +14 −0 .jshintrc
  3. 0 .npmignore
  4. +63 −0 Gruntfile.js
  5. +22 −0 LICENSE-MIT
  6. +95 −0 README.md
  7. +42 −0 package.json
  8. +37 −0 tasks/reloadr.js
  9. +1 −0 test/expected/custom_options
  10. +1 −0 test/expected/default_options
  11. +1 −0 test/fixtures/123
  12. +1 −0 test/fixtures/testing
  13. +48 −0 test/reloadr_test.js
@@ -0,0 +1 @@
+node_modules
@@ -0,0 +1,14 @@
+{
+ "curly": true,
+ "eqeqeq": true,
+ "immed": true,
+ "latedef": true,
+ "newcap": true,
+ "noarg": true,
+ "sub": true,
+ "undef": true,
+ "boss": true,
+ "eqnull": true,
+ "node": true,
+ "es5": true
+}
No changes.
@@ -0,0 +1,63 @@
+/*
+ * grunt-reloadr
+ * https://github.com/jgallen23/grunt-reloadr
+ *
+ * Copyright (c) 2012 Greg Allen
+ * Licensed under the MIT license.
+ */
+
+'use strict';
+
+module.exports = function(grunt) {
+
+ // Project configuration.
+ grunt.initConfig({
+ jshint: {
+ all: [
+ 'Gruntfile.js',
+ 'tasks/*.js',
+ '<%= nodeunit.tests %>',
+ ],
+ options: {
+ jshintrc: '.jshintrc',
+ },
+ },
+
+ // Before generating any new files, remove any previously-created files.
+ clean: {
+ tests: ['tmp'],
+ },
+
+ // Configuration to be run (and then tested).
+ reloadr: {
+ main: {
+ watch: [
+ 'test/**/*',
+ 'tasks/*.js'
+ ]
+ }
+ },
+
+ // Unit tests.
+ nodeunit: {
+ tests: ['test/*_test.js'],
+ },
+
+ });
+
+ // Actually load this plugin's task(s).
+ grunt.loadTasks('tasks');
+
+ // These plugins provide necessary tasks.
+ grunt.loadNpmTasks('grunt-contrib-jshint');
+ grunt.loadNpmTasks('grunt-contrib-clean');
+ grunt.loadNpmTasks('grunt-contrib-nodeunit');
+
+ // Whenever the "test" task is run, first clean the "tmp" dir, then run this
+ // plugin's task(s), then test the result.
+ grunt.registerTask('test', ['clean', 'reloadr', 'nodeunit']);
+
+ // By default, lint and run all tests.
+ grunt.registerTask('default', ['jshint', 'test']);
+
+};
@@ -0,0 +1,22 @@
+Copyright (c) 2012 Greg Allen
+
+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.
@@ -0,0 +1,95 @@
+# grunt-reloadr
+
+> LiveReload grunt plugin
+
+## Getting Started
+_If you haven't used [grunt][] before, be sure to check out the [Getting Started][] guide._
+
+From the same directory as your project's [Gruntfile][Getting Started] and [package.json][], install this plugin with the following command:
+
+```bash
+npm install grunt-reloadr --save-dev
+```
+
+Once that's done, add this line to your project's Gruntfile:
+
+```js
+grunt.loadNpmTasks('grunt-reloadr');
+```
+
+If the plugin has been installed correctly, running `grunt --help` at the command line should list the newly-installed plugin's task or tasks. In addition, the plugin should be listed in package.json as a `devDependency`, which ensures that it will be installed whenever the `npm install` command is run.
+
+[grunt]: http://gruntjs.com/
+[Getting Started]: https://github.com/gruntjs/grunt/blob/devel/docs/getting_started.md
+[package.json]: https://npmjs.org/doc/json.html
+
+## The "reloadr" task
+
+### Overview
+In your project's Gruntfile, add a section named `reloadr` to the data object passed into `grunt.initConfig()`.
+
+```js
+grunt.initConfig({
+ reloadr: {
+ options: {
+ // Task-specific options go here.
+ },
+ your_target: {
+ // Target-specific file lists and/or options go here.
+ },
+ },
+})
+```
+
+### Options
+
+#### options.separator
+Type: `String`
+Default value: `', '`
+
+A string value that is used to do something with whatever.
+
+#### options.punctuation
+Type: `String`
+Default value: `'.'`
+
+A string value that is used to do something else with whatever else.
+
+### Usage Examples
+
+#### Default Options
+In this example, the default options are used to do something with whatever. So if the `testing` file has the content `Testing` and the `123` file had the content `1 2 3`, the generated result would be `Testing, 1 2 3.`
+
+```js
+grunt.initConfig({
+ reloadr: {
+ options: {},
+ files: {
+ 'dest/default_options': ['src/testing', 'src/123'],
+ },
+ },
+})
+```
+
+#### Custom Options
+In this example, custom options are used to do something else with whatever else. So if the `testing` file has the content `Testing` and the `123` file had the content `1 2 3`, the generated result in this case would be `Testing: 1 2 3 !!!`
+
+```js
+grunt.initConfig({
+ reloadr: {
+ options: {
+ separator: ': ',
+ punctuation: ' !!!',
+ },
+ files: {
+ 'dest/default_options': ['src/testing', 'src/123'],
+ },
+ },
+})
+```
+
+## 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 and test your code using [grunt][].
+
+## Release History
+_(Nothing yet)_
@@ -0,0 +1,42 @@
+{
+ "name": "grunt-reloadr",
+ "description": "LiveReload grunt plugin",
+ "version": "0.1.0",
+ "homepage": "https://github.com/jgallen23/grunt-reloadr",
+ "author": {
+ "name": "Greg Allen",
+ "email": "me@jga.me"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/jgallen23/grunt-reloadr.git"
+ },
+ "bugs": {
+ "url": "https://github.com/jgallen23/grunt-reloadr/issues"
+ },
+ "licenses": [
+ {
+ "type": "MIT",
+ "url": "https://github.com/jgallen23/grunt-reloadr/blob/master/LICENSE-MIT"
+ }
+ ],
+ "main": "Gruntfile.js",
+ "engines": {
+ "node": ">= 0.8.0"
+ },
+ "scripts": {
+ "test": "grunt test"
+ },
+ "devDependencies": {
+ "grunt-contrib-jshint": "~0.1.0",
+ "grunt-contrib-clean": "~0.4.0a",
+ "grunt-contrib-nodeunit": "~0.1.0",
+ "grunt": "~0.3.17"
+ },
+ "keywords": [
+ "gruntplugin"
+ ],
+ "dependencies": {
+ "reloadr": "~0.1.1"
+ }
+}
@@ -0,0 +1,37 @@
+/*
+ * grunt-reloadr
+ * https://github.com/jgallen23/grunt-reloadr
+ *
+ * Copyright (c) 2012 Greg Allen
+ * Licensed under the MIT license.
+ */
+
+'use strict';
+
+module.exports = function(grunt) {
+
+ // Please see the grunt documentation for more information regarding task
+ // creation: https://github.com/gruntjs/grunt/blob/devel/docs/toc.md
+
+ var reloadr = require('reloadr');
+
+ grunt.registerMultiTask('reloadr', 'LiveReload grunt plugin', function() {
+
+ var self = this;
+ var done = this.async();
+
+ if (typeof this.data.watch == 'string') {
+ this.data.watch = [this.data.watch];
+ }
+
+ reloadr.start(this.data.watch, function() {
+ grunt.log.writeln('LiveReload server started');
+ grunt.log.writeln('Watching: '+self.data.watch.join(', '));
+ });
+
+ reloadr.changed(function(filepath) {
+ grunt.log.writeln('File changed: '+filepath);
+ });
+ });
+
+};
@@ -0,0 +1 @@
+Testing: 1 2 3 !!!
@@ -0,0 +1 @@
+Testing, 1 2 3.
@@ -0,0 +1 @@
+1 2 3
@@ -0,0 +1 @@
+Testing
@@ -0,0 +1,48 @@
+'use strict';
+
+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.reloadr = {
+ setUp: function(done) {
+ // setup here if necessary
+ done();
+ },
+ default_options: function(test) {
+ test.expect(1);
+
+ var actual = grunt.file.read('tmp/default_options');
+ var expected = grunt.file.read('test/expected/default_options');
+ test.equal(actual, expected, 'should describe what the default behavior is.');
+
+ test.done();
+ },
+ custom_options: function(test) {
+ test.expect(1);
+
+ var actual = grunt.file.read('tmp/custom_options');
+ var expected = grunt.file.read('test/expected/custom_options');
+ test.equal(actual, expected, 'should describe what the custom option(s) behavior is.');
+
+ test.done();
+ },
+};

0 comments on commit d77f9bf

Please sign in to comment.