Sha256: d9d66aab9022f66893e40c5c357c0c27d6312f0c48b7ed8ca1c291d659b764fd

Contents?: true

Size: 1.71 KB

Versions: 2

Compression:

Stored size: 1.71 KB

Contents

# -*- coding: utf-8 -*-


require 'erb'
require 'pp'


module Xot


  module Rake


    def empty_task (*names)
      names.each do |name|
        task name => '.'
      end
    end

    def glob (*patterns)
      paths = []
      patterns.each do |pattern|
        paths.concat Dir.glob(pattern)
      end
      paths
    end

    def erb (str)
      ERB.new(str, nil, "%").result binding
    end

    def compile (path, out)
      open(path) do |input|
        open(out, "w") do |output|
          output.write erb(input.read)
        end
      end
    #rescue
    end

    def params (n, sep = "", &block)
      raise "block not given." unless block
      return "" if n == 0
      (1..n).map(&block).join(sep)
    end

    def convertions (paths, convs)
      raise "empty conversion." if convs.empty?
      paths = paths.map do |path|
        convpath = path
        convs.each do |from, to|
          convpath = convpath.sub(/#{from.gsub('.', '\.')}$/, to)
        end
        [path, convpath]
      end
      Hash[*paths.flatten]
    end

    def env (name, defval = nil)
      case val = (ENV[name.to_s] || Object.const_get(name) rescue defval)
      when /^\d+$/ then val.to_i
      when 'true'  then true
      when 'false' then false
      else val
      end
    end

    def header (mod)
      puts "-- #{mod.to_s.capitalize} " + "-" * 50
    end

    def win32? ()
      RUBY_PLATFORM =~ /mswin|ming|cygwin/
    end

    def mswin? ()
      RUBY_PLATFORM =~ /mswin/
    end

    def ming? ()
      RUBY_PLATFORM =~ /ming/
    end

    def cygwin? ()
      RUBY_PLATFORM =~ /cygwin/
    end

    def cocoa? ()
      RUBY_PLATFORM =~ /darwin/
    end

    def clang? ()
      RbConfig::CONFIG['CXX'] =~ /clang/
    end


  end# Rake


end# Xot

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
xot-0.1.6 lib/xot/rake.rb
xot-0.1.5 lib/xot/rake.rb