Class: CodeKeeper::Parser
- Inherits:
-
Object
- Object
- CodeKeeper::Parser
- Defined in:
- lib/code_keeper/parser.rb
Overview
Search and parse ruby file
Instance Attribute Summary collapse
-
#processed_source ⇒ Object
readonly
Returns the value of attribute processed_source.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(file_path) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(file_path) ⇒ Parser
Returns a new instance of Parser.
8 9 10 11 12 13 |
# File 'lib/code_keeper/parser.rb', line 8 def initialize(file_path) source = File.read(File.(file_path)) @processed_source = ::RuboCop::AST::ProcessedSource.new(source, RUBY_VERSION.to_f) rescue Errno::ENOENT raise TargetFileNotFoundError, "The target file does not exist. Check the file path: #{file_path}." end |
Instance Attribute Details
#processed_source ⇒ Object (readonly)
Returns the value of attribute processed_source.
6 7 8 |
# File 'lib/code_keeper/parser.rb', line 6 def processed_source @processed_source end |
Class Method Details
.parse(file_path) ⇒ Object
16 17 18 19 |
# File 'lib/code_keeper/parser.rb', line 16 def parse(file_path) parser = new(file_path) parser.processed_source end |