Class: Analects::RakeTasks

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/analects/rake_tasks.rb

Instance Method Summary collapse

Constructor Details

#initialize(name = :analects, &blk) ⇒ RakeTasks

Returns a new instance of RakeTasks.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/analects/rake_tasks.rb', line 5

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

Instance Method Details

#data_dir(dir) ⇒ Object



29
30
31
# File 'lib/analects/rake_tasks.rb', line 29

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

#defineObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/analects/rake_tasks.rb', line 33

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

#libraryObject



17
18
19
# File 'lib/analects/rake_tasks.rb', line 17

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

#optionsObject



25
26
27
# File 'lib/analects/rake_tasks.rb', line 25

def options
  @options ||= {}
end

#sourcesObject



21
22
23
# File 'lib/analects/rake_tasks.rb', line 21

def sources
  library.sources
end