Class: Albacore::Solution

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/albacore/solution.rb

Overview

a solution encapsulates the properties from a sln file.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

#debug, #err, #error, #fatal, #info, #puts, #trace, #warn

Constructor Details

#initialize(path) ⇒ Solution

Returns a new instance of Solution.

Raises:

  • (ArgumentError)


11
12
13
14
15
16
# File 'lib/albacore/solution.rb', line 11

def initialize path
  raise ArgumentError, 'solution path does not exist' unless File.exists? path.to_s
  path = path.to_s unless path.is_a? String
  @content = open(path)
  @path_base, @filename = File.split path
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



9
10
11
# File 'lib/albacore/solution.rb', line 9

def content
  @content
end

#filenameObject (readonly)

Returns the value of attribute filename.



9
10
11
# File 'lib/albacore/solution.rb', line 9

def filename
  @filename
end

#path_baseObject (readonly)

Returns the value of attribute path_base.



9
10
11
# File 'lib/albacore/solution.rb', line 9

def path_base
  @path_base
end

Instance Method Details

#pathObject

get the path of the solution file



31
32
33
# File 'lib/albacore/solution.rb', line 31

def path
  File.join @path_base, @filename
end

#project_pathsObject



24
25
26
27
28
# File 'lib/albacore/solution.rb', line 24

def project_paths
  project_matches.map { |matches| matches[:location] }
                 .select { |path| File.extname(path).end_with? 'proj' }

end

#projectsObject



18
19
20
21
22
# File 'lib/albacore/solution.rb', line 18

def projects
  project_paths.map { |path| File.join(@path_base, path) }
               .select { |path| File.file?(path) }
               .map {|path| Albacore::Project.new(File.absolute_path(path)) }
end

#to_sObject

Gets the path of the solution file



36
37
38
# File 'lib/albacore/solution.rb', line 36

def to_s
  path
end