Class: ReapCommand
- Inherits:
-
Console::Command
- Object
- Console::Command
- ReapCommand
- Defined in:
- lib/reap/bin/reap.rb
Instance Method Summary collapse
-
#__debug ⇒ Object
(also: #_D)
debug mode (under construction).
-
#__force ⇒ Object
(also: #_f)
option to display help.
-
#__help ⇒ Object
(also: #_h)
option to display help.
- #__password(pass) ⇒ Object (also: #_p)
-
#__pretend ⇒ Object
(also: #_P)
pretend mode (under construction).
-
#__tasks ⇒ Object
(also: #_t)
option to display tasks.
-
#__verbose ⇒ Object
(also: #_V)
verbose mode.
-
#__version ⇒ Object
(also: #_v)
display reap version.
-
#_b ⇒ Object
option for build version (only for package task).
-
#default ⇒ Object
default action.
-
#help(*args) ⇒ Object
display help.
- #scaffold(type = nil) ⇒ Object
-
#tasks ⇒ Object
(also: #ls)
list available tasks.
-
#template ⇒ Object
copy the file from lib/data to the current dir.
-
#version ⇒ Object
display version.
Instance Method Details
#__debug ⇒ Object Also known as: _D
debug mode (under construction)
36 |
# File 'lib/reap/bin/reap.rb', line 36 def __debug; $DEBUG = true ; end |
#__force ⇒ Object Also known as: _f
option to display help
28 |
# File 'lib/reap/bin/reap.rb', line 28 def __force ; $FORCE = true ; end |
#__help ⇒ Object 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 |
#__pretend ⇒ Object Also known as: _P
pretend mode (under construction)
32 |
# File 'lib/reap/bin/reap.rb', line 32 def __pretend; $PRETEND = true ; end |
#__tasks ⇒ Object Also known as: _t
option to display tasks
51 |
# File 'lib/reap/bin/reap.rb', line 51 def __tasks; tasks ; end |
#__verbose ⇒ Object Also known as: _V
verbose mode
24 |
# File 'lib/reap/bin/reap.rb', line 24 def __verbose ; $VERBOSE = true ; end |
#__version ⇒ Object Also known as: _v
display reap version
43 |
# File 'lib/reap/bin/reap.rb', line 43 def __version ; version ; end |
#_b ⇒ Object
option for build version (only for package task)
55 |
# File 'lib/reap/bin/reap.rb', line 55 def _b ; $BUILD_VERSION = true ; end |
#default ⇒ Object
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 |
#tasks ⇒ Object 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 |
#template ⇒ Object
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 |