Class: Forge::Tool
- Inherits:
-
Object
- Object
- Forge::Tool
- Defined in:
- lib/proutils/icli/tool.rb
Overview
Tool class provides a base class for packaging tools.
Instance Attribute Summary collapse
-
#dryrun ⇒ Object
Returns the value of attribute dryrun.
-
#force ⇒ Object
Returns the value of attribute force.
-
#mode ⇒ Object
Verbosity mode allows for gradations of output types.
-
#quiet ⇒ Object
Returns the value of attribute quiet.
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
-
#trace ⇒ Object
Returns the value of attribute trace.
Instance Method Summary collapse
-
#cd(dir, &block) ⇒ Object
Extra filesystem util.
- #dryrun? ⇒ Boolean
- #force? ⇒ Boolean
-
#initialize(settings) ⇒ Tool
constructor
New Tool.
- #quiet? ⇒ Boolean
-
#say(message) ⇒ Object
Standard message to user.
-
#sh(cmd) ⇒ Object
Shell out.
-
#status(message) ⇒ Object
Internal status report.
- #trace? ⇒ Boolean
- #verbose? ⇒ Boolean
Constructor Details
#initialize(settings) ⇒ Tool
New Tool.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/proutils/icli/tool.rb', line 22 def initialize( settings ) @settings = settings settings.each do |k,v| send("#{k.to_s.downcase}=",v) end if dryrun? extend FileUtils::DryRun extend ZipUtils::DryRun else extend FileUtils extend ZipUtils end end |
Instance Attribute Details
#dryrun ⇒ Object
Returns the value of attribute dryrun.
12 13 14 |
# File 'lib/proutils/icli/tool.rb', line 12 def dryrun @dryrun end |
#force ⇒ Object
Returns the value of attribute force.
14 15 16 |
# File 'lib/proutils/icli/tool.rb', line 14 def force @force end |
#mode ⇒ Object
Verbosity mode allows for gradations of output types. Generally recognized values are:
quiet (same as quiet flag)
normal (default mode)
verbose (give details)
progress (use progress )
You add another mode if you need. any task that doesn’t recognize the current mode should fallback to normal.
56 57 58 |
# File 'lib/proutils/icli/tool.rb', line 56 def mode @mode end |
#quiet ⇒ Object
Returns the value of attribute quiet.
15 16 17 |
# File 'lib/proutils/icli/tool.rb', line 15 def quiet @quiet end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
18 19 20 |
# File 'lib/proutils/icli/tool.rb', line 18 def settings @settings end |
#trace ⇒ Object
Returns the value of attribute trace.
13 14 15 |
# File 'lib/proutils/icli/tool.rb', line 13 def trace @trace end |
Instance Method Details
#cd(dir, &block) ⇒ Object
Extra filesystem util
70 71 72 73 |
# File 'lib/proutils/icli/tool.rb', line 70 def cd(dir, &block) status "cd #{dir}" Dir.chdir(dir, &block) end |
#dryrun? ⇒ Boolean
37 |
# File 'lib/proutils/icli/tool.rb', line 37 def dryrun? ; @dryrun ; end |
#force? ⇒ Boolean
39 |
# File 'lib/proutils/icli/tool.rb', line 39 def force? ; @force ; end |
#quiet? ⇒ Boolean
40 |
# File 'lib/proutils/icli/tool.rb', line 40 def quiet? ; @quiet ; end |
#say(message) ⇒ Object
Standard message to user. Output unless quiet.
85 86 87 |
# File 'lib/proutils/icli/tool.rb', line 85 def say() puts unless quiet? end |
#sh(cmd) ⇒ Object
Shell out.
63 64 65 66 |
# File 'lib/proutils/icli/tool.rb', line 63 def sh(cmd) puts cmd unless quiet? system(cmd) unless dryrun? end |
#status(message) ⇒ Object
Internal status report. Only output if dryrun or trace mode.
78 79 80 |
# File 'lib/proutils/icli/tool.rb', line 78 def status() puts if dryrun? or trace? end |
#trace? ⇒ Boolean
38 |
# File 'lib/proutils/icli/tool.rb', line 38 def trace? ; @trace ; end |
#verbose? ⇒ Boolean
41 |
# File 'lib/proutils/icli/tool.rb', line 41 def verbose? ; !@quiet ; end |