Sha256: 45fba769bd94dcbcc8c1102576460970c9d9b2f99d46298c4a79f73dc496595c

Contents?: true

Size: 1.89 KB

Versions: 2

Compression:

Stored size: 1.89 KB

Contents

require 'rake'
require 'rake/tasklib'
require 'chrysalis/manifest'


module Rake
  
  class ChrysalisTask < TaskLib
    
    def initialize()
      yield self if block_given?
      define
    end
    
    def define
      namespace :project do
        
        desc "Show project information."
        task :info do
          raise "No project has been defined." if Chrysalis::Manifest.instance[:main].nil?
        
          puts ""
          puts "Project information: "

          main = Chrysalis::Manifest.instance[:main]
          main.graph.topsort.each do |url|
            p = Chrysalis::Manifest.instance[url]
            if p.nil?
              puts "* #{url} [Not Loaded]"
            else
              p.info
            end
          end
          
        end
      
        desc "Display task execution order."
        task :order do
          raise "No project has been defined." if Chrysalis::Manifest.instance[:main].nil?
        
          order = Chrysalis::Manifest.instance[:main].task_exec_order
        
          puts ""
          puts "Tasks execution order: "
          order.each { |url| puts "- #{url}" }
        end
      
        desc "Draw dependency graph."
        task :graph do
          raise "No project has been defined." if Chrysalis::Manifest.instance[:main].nil?
          
          g = Chrysalis::Manifest.instance[:main].graph
        
          name = Chrysalis::Manifest.instance[:main].name
          file = (name ? name.downcase.concat("-graph") : "graph")
        
          dot = g.write_to_graphic_file('jpg', file)
        
          puts "Dependency graph saved to #{dot}"
        end
        
      end
      
      desc "Retrieve dependencies."
      task :retrieve do
        raise "No project has been defined." if Chrysalis::Manifest.instance[:main].nil?
        Chrysalis::Manifest.instance[:main].retrieve
      end
      
      self
    end
    
  end
  
end


Chrysalis.boot

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chrysalis-0.1.0 lib/chrysalis/task.rb
chrysalis-0.1.1 lib/chrysalis/task.rb