Class: Logirel::VS::Solution

Inherits:
Object
  • Object
show all
Defined in:
lib/logirel/vs/solution.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(slfile) ⇒ Solution

Returns a new instance of Solution.



71
72
73
74
75
76
77
78
79
80
# File 'lib/logirel/vs/solution.rb', line 71

def initialize(slfile)
  @file = File.expand_path("#{slfile}")
  throw "Solution #{@file} must exist." unless File.exist?(@file)

  @name = File.basename(@file, ".sln")
  @path = File.dirname(@file)
  @projects = []

  populate_projects File.read(@file)
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



66
67
68
# File 'lib/logirel/vs/solution.rb', line 66

def file
  @file
end

#nameObject (readonly)

Returns the value of attribute name.



67
68
69
# File 'lib/logirel/vs/solution.rb', line 67

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



68
69
70
# File 'lib/logirel/vs/solution.rb', line 68

def path
  @path
end

#projectsObject (readonly)

Returns the value of attribute projects.



69
70
71
# File 'lib/logirel/vs/solution.rb', line 69

def projects
  @projects
end

Instance Method Details

#find_project(defaults = nil) ⇒ Object



82
83
84
# File 'lib/logirel/vs/solution.rb', line 82

def find_project(defaults=nil)
  projects.find{|p| yield p} || OpenStruct.new(defaults) 
end

#has_test_projects?Boolean

Returns:

  • (Boolean)


86
87
88
# File 'lib/logirel/vs/solution.rb', line 86

def has_test_projects?
  test_projects.count > 0
end

#has_web_projects?Boolean

Returns:

  • (Boolean)


94
95
96
# File 'lib/logirel/vs/solution.rb', line 94

def has_web_projects?
  web_projects.count > 0
end

#test_projectsObject



90
91
92
# File 'lib/logirel/vs/solution.rb', line 90

def test_projects
  projects.select { |p| p.test? || p.name =~ /(Test|Tests)$/ }
end

#web_projectsObject



98
99
100
# File 'lib/logirel/vs/solution.rb', line 98

def web_projects
  projects.select {|p| p.web? }
end