Sha256: fb4d9a9d7c8856a92b4e70bedc8d7cbab65f386cb3903d2c987e2916c6293196

Contents?: true

Size: 876 Bytes

Versions: 4

Compression:

Stored size: 876 Bytes

Contents

module CC
  module Analyzer
    class Filesystem

      def initialize(root)
        @root = root
      end

      def exist?(path)
        File.exist?(path_for(path))
      end

      def source_buffer_for(path)
        SourceBuffer.new(path, read_path(path))
      end

      def read_path(path)
        File.read(path_for(path))
      end

      def file_paths
        Dir.chdir(@root) do
          Dir["**/*.*"].select { |path| File.file?(path) }.sort
        end
      end

      def all
        @files ||= Dir.chdir(@root) { Dir.glob("**/*") }
      end

      def any?(&block)
        all.any?(&block)
      end

      def files_matching(globs)
        Dir.chdir(@root) do
          globs.map do |glob|
            Dir.glob(glob)
          end.flatten.sort.uniq
        end
      end

      def path_for(path)
        File.join(@root, path)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
codeclimate-0.0.7 lib/cc/analyzer/filesystem.rb
codeclimate-0.0.6 lib/cc/analyzer/filesystem.rb
codeclimate-0.0.5 lib/cc/analyzer/filesystem.rb
codeclimate-0.0.1 lib/cc/analyzer/filesystem.rb