Top Level Namespace

Includes:
Rake::DSL

Defined Under Namespace

Modules: Dev Classes: Array, Hash, String

Constant Summary collapse

DEV_ROOT =
Dev::Environment.dev_root
TASKS =

module Dev

Dev::Tasks.new
DEV =

module Dev

Dev::Project.new
PROJECT =

DEV.refresh

DEV
CMD =

module Dev

Dev::Commands.new()

Instance Method Summary collapse

Instance Method Details

#generate_task_hash(project) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/dev/Tasks.rb', line 26

def generate_task_hash(project)
  task_hash = { 
    :info=> { :desc=> 'display information about the rakefile' },
    #:test=> { :desc=> 'run unit tests' },

    :loc=> { :desc=> 'count the lines of code' },
    #:setup=> { :desc=> 'setup the project environment' },

    :pull=> { :desc=> 'rake working copies of dependencies' },
    :check=> { :desc=> 'checks if the project default task may be skipped' }
  }
  if(!CMD[:setup].nil? && CMD[:setup].length > 0)
    task_hash[:setup]={ :desc=> 'setup the project environment' }
  end

  if(project[:scm_type]=="svn" || project[:scm_type]=="git")
    task_hash[:add]   ={ :desc=> 'add files defined by src_glob to source code management' }
  task_hash[:commit]={ :desc=> 'commit changes to source code management' }
  task_hash[:update]={ :desc=> 'updates changes from source code management' }
  end
  
  task_hash[:compile] = { :desc=> 'compile source code' } if CMD.has_key?(:compile) && CMD[:compile].length > 0 #project.has_key?(:compile) && project[:compile].length > 0

  task_hash[:replace] = { :desc=> 'replace text' } if CMD.has_key?(:replace) && CMD[:replace].length > 0
  task_hash[:test]={:desc=>'run unit tests'} if CMD.has_key?(:test) && CMD[:test].length > 0
 
  if project[:type]=="gem" || project[:type]=="ruby"
    task_hash[:features] = { :desc=> 'tests cucumber features' }
  end
  return task_hash
end

#generate_tasks(project) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/dev/Tasks.rb', line 55

def generate_tasks(project)
  puts_debug "generate_tasks"
  hash=generate_task_hash project

  hash.each do |k,v|
  name=k.to_s
  puts_debug "checking if task #{name} should be autogenerated"
  desc=nil
  desc=v[:desc] if v.has_key?(:desc)
  #ruby="task :#{name} do; task_start '#{name}'; PROJECT.#{name}; end" if PROJECT.respond_to?(name)

  ruby="task :#{name} do; task_start '#{name}'; CMD.#{name}; end"
  ruby="desc '#{desc}'; " + ruby unless desc.nil? 
  if !task_exists?(name)
    puts_debug "defining task #{name} with '#{ruby}'"
    eval(ruby)
  end
  end

  # generate default task

  if(!defined?(DEV_NO_DEFAULT_TASK))
    Rake.application.instance_variable_get('@tasks').delete('default')
  task_list=""
  ["check","setup","replace","pre_compile","compile","post_compile","pre_test","test","post_test","add","commit","update","finalize"].each {|t|
    if(hash.has_key?(t.to_sym) || task_exists?(t) || (CMD.has_key?(t.to_sym) && CMD[t.to_sym].count > 0) )
      task_list = "#{task_list}," if task_list.length > 0
      task_list = "#{task_list} :#{t}"
      default_code = "#{default_code} :#{t},"
    end
  }
  desc="desc '#{task_list}'".gsub(' ',"").gsub(':',"")
  eval("#{desc}; task :default => [#{task_list}] do; task_start('default'); end")
  end
end

#puts_debug(msg) ⇒ Object

if DEV_DEBUG is defined, puts_debug will send message to the console



27
28
29
30
31
# File 'lib/dev.rb', line 27

def puts_debug msg
  if(defined?(DEV_DEBUG))
    puts msg
  end
end

#puts_debug_verbose(msg) ⇒ Object

if DEV_DEBUG_VERBOSE is defined, puts_debug_verbose will send message to the console



34
35
36
37
38
# File 'lib/dev.rb', line 34

def puts_debug_verbose msg
  if(defined?(DEV_DEBUG_VERBOSE))
    puts msg
  end
end

#task_exists?(name) ⇒ Boolean

Returns:

  • (Boolean)


89
90
91
92
93
94
95
# File 'lib/dev/Tasks.rb', line 89

def task_exists?(name)
  if("#{RUBY_VERSION}">"1.9.1")
    return Rake::Task.task_defined?(name)
  else
    return false
  end
end

#task_start(task_name) ⇒ Object



9
10
11
12
# File 'lib/dev/Tasks.rb', line 9

def task_start(task_name)
  puts " "
  puts "[:#{task_name}]".foreground(:yellow).bright + " " + Dir.pwd
end