Class: CsProj::Msbuild::SolutionParser

Inherits:
Object
  • Object
show all
Defined in:
lib/csproj/msbuild/solution_parser.rb

Class Method Summary collapse

Class Method Details

.get_project_file(project_line) ⇒ Object



31
32
33
# File 'lib/csproj/msbuild/solution_parser.rb', line 31

def self.get_project_file(project_line)
  project_line.split("\"")[5].tr('\\', "/")
end

.get_project_name(project_line) ⇒ Object



27
28
29
# File 'lib/csproj/msbuild/solution_parser.rb', line 27

def self.get_project_name(project_line)
  project_line.split("\"")[3]
end

.parse(filename) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/csproj/msbuild/solution_parser.rb', line 6

def self.parse(filename)
  solution = Solution.new

  File.open(filename) do |f|
    f.read.split("\n").each do |line|
      if line.start_with? "Project"
        options = parse_line line
        solution.add_project Project.new(options)
      end
    end
  end

  solution
end

.parse_line(line) ⇒ Object



21
22
23
24
25
# File 'lib/csproj/msbuild/solution_parser.rb', line 21

def self.parse_line(line)
  name = get_project_name line
  project_file = get_project_file line
  {project_name: name, project_path: project_file}
end