Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 95b09d7f50
Fetching contributors…

Cannot retrieve contributors at this time

file 68 lines (51 sloc) 1.906 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
require 'rubygems'
require 'open3'
require 'talks'

$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
require 'jquery-turbolinks/version'

namespace :release do
  task :build_gem do
    system 'gem build jquery-turbolinks.gemspec'
  end
  
  task gem: :build_gem do
    system "gem push jquery-turbolinks-#{JqueryTurbolinks::VERSION}.gem"
  end

  task :npm do
    system 'npm publish'
  end

  task all: [:gem, :npm]
end

namespace :js do
  task :build do
    command = [
      './node_modules/coffee-script/bin/coffee',
      '--compile',
      '--output ./vendor/assets/javascripts/ ./src/jquery.turbolinks.coffee'
    ]
    system command.join(' ')
  end
end

task :test do
 stdin, stdout, stderr = Open3.popen3 \
    './node_modules/mocha/bin/mocha ./spec/*_spec.coffee --compilers coffee:coffee-script -R spec -c'

  puts stdout_array = stdout.readlines
  puts stderr_array = stderr.readlines

  stdout_strings = stdout_array.to_s
  stderr_strings = stderr_array.to_s

  if stderr_strings and
    error_match = stderr_strings.match(/(\d+) of (\d+) (test[s]?) failed/)

    failed_count, total_count, tests_failed_str = error_match.captures

    message = "#{failed_count} of #{total_count} #{tests_failed_str} failed"

  elsif stdout_strings_match = stdout_strings.match(/(\d+) (test[s]?) complete/)
    complete_count, tests_complete_str = stdout_strings_match.captures

    if pending_matches = stdout_strings.match(/(\d+) test[s]? pending/)
      pending_count, tests_pending_str = pending_matches.captures
    end

    message = "#{complete_count} #{tests_complete_str} complete"
    message += ", #{pending_count} #{tests_pending_str} pending" if pending_count

  else
    message = 'Something wrong, check console output.'
  end

  `bundle exec terminal-notifier -message '#{message}' -title 'Test results' -remove TEST_RESULTS -group TEST_RESULTS`
  Talks.say message, detach: true
end
Something went wrong with that request. Please try again.