Sha256: e7730d8d31be5fa2724f341a93daeb029b10f0930a665213fff005201e81f31a

Contents?: true

Size: 831 Bytes

Versions: 2

Compression:

Stored size: 831 Bytes

Contents

require 'ftools'
require "delegate"

class Dressmaker
  class Configuration
    class FileRule < Rule

      class All < FileRule
        
        def initialize(&action)
          @action = action
        end
        
        def matches?(base, target)
          File.file?(File.join(base, target))
        end
      end

      attr_reader :directory, :action
      attr_accessor :description, :name
      
      class Pattern
        def initialize(pattern, &action)
          @pattern = pattern
          @action = action
        end

        def matches?(base, target)
          File.file?(File.join(base, target)) and File.fnmatch(pattern, File.join(base, target))
        end

      end

      def execute!(target)
        Delegators.with(target) do |file|
          action.call(file)
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dressmaker-0.0.3 lib/dressmaker/configuration/file_rule.rb
dressmaker-0.0.2 lib/dressmaker/configuration/file_rule.rb