Sha256: cb674a48e1c17a55d6541a4c8b11422ac1834e1d81daa1d12f58a2c91c201534

Contents?: true

Size: 1.28 KB

Versions: 43

Compression:

Stored size: 1.28 KB

Contents

require 'fileutils'

module Bake
  module Blocks

    class FileUtil

      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

      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

      def execute
        return run()
      end

      def startupStep
        return run()
      end

      def exitStep
        return run()
      end

      def cleanStep
        return run()
      end

      def clean
        # nothing to do here
        return true
      end

    end

  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
bake-toolkit-2.68.1 lib/blocks/fileutil.rb
bake-toolkit-2.68.0 lib/blocks/fileutil.rb
bake-toolkit-2.67.0 lib/blocks/fileutil.rb
bake-toolkit-2.66.0 lib/blocks/fileutil.rb
bake-toolkit-2.65.2 lib/blocks/fileutil.rb
bake-toolkit-2.65.1 lib/blocks/fileutil.rb
bake-toolkit-2.65.0 lib/blocks/fileutil.rb
bake-toolkit-2.64.4 lib/blocks/fileutil.rb
bake-toolkit-2.64.3 lib/blocks/fileutil.rb
bake-toolkit-2.64.2 lib/blocks/fileutil.rb
bake-toolkit-2.64.1 lib/blocks/fileutil.rb
bake-toolkit-2.64.0 lib/blocks/fileutil.rb
bake-toolkit-2.63.2 lib/blocks/fileutil.rb
bake-toolkit-2.63.1 lib/blocks/fileutil.rb
bake-toolkit-2.63.0 lib/blocks/fileutil.rb
bake-toolkit-2.62.0 lib/blocks/fileutil.rb
bake-toolkit-2.61.0 lib/blocks/fileutil.rb
bake-toolkit-2.60.2 lib/blocks/fileutil.rb
bake-toolkit-2.60.0 lib/blocks/fileutil.rb
bake-toolkit-2.59.0 lib/blocks/fileutil.rb