Sha256: 99a2f417a393f0583139b8713d035ea9f22c2196bbc5d83db41a73128c277c60

Contents?: true

Size: 1.07 KB

Versions: 40

Compression:

Stored size: 1.07 KB

Contents

module CC
  module Analyzer
    class PathPatterns
      def initialize(patterns, root = Dir.pwd)
        @patterns = patterns
        @root = root
      end

      def expanded
        @expanded ||= expand
      end

      private

      def expand
        results = Dir.chdir(@root) do
          @patterns.flat_map do |pattern|
            # FIXME: there exists a temporary workaround whereby **-style globs
            # are translated to **/*-style globs within cc-yaml's custom
            # Glob#value method. It was thought that that would work correctly
            # with Dir.glob but it turns out we have to actually invoke #value
            # directory for this to work. We need to guard this on class (not
            # respond_to?) because our mocking framework adds a #value method to
            # all objects, apparently.
            if pattern.is_a?(CC::Yaml::Nodes::Glob)
              value = pattern.value
            else
              value = pattern
            end

            Dir.glob(value)
          end
        end

        results.sort.uniq
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
codeclimate-0.6.3 lib/cc/analyzer/path_patterns.rb
codeclimate-0.6.2 lib/cc/analyzer/path_patterns.rb
codeclimate-0.6.1 lib/cc/analyzer/path_patterns.rb
codeclimate-0.6.0 lib/cc/analyzer/path_patterns.rb
codeclimate-0.5.0 lib/cc/analyzer/path_patterns.rb
codeclimate-0.4.4 lib/cc/analyzer/path_patterns.rb
codeclimate-0.4.3 lib/cc/analyzer/path_patterns.rb
codeclimate-0.4.1 lib/cc/analyzer/path_patterns.rb
codeclimate-0.4.0 lib/cc/analyzer/path_patterns.rb
codeclimate-0.3.2 lib/cc/analyzer/path_patterns.rb
codeclimate-0.3.1 lib/cc/analyzer/path_patterns.rb
codeclimate-0.3.0 lib/cc/analyzer/path_patterns.rb
codeclimate-0.2.12 lib/cc/analyzer/path_patterns.rb
codeclimate-0.2.11 lib/cc/analyzer/path_patterns.rb
codeclimate-0.2.9 lib/cc/analyzer/path_patterns.rb
codeclimate-0.2.7 lib/cc/analyzer/path_patterns.rb
codeclimate-0.2.6 lib/cc/analyzer/path_patterns.rb
codeclimate-0.2.4 lib/cc/analyzer/path_patterns.rb
codeclimate-0.2.2 lib/cc/analyzer/path_patterns.rb
codeclimate-0.2.1 lib/cc/analyzer/path_patterns.rb