Class: Forge::Tool

Inherits:
Object
  • Object
show all
Defined in:
lib/proutils/icli/tool.rb

Overview

Tool class provides a base class for packaging tools.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dryrunObject

Returns the value of attribute dryrun.



12
13
14
# File 'lib/proutils/icli/tool.rb', line 12

def dryrun
  @dryrun
end

#forceObject

Returns the value of attribute force.



14
15
16
# File 'lib/proutils/icli/tool.rb', line 14

def force
  @force
end

#modeObject

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 bar)

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

#quietObject

Returns the value of attribute quiet.



15
16
17
# File 'lib/proutils/icli/tool.rb', line 15

def quiet
  @quiet
end

#settingsObject (readonly)

Returns the value of attribute settings.



18
19
20
# File 'lib/proutils/icli/tool.rb', line 18

def settings
  @settings
end

#traceObject

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

Returns:

  • (Boolean)


37
# File 'lib/proutils/icli/tool.rb', line 37

def dryrun?  ;  @dryrun ; end

#force?Boolean

Returns:

  • (Boolean)


39
# File 'lib/proutils/icli/tool.rb', line 39

def force?   ;  @force  ; end

#quiet?Boolean

Returns:

  • (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(message)
  puts message 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(message)
  puts message if dryrun? or trace?
end

#trace?Boolean

Returns:

  • (Boolean)


38
# File 'lib/proutils/icli/tool.rb', line 38

def trace?   ;  @trace  ; end

#verbose?Boolean

Returns:

  • (Boolean)


41
# File 'lib/proutils/icli/tool.rb', line 41

def verbose? ; !@quiet  ; end