     ))
     .pipe(gulp.dest(options.dest))
 
+processJavascripts = (options = {})->
+  settings = _.extend {}, options,
+    name: 'app.js'
+    dest: ASSETS_LOCATION
 
-gulp.task 'clean', ->
-  gulp.src('./public/assets', read: false)
-    .pipe(clean())
+  compileJavascripts("#{CORE_LOCATION}/javascripts/client/index.coffee", settings)
 
-gulp.task 'browserify', ['clean'], ->
-  compileJavascripts './app/javascripts/client/index.coffee',
-    name: 'app.js'
-    dest: './public/assets'
+processStylesheets = (options = {})->
+  settings = _.extend {}, options,
+    name: 'app.css'
+    dest: ASSETS_LOCATION
 
-gulp.task 'stylus', ['clean'], ->
-  compileStylesheets './app/stylesheets/index.styl',
-    name: 'app.css'
-    dest: './public/assets'
+  compileStylesheets("#{CORE_LOCATION}/stylesheets/index.styl", settings)
 
-gulp.task 'static', ['clean'], ->
-  compileStylesheets './app/stylesheets/static.styl',
+processStatic = ->
+  compileStylesheets "#{CORE_LOCATION}/stylesheets/static.styl",
     name: 'static.css'
-    dest: './public'
+    dest: PUBLIC_LOCATION
 
-  compileTemplates ['./app/templates/static/**/*.jade', '!./app/templates/static/**/_*.jade'],
-    dest: './public'
+  compileTemplates ["#{CORE_LOCATION}/templates/static/**/*.jade", "!#{CORE_LOCATION}/templates/static/**/_*.jade"],
+    dest: PUBLIC_LOCATION
+
+gulp.task 'clean', -> gulp.src(ASSETS_LOCATION, read: false).pipe(clean())
+gulp.task 'browserify', ['clean'], -> processJavascripts()
+gulp.task 'stylus', ['clean'], -> processStylesheets()
+gulp.task 'static', ['clean'], -> processStatic()
 
 gulp.task 'minify', ['browserify', 'stylus'], ->
-  gulp.src('./public/assets/*.js')
+  gulp.src("#{ASSETS_LOCATION}/*.js")
     .pipe(uglify())
     .pipe(rename(suffix: '.min'))
-    .pipe(gulp.dest('./public/assets'))
+    .pipe(gulp.dest(ASSETS_LOCATION))
 
-  gulp.src('./public/assets/*.css')
+  gulp.src("#{ASSETS_LOCATION}/*.css")
     .pipe(minifyCSS())
     .pipe(rename(suffix: '.min'))
-    .pipe(gulp.dest('./public/assets'))
+    .pipe(gulp.dest(ASSETS_LOCATION))
 
-  gulp.src('./public/static.css')
+  gulp.src("#{PUBLIC_LOCATION}/static.css")
     .pipe(minifyCSS())
-    .pipe(gulp.dest('./public'))
+    .pipe(gulp.dest(PUBLIC_LOCATION))
 
-  gulp.src('./public/*.html')
+  gulp.src("#{PUBLIC_LOCATION}/*.html")
     .pipe(htmlmin(
       removeComments: true
       collapseWhitespace: true

pkg = require('./package')

gulp = require('gulp')
util = require('gulp-util')

      useShortDoctype: true
      removeEmptyAttributes: true
    ))
    .pipe(gulp.dest(PUBLIC_LOCATION))

gulp.task 'hashify', ['minify'], ->
  gulp.src("#{ASSETS_LOCATION}/*.min.*")
    .pipe(rev())
    .pipe(gulp.dest("#{ASSETS_LOCATION}/"))
    .pipe(rev.manifest())
    .pipe(rename('hashmap.json'))
    .pipe(gulp.dest("#{ASSETS_LOCATION}/"))

gulp.task 'compress', ['hashify'], ->
  gulp.src("#{ASSETS_LOCATION}/*.min-*.*")
    .pipe(gzip())
    .pipe(gulp.dest(ASSETS_LOCATION))

  gulp.src("#{PUBLIC_LOCATION}/*.css")
    .pipe(gzip())
    .pipe(gulp.dest(PUBLIC_LOCATION))

gulp.task 'watch', ->
  processJavascripts(watch: true)

  stylesheets = [
    "#{CORE_LOCATION}/stylesheets/**/*.styl"
    './vendor/**/*.css'
    './vendor/**/*.styl'
    "!#{CORE_LOCATION}/stylesheets/static.styl"
  ]
  gulp.watch(stylesheets).on 'change', (event)->
    watchReporter(event)
    processStylesheets()

  templates = [
    "#{CORE_LOCATION}/stylesheets/static.styl"
    "#{CORE_LOCATION}/templates/static/**/*.jade"
  ]
  gulp.watch(templates).on 'change', (event)->
    watchReporter(event)
    processStatic()

gulp.task('default', ['browserify', 'stylus', 'static'])
gulp.task('build', ['compress'])
