Class: CC::Analyzer::Filesystem
- Inherits:
-
Object
- Object
- CC::Analyzer::Filesystem
- Defined in:
- lib/cc/analyzer/filesystem.rb
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #exist?(path) ⇒ Boolean
-
#initialize(root) ⇒ Filesystem
constructor
A new instance of Filesystem.
- #ls ⇒ Object
- #read_path(path) ⇒ Object
- #source_buffer_for(path) ⇒ Object
- #write_path(path, content) ⇒ Object
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
#root ⇒ Object (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
10 11 12 |
# File 'lib/cc/analyzer/filesystem.rb', line 10 def exist?(path) File.exist?(path_for(path)) end |
#ls ⇒ Object
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 |