Skip to content

Commit

Permalink
Add skeleton from grunt-init noflo
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnor committed Oct 22, 2014
0 parents commit 89fcc6f
Show file tree
Hide file tree
Showing 11 changed files with 271 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/node_modules/
/browser/
/components/*/
/spec/*.js
/spec/*.xml
flowhub.json
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: node_js
node_js:
- 0.10
before_script:
- npm install -g grunt-cli
94 changes: 94 additions & 0 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
module.exports = ->
# Project configuration
@initConfig
pkg: @file.readJSON 'package.json'

# Updating the package manifest files
noflo_manifest:
update:
files:
'component.json': ['graphs/*', 'components/*']
'package.json': ['graphs/*', 'components/*']

# CoffeeScript compilation of tests
coffee:
spec:
options:
bare: true
expand: true
cwd: 'spec'
src: ['**.coffee']
dest: 'spec'
ext: '.js'

# Browser build of NoFlo
noflo_browser:
build:
files:
'browser/noflo-browser-app.js': ['component.json']

# JavaScript minification for the browser
uglify:
options:
report: 'min'
noflo:
files:
'./browser/noflo-browser-app.min.js': ['./browser/noflo-browser-app.js']

# Automated recompilation and testing when developing
watch:
files: ['spec/*.coffee', 'components/*.coffee']
tasks: ['test']

# BDD tests on Node.js
cafemocha:
nodejs:
src: ['spec/*.coffee']
options:
reporter: 'spec'

# BDD tests on browser
mocha_phantomjs:
options:
output: 'spec/result.xml'
reporter: 'spec'
all: ['spec/runner.html']

# Coding standards
coffeelint:
components: ['Gruntfile.coffee', 'spec/*.coffee', 'components/*.coffee']
options:
'max_line_length':
'level': 'ignore'

# Grunt plugins used for building
@loadNpmTasks 'grunt-contrib-coffee'
@loadNpmTasks 'grunt-noflo-manifest'
@loadNpmTasks 'grunt-noflo-browser'
@loadNpmTasks 'grunt-contrib-uglify'

# Grunt plugins used for testing
@loadNpmTasks 'grunt-contrib-watch'
@loadNpmTasks 'grunt-cafe-mocha'
@loadNpmTasks 'grunt-mocha-phantomjs'
@loadNpmTasks 'grunt-coffeelint'

# Our local tasks
@registerTask 'build', 'Build NoFlo for the chosen target platform', (target = 'all') =>
@task.run 'coffee'
@task.run 'noflo_manifest'
if target is 'all' or target is 'browser'
@task.run 'noflo_browser'
@task.run 'uglify'

@registerTask 'test', 'Build NoFlo and run automated tests', (target = 'all') =>
@task.run 'coffeelint'
@task.run 'coffee'
@task.run 'noflo_manifest'
if target is 'all' or target is 'nodejs'
@task.run 'cafemocha'
if target is 'all' or target is 'browser'
@task.run 'noflo_browser'
@task.run 'mocha_phantomjs'

@registerTask 'default', ['test']
22 changes: 22 additions & 0 deletions LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright (c) 2014 Jon Nordby

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.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# noflo-browser-app [![Build Status](https://secure.travis-ci.org/noflo/noflo-browser-app.png?branch=master)](http://travis-ci.org/noflo/noflo-browser-app)

The best project ever.
18 changes: 18 additions & 0 deletions component.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "noflo-browser-app",
"description": "The best project ever.",
"author": "Jon Nordby <jononor@gmail.com>",
"repo": "noflo/noflo-browser-app",
"version": "0.1.0",
"keywords": [
],
"dependencies": {
"noflo/noflo": "*"
},
"remotes": [
"https://raw.githubusercontent.com"
],
"scripts": [
"index.js"
]
}
25 changes: 25 additions & 0 deletions components/DoSomething.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
noflo = require 'noflo'

exports.getComponent = ->
c = new noflo.Component

# Define a meaningful icon for component from http://fontawesome.io/icons/
c.icon = 'cog'

# Provide a description on component usage
c.description = 'do X'

# Add input ports
c.inPorts.add 'in',
datatype: 'string'
process: (event, payload) ->
# What to do when port receives a packet
return unless event is 'data'
c.outPorts.out.send payload

# Add output ports
c.outPorts.add 'out',
datatype: 'string'

# Finally return the component instance
c
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* This file can be used for general library features of noflo-browser-app.
*
* The library features can be made available as CommonJS modules that the
* components in this project utilize.
*/
39 changes: 39 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "noflo-browser-app",
"description": "The best project ever.",
"version": "0.1.0",
"author": {
"name": "Jon Nordby",
"email": "jononor@gmail.com"
},
"repository": {
"type": "git",
"url": "git://github.com/noflo/noflo-browser-app.git"
},
"licenses": [
{
"type": "MIT",
"url": "undefined/blob/master/LICENSE-MIT"
}
],
"scripts": {
"test": "grunt test"
},
"dependencies": {
"noflo": "~0.5.0"
},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-coffee": "~0.10.1",
"grunt-coffeelint": "~0.0.10",
"grunt-cafe-mocha": "~0.1.12",
"chai": "~1.9.0",
"mocha": "~1.21.0",
"grunt-mocha-phantomjs": "~0.2.2",
"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-watch": "~0.6.1",
"grunt-noflo-manifest": "~0.1.11",
"grunt-noflo-browser": "^0.1.1"
},
"keywords": []
}
23 changes: 23 additions & 0 deletions spec/DoSomething.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
noflo = require 'noflo'
unless noflo.isBrowser()
chai = require 'chai' unless chai
DoSomething = require '../components/DoSomething.coffee'
else
DoSomething = require 'noflo-browser-app/components/DoSomething.js'

describe 'DoSomething component', ->
c = null
ins = null
out = null
beforeEach ->
c = DoSomething.getComponent()
ins = noflo.internalSocket.createSocket()
out = noflo.internalSocket.createSocket()
c.inPorts.in.attach ins
c.outPorts.out.attach out

describe 'when instantiated', ->
it 'should have an input port', ->
chai.expect(c.inPorts.in).to.be.an 'object'
it 'should have an output port', ->
chai.expect(c.outPorts.out).to.be.an 'object'
30 changes: 30 additions & 0 deletions spec/runner.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>noflo-browser-app in browser</title>
<link rel="stylesheet" href="../node_modules/mocha/mocha.css">
<style type="text/css">
#fixtures {
display: none;
}
</style>
</head>
<body>
<div id="mocha"></div>
<div id="fixtures"></div>
<script src="../browser/noflo-browser-app.js"></script>
<script src="http://chaijs.com/chai.js"></script>
<script src="../node_modules/mocha/mocha.js"></script>
<script>mocha.setup('bdd');</script>
<script src="./DoSomething.js"></script>
<script>
if (window.mochaPhantomJS) {
mochaPhantomJS.run();
} else {
mocha.checkLeaks();
mocha.run();
}
</script>
</body>
</html>

0 comments on commit 89fcc6f

Please sign in to comment.