Class: IronSpect::Parsers::SolutionFileParser
- Inherits:
-
Object
- Object
- IronSpect::Parsers::SolutionFileParser
- Defined in:
- lib/iron-spect/parsers/solution_file_parser.rb
Instance Attribute Summary collapse
-
#solution_file ⇒ Object
readonly
Returns the value of attribute solution_file.
Instance Method Summary collapse
-
#initialize(solution_file_path) ⇒ SolutionFileParser
constructor
A new instance of SolutionFileParser.
- #parse ⇒ Object
Constructor Details
#initialize(solution_file_path) ⇒ SolutionFileParser
Returns a new instance of SolutionFileParser.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/iron-spect/parsers/solution_file_parser.rb', line 6 def initialize(solution_file_path) @solution = {} if File.directory?(solution_file_path) sln_file = Dir["#{solution_file_path}/*.sln"] raise "Solution file not present in directory #{solution_file_path}" if sln_file.empty? puts "Multiple solution files found in directory #{solution_file_path}. Accepting the first." if sln_file.count > 1 @solution_file = File.open(sln_file[0], 'r+') elsif File.file?(solution_file_path) @solution_file = solution_file_path else raise "Didn't understand being called with #{solution_file_path}" end end |
Instance Attribute Details
#solution_file ⇒ Object (readonly)
Returns the value of attribute solution_file.
4 5 6 |
# File 'lib/iron-spect/parsers/solution_file_parser.rb', line 4 def solution_file @solution_file end |
Instance Method Details
#parse ⇒ Object
20 21 22 23 24 25 |
# File 'lib/iron-spect/parsers/solution_file_parser.rb', line 20 def parse @solution[:projects] = [] @solution[:global] = [] run_parse(@solution_file.read) @solution end |