Class: Bake::Blocks::FileUtil
- Inherits:
-
Object
- Object
- Bake::Blocks::FileUtil
- Defined in:
- lib/blocks/fileutil.rb
Instance Method Summary collapse
- #clean ⇒ Object
- #cleanStep ⇒ Object
- #execute ⇒ Object
- #exitStep ⇒ Object
-
#initialize(config, type, projectDir) ⇒ FileUtil
constructor
A new instance of FileUtil.
- #run ⇒ Object
- #startupStep ⇒ Object
Constructor Details
#initialize(config, type, projectDir) ⇒ FileUtil
Returns a new instance of FileUtil.
8 9 10 11 12 13 14 |
# File 'lib/blocks/fileutil.rb', line 8 def initialize(config, type, projectDir) @arg1 = config.name @arg2 = config.respond_to?(:to) ? config.to : nil @type = type @projectDir = projectDir @echo = (config.echo != "off") end |
Instance Method Details
#clean ⇒ Object
54 55 56 57 |
# File 'lib/blocks/fileutil.rb', line 54 def clean # nothing to do here return true end |
#cleanStep ⇒ Object
50 51 52 |
# File 'lib/blocks/fileutil.rb', line 50 def cleanStep return run() end |
#execute ⇒ Object
38 39 40 |
# File 'lib/blocks/fileutil.rb', line 38 def execute return run() end |
#exitStep ⇒ Object
46 47 48 |
# File 'lib/blocks/fileutil.rb', line 46 def exitStep return run() end |
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/blocks/fileutil.rb', line 16 def run Dir.chdir(@projectDir) do if @type == :touch puts "Touching #{@arg1}" if @echo FileUtils.touch(@arg1) elsif @type == :move puts "Moving #{@arg1} to #{@arg2}" if @echo FileUtils.mv(@arg1, @arg2) elsif @type == :copy puts "Copying #{@arg1} to #{@arg2}" if @echo FileUtils.cp_r(@arg1, @arg2) elsif @type == :remove puts "Removing #{@arg1}" if @echo FileUtils.rm_rf(@arg1) elsif @type == :makedir puts "Making #{@arg1}" if @echo FileUtils.mkdir_p(@arg1) end end return true end |
#startupStep ⇒ Object
42 43 44 |
# File 'lib/blocks/fileutil.rb', line 42 def startupStep return run() end |