Class: CC::Analyzer::Filesystem

Inherits:
Object
  • Object
show all
Defined in:
lib/cc/analyzer/filesystem.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root) ⇒ Filesystem

Returns a new instance of Filesystem.



6
7
8
# File 'lib/cc/analyzer/filesystem.rb', line 6

def initialize(root)
  @root = root
end

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



4
5
6
# File 'lib/cc/analyzer/filesystem.rb', line 4

def root
  @root
end

Instance Method Details

#exist?(path) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/cc/analyzer/filesystem.rb', line 10

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

#lsObject



27
28
29
# File 'lib/cc/analyzer/filesystem.rb', line 27

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

#read_path(path) ⇒ Object



18
19
20
# File 'lib/cc/analyzer/filesystem.rb', line 18

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

#source_buffer_for(path) ⇒ Object



14
15
16
# File 'lib/cc/analyzer/filesystem.rb', line 14

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

#write_path(path, content) ⇒ Object



22
23
24
25
# File 'lib/cc/analyzer/filesystem.rb', line 22

def write_path(path, content)
  File.write(path_for(path), content)
  File.chown(root_uid, root_gid, path_for(path))
end