<commit_before>gulp        = require 'gulp'
stylus      = require 'gulp-stylus'
nib         = require 'nib'
jade        = require 'gulp-jade'
coffee      = require 'gulp-coffee'
connect     = require 'gulp-connect'
minifyCSS   = require 'gulp-minify-css'
uglify      = require 'gulp-uglify'
gutil       = require 'gulp-util'
path        = require 'path'
changed     = require 'gulp-changed'
concat      = require 'gulp-concat'
open        = require 'gulp-open'
aws         = require 'gulp-awspublish'
fs          = require 'fs'
args        = require('yargs').argv;


config_file = if args.config? then args.config else path.resolve('./config.json')
config = JSON.parse(fs.readFileSync(config_file, 'utf8'));

gulp.task 'clean', ->
  files = [ config.app + '/*.js',
            config.app + '/*.css',
            config.app + '/*.html']

  gulp.src files ->
    read: false
    .pipe clean force: true

gulp.task 'build-templates', ->
  data = {}
  gulp.src config.templates
    .pipe jade(data: data)
    .pipe gulp.dest config.app
    .pipe connect.reload()

gulp.task 'build-styles', ->
  gulp.src config.styles
    .pipe stylus (use: [nib()], errors: true)
    .pipe minifyCSS keepBreaks: true
    .pipe concat config.app_style
    .pipe gulp.dest config.app
      .pipe connect.reload()

gulp.task 'build-scripts', ->
  gulp.src config.scripts
    .pipe changed config.app
    .pipe uglify()
    .pipe concat config.app_script
    .pipe gulp.dest config.app
    .pipe connect.reload()

gulp.task 'copy-brush-assets', ->
  gulp.src 'dist'
    .pipe gulp.dest 'examples/app'

gulp.task 'start-server', ->
  connect.server
    root: config.app
    port: config.port
    livereload: true

gulp.task 'open', ->
  options =
    url: "http://localhost:" + config.port
    app: "google chrome"

  gulp.src config.app + '/index.html'
    .pipe open("", options)

gulp.task 'watch', ->
    gulp.watch(config.templates, ['build-templates'])
    gulp.watch(config.styles, ['build-styles'])
    gulp.watch(config.scripts, ['build-scripts'])

gulp.task 'publish', ->
  credentials = JSON.parse(fs.readFileSync('.aws.json', 'utf8'));
  publisher = aws.create(credentials)

  headers =
    'Cache-Control': 'max-age=315360000, no-transform, public'

  gulp.src config.app + '*.*'
    .pipe publisher.publish(headers)
    .pipe publisher.cache()
    .pipe aws.reporter()

gulp.task('build', ['build-templates', 'build-styles', 'build-scripts'])
gulp.task('serve', ['build', 'start-server', 'open', 'watch'])
gulp.task('default', ['build'])
<commit_msg>refactor<commit_after>gulp        = require 'gulp'
stylus      = require 'gulp-stylus'
nib         = require 'nib'
jade        = require 'gulp-jade'
coffee      = require 'gulp-coffee'
connect     = require 'gulp-connect'
minifyCSS   = require 'gulp-minify-css'
uglify      = require 'gulp-uglify'
gutil       = require 'gulp-util'
path        = require 'path'
changed     = require 'gulp-changed'
concat      = require 'gulp-concat'
open        = require 'gulp-open'
aws         = require 'gulp-awspublish'
fs          = require 'fs'
args        = require('yargs').argv;


config_file = if args.config? then args.config else path.resolve('./config.json')
config = JSON.parse(fs.readFileSync(config_file, 'utf8'));

gulp.task 'clean', ->
  files = [ config.app + '/*.js',
            config.app + '/*.css',
            config.app + '/*.html']

  gulp.src files ->
    read: false
    .pipe clean force: true

gulp.task 'build-templates', ->
  data = {}
  gulp.src config.templates
    .pipe jade(data: data)
    .pipe gulp.dest config.app
    .pipe connect.reload()

gulp.task 'build-styles', ->
  gulp.src config.styles
    .pipe stylus (use: [nib()], errors: true)
    .pipe minifyCSS keepBreaks: true
    .pipe concat config.app_style
    .pipe gulp.dest config.app
    .pipe connect.reload()

gulp.task 'build-scripts', ->
  gulp.src config.scripts
    .pipe changed config.app
    .pipe uglify()
    .pipe concat config.app_script
    .pipe gulp.dest config.app
    .pipe connect.reload()

gulp.task 'copy-brush-assets', ->
  gulp.src 'dist'
    .pipe gulp.dest 'examples/app'

gulp.task 'start-server', ->
  connect.server
    root: config.app
    port: config.port
    livereload: true

gulp.task 'open-chrome', ->
  options =
    url: "http://localhost:" + config.port
    app: "google chrome"

  gulp.src config.app + '/index.html'
    .pipe open("", options)

gulp.task 'watch', ->
    gulp.watch(config.templates, ['build-templates'])
    gulp.watch(config.styles, ['build-styles'])
    gulp.watch(config.scripts, ['build-scripts'])

gulp.task 'publish', ->
  credentials = JSON.parse(fs.readFileSync('.aws.json', 'utf8'));
  publisher = aws.create(credentials)

  headers =
    'Cache-Control': 'max-age=315360000, no-transform, public'

  gulp.src config.app + '*.*'
    .pipe publisher.publish(headers)
    .pipe publisher.cache()
    .pipe aws.reporter()

gulp.task('build', ['build-templates', 'build-styles', 'build-scripts'])
gulp.task('serve', ['build', 'start-server', 'open-chrome', 'watch'])
gulp.task('default', ['serve'])

{'fraction_non_alphanumeric': 0.16047197640117994, 'fraction_numerical': 0.004326450344149459, 'mean_word_length': 2.867680608365019, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4390730', 'n_tokens_mistral': 1782, 'n_tokens_neox': 1751, 'n_words': 392}