class GNOME2::Rake::SourceDownloadTask - glib2-2.2.0 Documentation

# class GNOME2::Rake::SourceDownloadTask

### Public Class Methods

new(package) click to toggle source

    # File lib/gnome2/rake/source-download-task.rb, line 28
    def initialize(package)
      @package = package
    end

### Public Instance Methods

define() click to toggle source

    # File lib/gnome2/rake/source-download-task.rb, line 32
    def define
      namespace :source do
        namespace :downloader do
          task :before
          define_download_tasks
          download_tasks = @package.external_packages.collect do |package|
            "source:downloader:download:#{package.name}"
          end
          task :download => download_tasks
          task :after
        end

        desc "Dowanload sources"
        task :download => [
          "source:downloader:before",
          "source:downloader:download",
          "source:downloader:after",
        ]
      end
    end

define_download_tasks() click to toggle source

    # File lib/gnome2/rake/source-download-task.rb, line 53
    def define_download_tasks
      namespace :download do
        @package.external_packages.each do |package|
          download_dir = @package.download_dir
          tar_full_path = download_dir + package.archive_base_name

          task :before
          task :after
          desc "Download #{package.label} into #{download_dir}."
          # task package[:name] => [:before, tar_full_path.to_s, :after]
          task package[:name] => tar_full_path.to_s

          directory_path = tar_full_path.dirname
          directory directory_path.to_s
          file tar_full_path.to_s => directory_path.to_s do
            archive_url = package.archive_url
            rake_output_message "Downloading... #{archive_url}"
            open(archive_url) do |downloaded_tar|
              tar_full_path.open("wb") do |tar_file|
                tar_file.print(downloaded_tar.read)
              end
            end
          end
        end
      end
    end