Class: IronSpect::Parsers::SolutionFileParser

Inherits:
Object
  • Object
show all
Defined in:
lib/iron-spect/parsers/solution_file_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_fileObject (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

#parseObject



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