Sha256: f4f035fa79375de0776e9d032d1ab8f7f3ebab8255b0e9623f6b504de51bb8c6

Contents?: true

Size: 1.21 KB

Versions: 8

Compression:

Stored size: 1.21 KB

Contents

namespace :vendor do
  desc "Fetch vendor packages"
  task :fetch do
    # FIXME: There is some fast and loose code right here.
    require 'lib/coupler/config'

    Coupler::Config.each_vendor_lib do |name, info|
      type_dir = File.join(Dir.pwd, 'vendor', info[:type])
      destination = File.join(type_dir, info[:dir] || info[:filename])
      if File.exist?(destination)
        puts "Not downloading #{name}"
        next
      end

      puts "Downloading #{name}..."
      io = info[:filename] ? File.open(destination, "w") : Tempfile.new(name)
      io.write(open(info[:url]).read)
      io.close

      if info[:uncompress] != false
        case info[:filetype]
        when "tarball"
          `tar -xzf #{io.path} -C #{type_dir}`
        when "jar", "zip"
          FileUtils.mkdir(destination)
          Dir.chdir(destination) do
            if info[:filetype] == "jar"
              `jar -xf #{io.path}`
            else
              `unzip #{io.path}`
            end
          end
        end
        io.unlink
      end
      if info[:filename] && info[:symlink]
        Dir.chdir(type_dir) do
          FileUtils.ln_sf("./#{info[:filename]}", info[:symlink], :verbose => true)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
coupler-0.0.9-java tasks/vendor.rake
coupler-0.0.8-java tasks/vendor.rake
coupler-0.0.7-java tasks/vendor.rake
coupler-0.0.6-java tasks/vendor.rake
coupler-0.0.4-java tasks/vendor.rake
coupler-0.0.3-java tasks/vendor.rake
coupler-0.0.2-java tasks/vendor.rake
coupler-0.0.1-java tasks/vendor.rake