Sha256: 20ec189dc36010ba378a955f7227bd6964e55ca8c583cec1009fa94188910f49

Contents?: true

Size: 962 Bytes

Versions: 2

Compression:

Stored size: 962 Bytes

Contents

class HaxeLib < Rake::FileTask
  class << self
    def home
      `haxelib config`.chomp
    end

    def spec_to_path spec
      id, version = spec.split(":")
      File.join( home, id, version.gsub(".",",") )
    end

    def lookup spec
      id, version = spec.split(":")
      task = HaxeLib.define_task( spec_to_path spec )
      task.id = id
      task.version = version
      task
    end
  end

  attr_accessor :id, :version

  def initialize(*args)
    super
    enhance do |task|
      task.enhance do
        if download_needed?
          info "Downloading #{to_spec}"
          download
        end
      end
    end
  end

  def download
    fail( "Could not download #{to_spec}") unless system "haxelib install #{id} #{version}"
  end

  def download_needed?
    !File.exists?(name)
  end

  def to_spec
    "#{id}:#{version}"
  end

end

module Buildr
  def haxelib spec
    haxelib = HaxeLib.lookup(spec)
    haxelib.invoke
    haxelib
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
buildr-hx-0.0.4.pre lib/buildr/hx/core/haxe_lib.rb
buildr-hx-0.0.3.pre lib/buildr/hx/core/haxe_lib.rb