Class: ReapCommand

Inherits:
Console::Command
  • Object
show all
Defined in:
lib/reap/bin/reap.rb

Instance Method Summary collapse

Instance Method Details

#__debugObject Also known as: _D

debug mode (under construction)



34
# File 'lib/reap/bin/reap.rb', line 34

def __debug; $DEBUG = true ; end

#__forceObject Also known as: _f

option to display help



26
# File 'lib/reap/bin/reap.rb', line 26

def __force ; $FORCE = true ; end

#__helpObject Also known as: _h

option to display help



45
# File 'lib/reap/bin/reap.rb', line 45

def __help ; help ; end

#__password(pass) ⇒ Object Also known as: _p



37
# File 'lib/reap/bin/reap.rb', line 37

def __password( pass ); $PASSWORD =  pass ; end

#__pretendObject Also known as: _P

pretend mode (under construction)



30
# File 'lib/reap/bin/reap.rb', line 30

def __pretend; $PRETEND = true ; end

#__tasksObject Also known as: _t

option to display tasks



49
# File 'lib/reap/bin/reap.rb', line 49

def __tasks; tasks ; end

#__verboseObject Also known as: _V

verbose mode



22
# File 'lib/reap/bin/reap.rb', line 22

def __verbose ; $VERBOSE = true ; end

#__versionObject Also known as: _v

display reap version



41
# File 'lib/reap/bin/reap.rb', line 41

def __version ; version ; end

#_bObject

option for build version (only for package task)



53
# File 'lib/reap/bin/reap.rb', line 53

def _b ; $BUILD_VERSION = true ; end

#defaultObject

default action



62
63
64
# File 'lib/reap/bin/reap.rb', line 62

def default
  tasks
end

#help(*args) ⇒ Object

display help



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/reap/bin/reap.rb', line 75

def help(*args)
  unless args.empty?
    t = Reap.tasks[args[0]]
    s = "\n"
    s << "#{args[0]}: "
    s << t.task_desc.sub(/^\n+/, '').rstrip
    s << "\n\n"
    if thelp = t.task_help
      s << thelp.sub(/^\n+/, '').rstrip
    end
    s << "\n\n"
    puts s
  else
    puts HELP
  end
  exit 0
end

#scaffold(name, type = nil) ⇒ Object



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/reap/bin/reap.rb', line 131

def scaffold( name, type=nil )
  if File.directory?(name) and not $FORCE
    puts "Directory already exists. Use -f option to force scaffoling."
    exit -1
  end
  case type
  when 'std', 'standard', nil
    type = 'standard'
  when 'svn', 'subversion'
    type = 'subversion'
  else
    puts "Unrecognized project type."
    exit -1
  end
  # need to add gems workaround
  dir = File.join( ::Config::CONFIG['datadir'], 'reap', 'scaffold', type )
  #FileUtils.mkdir_p( name )
  FileUtils.cp_r( dir, name )
  puts "Project #{name} created. Good luck with your new project!"
  exit 0
end

#tasksObject Also known as: ls

list available tasks



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/reap/bin/reap.rb', line 95

def tasks
  if Reap.projectfile?
    puts
    sorted_names = Reap.tasks.keys.sort
    margin = sorted_names.collect{ |n| n.size }.max + 6
    sorted_names.each do |name|
      task_class = Reap.tasks[name]
      puts "  #{name}".ljust(margin) + "#{task_class.task_desc}"
    end
    puts
  else
    puts "No project information file found."
  end
  exit 0
end

#templateObject

copy the file from lib/data to the current dir.



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/reap/bin/reap.rb', line 114

def template
  f = nil
  if ::ProjectInfo::INFO_FILES.any?{ |f| File.exists?(f) }
    puts "Project file '#{f}' already exists."
    exit 0
  end
  filename = 'ProjectInfo'
  # need to add gems workaround
  dir = File.join( ::Config::CONFIG['datadir'], 'reap', 'scaffold', 'standard' )
  f = File.join( dir, filename )
  raise "ProjectInfo template file #{f} is missing." unless File.file?( f )
  # copy
  FileUtils.install( f, '.' )
  puts "#{filename} created. You'll need to fill it out."
  exit 0
end

#versionObject

display version



68
69
70
71
# File 'lib/reap/bin/reap.rb', line 68

def version
  puts "Reap  v#{Reap::Version}"
  exit 0
end