Skip to content
This repository was archived by the owner on Nov 28, 2017. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
246 changes: 122 additions & 124 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@


module.exports = ( grunt ) ->
srcs = [
'src/tails.coffee'
'src/utils/hash.coffee'
'src/mixins/interceptable.coffee'
'src/mixins/debug.coffee'
'src/mixable.coffee'

'src/mixins/dynamic_attributes.coffee'
'src/collection.coffee'
'src/mixins/collectable.coffee'
'src/associations/relation.coffee'
'src/associations/belongs_to_relation.coffee'
'src/associations/has_one_relation.coffee'
'src/associations/has_many_relation.coffee'
'src/associations/association.coffee'
'src/mixins/associable.coffee'
'src/mixins/storage.coffee'
'src/mixins/history.coffee'

'src/model.coffee'
'src/template.coffee'
'src/view.coffee'

'src/export.coffee'
'tails'
'utils/hash'
'utils/rivets-tails'

'mixable'
'mixins/interceptable'
'mixins/debug'
'mixins/dynamic_attributes'

'collection'
'mixins/collectable'
'associations/relation'
'associations/belongs_to_relation'
'associations/has_one_relation'
'associations/has_many_relation'
'associations/association'
'mixins/associable'
'mixins/storage'
'mixins/history'

'model'
'template'
'view'

'config'
]

deps = [
Expand All @@ -37,142 +37,140 @@ module.exports = ( grunt ) ->
'bower_components/rivets/dist/rivets.js'
]

bundle = deps.concat('build/tails.js')
# Coverage thresholds
thresholds =
lines: 60
statements: 50
branches: 40
functions: 50

# This functions makes the config shorter and clearer later on.
# It just returns the type specific coverage config
coverage = ( type, optionsRef ) ->
optionsRef.template = require('grunt-template-jasmine-istanbul')
optionsRef.templateOptions =
coverage: 'stat/coverage/coverage.json'
thresholds: thresholds
report:
type: type
options:
dir: "stat/coverage/#{type}"

grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.loadNpmTasks 'grunt-contrib-concat'
grunt.loadNpmTasks 'grunt-contrib-uglify'
grunt.loadNpmTasks 'grunt-contrib-clean'
grunt.loadNpmTasks 'grunt-contrib-jasmine'
grunt.loadNpmTasks 'grunt-contrib-watch'
grunt.loadNpmTasks 'grunt-requirejs'
grunt.loadNpmTasks 'grunt-plato'
return optionsRef

# Configure all the tasks!
grunt.initConfig
pkg: grunt.file.readJSON('package.json')

meta:
banner:
'// Tails\n' +
'// version: <%= pkg.version %>\n' +
'// contributors: <%= pkg.contributors %>\n' +
'// license: <%= pkg.licenses[0].type %>\n'

coffee:

dist:
src:
options:
join: true
files:
'dist/tails.js': srcs

build:
options:
join: true
sourceMap: true
files:
'build/tails.js': srcs
files: [
expand: true
cwd: 'src'
src: srcs.map ( src ) -> src + '.coffee'
dest: 'dist'
ext: '.js'
]

modules:
spec:
options:
join: false
sourceMap: true
files: [
expand: true
cwd: 'src'
cwd: 'spec'
src: ['**/*.coffee']
dest: '.grunt/tails/src_compiled'
dest: 'build/spec'
ext: '.js'
]

spec:
perf:
files: [
expand: true
cwd: 'spec'
cwd: 'perf'
src: ['**/*.coffee']
dest: '.grunt/tails/spec_compiled'
dest: 'build/perf'
ext: '.js'
]

browserify:
default:
files: 'dist/tails.browser.js': 'dist/tails.js'
options:
sourceMap: false
browserifyOptions:
standalone: 'Tails'
istanbul:
files: 'build/spec/tails.browser.js': 'dist/tails.js'
options:
sourceMap: true
transform: [require('browserify-istanbul')]
browserifyOptions:
standalone: 'Tails'

concat:
bundle:
options:
banner: '<%= meta.banner %>'
files:
'dist/tails.bundle.js': bundle
'dist/tails.bundle.js': deps.concat('dist/tails.browser.js')

