Sha256: 6a083f26d7cad00525471cb6dc89cf6645fc663b12470060744ed7b6fac5822a

Contents?: true

Size: 893 Bytes

Versions: 3

Compression:

Stored size: 893 Bytes

Contents

require 'rake/tasklib'

module Analects
  class RakeTasks < Rake::TaskLib
    def initialize(name = :analects, &blk)
      @name = name
      if block_given?
        if blk.arity == 0
          self.instance_eval(&blk)
        else
          yield self
        end
      end
      define
    end

    def library
      @library ||= Analects::Library.new(options)
    end

    def sources
      library.sources
    end

    def options
      @options ||= {}
    end

    def data_dir(dir)
      options[:data_dir] = dir
    end

    def define
      namespace @name do
        namespace :download do
          sources.each do |source|
            desc "download #{source.name}"
            task source.name do
              source.retrieve!
            end
          end

          desc 'download all sources'
          task :all => sources.map(&:name)
        end
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
analects-0.4.2 lib/analects/rake_tasks.rb
analects-0.4.1 lib/analects/rake_tasks.rb
analects-0.4.0 lib/analects/rake_tasks.rb