           level: 'error'
         no_stand_alone_at:
           level: 'error'
-      directives:
-        files: src: ["#{MODULES_DIR}/*/*/*.coffee"]
+      build:
+        files: src: [
+          '<%=bp.app%>/scripts/bradypodion.coffee'
+          '<%=bp.app%>/scripts/*/**/*.coffee'
+        ]
         max_line_length:
           value: 79
           level: 'error'
-      tests:
-        files: src: "<%= coffee.tests.src %>"
+      test:
+        files: src: 'test/spec/**/*.coffee'
       gruntfile:
-        files: src: [GRUNTFILE]
-
-    groc:
-      options:
-        out: 'docs/'
-        index: "#{MODULES_DIR}/index.md"
-        strip: "#{MODULES_DIR}"
-      modules: [
-        "#{MODULES_DIR}/index.md"
-        "#{MODULES_DIR}/**/*.{coffee,less,md}"
-        "!#{MODULES_DIR}/**/test.coffee"
-        "!#{MODULES_DIR}/_less/*.less"
-        "!#{MODULES_DIR}/bradypodion.*"]
+        files: src: ['Gruntfile.coffee']
+
+    # Put files not handled in other tasks here
+    copy:
+      dist:
+        files: [
+          expand: true
+          dot: true
+          cwd: '<%=bp.app%>'
+          dest: '<%=bp.dist%>'
+          src: ['bower_components/**/*', 'index.html']
+        ]
+
+    concurrent:
+      server: [
+        'coffee:dist'
+        'coffee:test'
+        'cssbuild'
+      ]
+      dist: [
+        'coffee:dist'
+        'cssbuild'
+        'cssbuild:android'
+        'cssbuild:ios'
+        'cssbuild:ios7'
+      ]
 
     karma:
       options:

      matches = path.match(/(^(.*\/|)([a-zA-Z0-9-_.]+))\.less$/)
      platform = matches[3]
      if platform in platforms or platform is 'general'
        chunk = "@import '../#{matches[1]}';"
        chunks[platform] += chunk

    # import config and modules

'use strict'

module.exports = (grunt) ->
  require('load-grunt-tasks') grunt
  require('time-grunt') grunt
  grunt.initConfig
    bp:
      app: 'modules'
      dist: 'dist'
      tmp: '.tmp'
      platforms: ['android', 'ios', 'ios7']

    watch:
      coffee:
        files: [
          '<%=bp.app%>/scripts/bradypodion.coffee'
          '<%=bp.app%>/scripts/*/**/*.coffee'
        ]
        tasks: ['coffeelint:build', 'coffee:dist', 'karma:unit:run']

      coffeeTest:
        files: ['test/spec/**/*.coffee']
        tasks: ['coffeelint:test', 'coffee:test', 'karma:unit:run']

      gruntfile:
        files: ['Gruntfile.coffee']
        tasks: ['coffeelint:gruntfile']

      styles:
        files: ['<%=bp.app%>/styles/**/*.less']
        tasks: ['cssbuild']

      livereload:
        options:
          livereload: '<%= connect.options.livereload %>'

        files: [
          '{<%=bp.tmp%>,<%=bp.app%>}/**/*.html'
          '{<%=bp.tmp%>,<%=bp.app%>}/**/*.css'
          '{<%=bp.tmp%>,<%=bp.app%>}/**/*.js'
        ]

    connect:
      options:
        port: 9000
        hostname: '*'
        livereload: 35729

      livereload:
        options:
          open: 'http://localhost:9000/'
          base: ['<%=bp.tmp%>', '<%=bp.app%>', '<%=bp.dist%>']

      dist:
        options:
          base: '<%=bp.dist%>'

    shell:
      options:
        stderr : true
        stdout : true
        failOnError : true
      semver:
        command: './node_modules/semver-sync/bin/semver-sync -v'
      hooks:
        command: 'cp -R ./hooks ./.git/'

    clean:
      dist:
        files: [
          dot: true
          src: [
            '<%=bp.tmp%>/scripts/'
            '<%=bp.tmp%>/styles/'
            '<%=bp.dist%>/*'
            '!<%=bp.dist%>/.git*'
          ]
        ]

      server: '<%=bp.tmp%>/test'

    coffee:
      options:
        sourceMap: true
        sourceRoot: ''

      dist:
        options:
          join: yes
        src: [
          '<%=bp.app%>/scripts/bradypodion.coffee'
          '<%=bp.app%>/scripts/*/**/*.coffee'
        ]
        dest: '<%=bp.dist%>/bradypodion.js'

      test:
        options:
          join: yes
        src: [ 'test/spec/**/*.coffee' ]
        dest: '<%=bp.tmp%>/test/tests.js'

    coffeelint:
      options:
