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)



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

def __debug; $DEBUG = true ; end

#__forceObject Also known as: _f

option to display help



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

def __force ; $FORCE = true ; end

#__helpObject Also known as: _h

option to display help



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

def __help ; help ; end

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



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

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

#__pretendObject Also known as: _P

pretend mode (under construction)



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

def __pretend; $PRETEND = true ; end

#__tasksObject Also known as: _t

option to display tasks



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

def __tasks; tasks ; end

#__verboseObject Also known as: _V

verbose mode



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

def __verbose ; $VERBOSE = true ; end

#__versionObject Also known as: _v

display reap version



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

def __version ; version ; end

#_bObject

option for build version (only for package task)



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

def _b ; $BUILD_VERSION = true ; end

#defaultObject

default action



64
65
66
# File 'lib/reap/bin/reap.rb', line 64

def default
  tasks
end

#help(*args) ⇒ Object

display help



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

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(type = nil) ⇒ Object



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/reap/bin/reap.rb', line 137

def scaffold( type=nil )
  content = Dir.entries('.') - [ '.', '..' ]
  if not content.empty? and not $FORCE
    puts "Directory already has content. Use -f option to force scaffolding."
    exit -1
  end
  type ||= 'standard'
  type = 'standard' if type == 'std'
  type = 'subversion' if type == 'svn'
  # gems workaround
  if dir = Gem.gempath('reap')
    dir = File.join( dir, 'data', 'reap', 'scaffold', type )
  else
    dir = File.join( ::Config::CONFIG['datadir'], 'reap', 'scaffold', type )
  end
  #
  unless File.directory?( dir )
    puts "Unrecognized project type."
    exit -1
  end
  #FileUtils.mkdir_p( name )
  FileUtils.cp_r( File.join( dir, '.'), '.' )
  puts "Project ready."
end

#tasksObject Also known as: ls

list available tasks



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

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.



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/reap/bin/reap.rb', line 116

def template
  f = nil
  if ::ProjectInfo::INFO_FILES.any?{ |f| File.exists?(f) }
    puts "Project file '#{f}' already exists."
    return
  end
  filename = 'ProjectInfo'
  # if using gems
  if dir = Gem.gempath('reap')
    dir = File.join( dir, 'data', 'reap', 'scaffold', 'standard' )
  else
    dir = File.join( ::Config::CONFIG['datadir'], 'reap', 'scaffold', 'standard' )
  end
  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



70
71
72
73
# File 'lib/reap/bin/reap.rb', line 70

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