Sha256: 1be25d5ef867ddcd4b6ff4fd22a78175a59147da511200c3f8cf7dc53cbdcf04

Contents?: true

Size: 797 Bytes

Versions: 2

Compression:

Stored size: 797 Bytes

Contents

require 'ftools'
require "delegate"

class Dressmaker
  class Configuration
    class DirectoryRule < Rule

      class All < DirectoryRule

        def matches?(base, target)
          File.directory?(File.join(base, target))
        end

      end
      
      class Pattern < DirectoryRule
        
        attr_reader :pattern, :action
        
        def initialize(pattern, &action)
          @pattern = pattern
          @action = action
        end

        def matches?(base, target)
          File.directory?(File.join(base, target)) && File.fnmatch(pattern, target)
        end
        
      end

      attr_accessor :description, :name

      def execute!(target)
        Delegators.with(File.join(target)) do |dir|
          action.call(dir)
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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