Sha256: e6b2fddce1915c7a16d066b75135791ddd21ae96425c42460c58b7fc4f4d8fa2

Contents?: true

Size: 1.34 KB

Versions: 13

Compression:

Stored size: 1.34 KB

Contents

# encoding: utf-8

require "fileutils"
require "nake/colors"

module Nake
  module TaskHelpers
    include FileUtils
    def run(*parts)
      puts parts.join(" ").cyan
      system(*parts)
    end

    # return true if process suceeded, false otherwise
    # sh "ls -a"
    # sh "ls", "-a"
    def sh(*parts)
      puts "#{"$".magenta} #{parts.join(" ").cyan}"
      system("sh", "-c", *parts)
    end

    # zsh "ls .*(.)"
    def zsh(*parts)
      puts "#{"%".magenta} #{parts.join(" ").cyan}"
      system("zsh", "-c", *parts)
    end
  end

  module PrintHelpers
    def info(message)
      puts "~ #{message}".cyan if Nake.verbose
    end

    def note(message)
      puts "~ #{message}".green if Nake.verbose
    end

    def warn(message)
      Kernel.warn("~ #{message.yellow}") if Nake.debug
    end

    def debug(message)
      STDERR.puts("~ #{message.yellow}") if Nake.debug
    end

    def error(message)
      STDERR.puts "~ #{message}".red
    end

    def abort(message)
      Kernel.abort "[#{"ERROR".red}] #{message}"
    end

    def print_exception_and_abort(exception)
      abort exception.message
    end

    def print_exception_with_backtrace_and_abort(exception)
      abort [exception.message, exception.backtrace.join("\n- ")].join("\n")
    end
  end
end

Object.send(:include, Nake::TaskHelpers)
Object.send(:include, Nake::PrintHelpers)

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
nake-0.1.1 lib/nake/helpers.rb
nake-0.1 lib/nake/helpers.rb
nake-0.0.9.5 lib/nake/helpers.rb
nake-0.0.9.4 lib/nake/helpers.rb
nake-0.0.9.3 lib/nake/helpers.rb
nake-0.0.9.2 lib/nake/helpers.rb
nake-0.0.9.pre lib/nake/helpers.rb
do_riak-0.10.1.pre gems/gems/nake-0.0.8/lib/nake/helpers.rb
nake-0.0.8.pre lib/nake/helpers.rb
nake-0.0.8 lib/nake/helpers.rb
nake-0.0.7 lib/nake/helpers.rb
nake-0.0.6 lib/nake/helpers.rb
nake-0.0.5 lib/nake/helpers.rb