Sha256: ace546c4fa242a916dabfb2b27bb478ad7de690e68b25ba5b75458a312a4e102

Contents?: true

Size: 882 Bytes

Versions: 199

Compression:

Stored size: 882 Bytes

Contents

module CC
  module Analyzer
    class Filesystem
      attr_reader :root

      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 write_path(path, content)
        File.write(path_for(path), content)
        File.chown(root_uid, root_gid, path_for(path))
      end

      def ls
        Dir.entries(root).reject { |entry| [".", ".."].include?(entry) }
      end

      private

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

      def root_uid
        root_stat.uid
      end

      def root_gid
        root_stat.gid
      end

      def root_stat
        @root_stat ||= File.stat(root)
      end
    end
  end
end

Version data entries

199 entries across 199 versions & 2 rubygems

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