Sha256: ffca691068dbf779ea32605f615641789220559f705478ec67399e0e4a8f5cdb

Contents?: true

Size: 566 Bytes

Versions: 155

Compression:

Stored size: 566 Bytes

Contents

module CC
  class Workspace
    class Exclusion
      def initialize(pattern)
        @negated = pattern.starts_with?("!")
        @pattern = simplify(pattern)
      end

      def expand
        if glob?
          Dir.glob(pattern)
        else
          [pattern]
        end
      end

      def glob?
        pattern.include?("*")
      end

      def negated?
        negated
      end

      private

      attr_reader :negated, :pattern

      def simplify(pattern)
        pattern.to_s.sub(%r{(/\*\*)?(/\*)?$}, "").sub(/^\!/, "")
      end
    end
  end
end

Version data entries

155 entries across 155 versions & 2 rubygems

Version Path
codeclimate-0.85.27 lib/cc/workspace/exclusion.rb
codeclimate-0.85.26 lib/cc/workspace/exclusion.rb
codeclimate-0.85.25 lib/cc/workspace/exclusion.rb
codeclimate-0.85.24 lib/cc/workspace/exclusion.rb
codeclimate-fede-0.85.54 lib/cc/workspace/exclusion.rb
codeclimate-fede-0.85.53 lib/cc/workspace/exclusion.rb
codeclimate-fede-0.85.52 lib/cc/workspace/exclusion.rb
codeclimate-fede-0.85.51 lib/cc/workspace/exclusion.rb
codeclimate-fede-0.85.50 lib/cc/workspace/exclusion.rb
codeclimate-fede-0.85.49 lib/cc/workspace/exclusion.rb
codeclimate-fede-0.85.48 lib/cc/workspace/exclusion.rb
codeclimate-fede-0.85.47 lib/cc/workspace/exclusion.rb
codeclimate-fede-0.85.46 lib/cc/workspace/exclusion.rb
codeclimate-fede-0.85.45 lib/cc/workspace/exclusion.rb
codeclimate-fede-0.85.44 lib/cc/workspace/exclusion.rb
codeclimate-fede-0.85.43 lib/cc/workspace/exclusion.rb
codeclimate-fede-0.85.42 lib/cc/workspace/exclusion.rb
codeclimate-fede-0.85.41 lib/cc/workspace/exclusion.rb
codeclimate-fede-0.85.40 lib/cc/workspace/exclusion.rb
codeclimate-fede-0.85.39 lib/cc/workspace/exclusion.rb