uglify:
dist:
options:
banner: '<%= meta.banner %>'
report: 'gzip'
files:
'dist/tails.min.js': 'dist/tails.js'
default:
files: 'dist/tails.browser.min.js': 'dist/tails.browser.js'
bundle:
options:
banner: '<%= meta.banner %>'
report: 'gzip'
files:
'dist/tails.bundle.min.js': 'dist/tails.bundle.js'
files: 'dist/tails.bundle.min.js': 'dist/tails.bundle.js'

jasmine:
build:
src: ['build/tails.js']
default:
src: ['dist/tails.browser.js']
options:
specs: '.grunt/tails/spec_compiled/**/*.js'
vendor: bundle.concat('bower_components/jasmine-ajax/lib/mock-ajax.js')
template: require('grunt-template-jasmine-istanbul')
templateOptions:
coverage: 'statistics/coverage/coverage.json'
report:
type: 'lcovonly'
options:
dir: '.grunt/tails/coverage/lcov'
thresholds:
lines: 60
statements: 60
branches: 60
functions: 60
keepRunner: true
vendor: deps.concat('bower_components/jasmine-ajax/lib/mock-ajax.js')
specs: 'build/spec/**/*.js'
lcovonly:
src: ['build/spec/tails.browser.js']
options: (coverage 'lcovonly',
keepRunner: true
vendor: deps.concat('bower_components/jasmine-ajax/lib/mock-ajax.js')
specs: 'build/spec/**/*.js'
)
html:
src: ['build/tails.js']
options:
specs: '.grunt/tails/spec_compiled/**/*.js'
vendor: deps
template: require('grunt-template-jasmine-istanbul')
templateOptions:
coverage: 'statistics/coverage/coverage.json'
report:
type: 'html'
options:
dir: 'statistics/coverage/html'
thresholds:
lines: 60
statements: 60
branches: 60
functions: 60

plato:
all:
options:
jshint: false
files:
'statistics/complexity' : ['.grunt/tails/src_compiled/**/*.js']
src: ['build/spec/tails.browser.js']
options: (coverage 'html',
vendor: deps.concat('bower_components/jasmine-ajax/lib/mock-ajax.js')
specs: 'build/spec/**/*.js'
)

benchmark:
default:
src: ['build/perf/**/*.js']
dest: 'stat/perf/result.csv'

clean:
build: ['build']
spec: ['.grunt/tails/spec_compiled']
grunt: ['.grunt']

watch:
all:
files: 'src/**/*.coffee'
tasks: ['build', 'spec']

grunt.registerTask 'watch', ['coffee:build', 'watch']
grunt.registerTask 'spec', ['clean:spec', 'coffee:build', 'coffee:spec', 'jasmine:build', 'clean:spec']
grunt.registerTask 'build', ['coffee:build']
grunt.registerTask 'dist', ['coffee:dist', 'uglify:dist']
grunt.registerTask 'bundle', ['coffee:dist', 'concat:bundle', 'uglify:bundle']
grunt.registerTask 'analyze', ['coffee','jasmine:html', 'plato']
default:
files: ['src/**/*.coffee', 'spec/**/*.coffee']
tasks: ['spec']

codo:
files: ['src/**/*.coffee']

# grunt.loadNpmTasks 'grunt-babel'
grunt.loadNpmTasks 'grunt-browserify'
grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.loadNpmTasks 'grunt-contrib-uglify'
grunt.loadNpmTasks 'grunt-contrib-watch'
grunt.loadNpmTasks 'grunt-contrib-clean'
grunt.loadNpmTasks 'grunt-contrib-jasmine'
grunt.loadNpmTasks 'grunt-benchmark'
grunt.loadNpmTasks 'grunt-codo'
grunt.loadNpmTasks 'grunt-contrib-concat'

grunt.registerTask 'default', ['watch']
grunt.registerTask 'dist', ['coffee:src', 'browserify:default', 'concat:bundle', 'uglify']
grunt.registerTask 'spec', ['clean', 'dist', 'coffee:spec' ,'jasmine:default']
grunt.registerTask 'perf', ['clean', 'dist', 'coffee:perf' ,'benchmark:default']
grunt.registerTask 'test', ['spec', 'browserify:istanbul', 'jasmine:lcovonly']
grunt.registerTask 'coverage', ['spec', 'browserify:istanbul', 'jasmine:html']
103 changes: 103 additions & 0 deletions dist/associations/association.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading