Class: AlpacaBuildTool::Solution
- Inherits:
-
Object
- Object
- AlpacaBuildTool::Solution
- Includes:
- Log
- Defined in:
- lib/alpacabuildtool/entities/solution.rb
Overview
Solution provides solution representation and it’s configuration storage
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#projects ⇒ Object
readonly
Returns array of it’s projects (initialized only once).
Attributes included from Log
Instance Method Summary collapse
-
#build_version ⇒ Object
Returns current build version.
-
#configuration ⇒ Object
Returns Configuration object for current solution (initialized only once).
-
#initialize(file) ⇒ Solution
constructor
Creates instance from *.sln file Initializes solution’s semantic version and absolute path to it’s file.
-
#no_build? ⇒ Boolean
Returns true if solution is marked as nobuild.
-
#package_version ⇒ Object
Returns current package version.
-
#project(name) ⇒ Object
Returns specific project by it’s name.
-
#specific_projects(type) ⇒ Object
Returns array of projects that correspondes to specific type.
-
#to_s ⇒ Object
Overrides string representation.
-
#update_projects_version(version) ⇒ Object
Updates all projects AssemblyInfo.cs files with specific version.
Constructor Details
#initialize(file) ⇒ Solution
Creates instance from *.sln file Initializes solution’s semantic version and absolute path to it’s file
file
-
absolute or relative path to *.sln file
19 20 21 22 23 |
# File 'lib/alpacabuildtool/entities/solution.rb', line 19 def initialize(file) @file = File.(file) @dir = File.dirname(@file) @semver = Versioning.find(@dir) end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
12 13 14 |
# File 'lib/alpacabuildtool/entities/solution.rb', line 12 def dir @dir end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
12 13 14 |
# File 'lib/alpacabuildtool/entities/solution.rb', line 12 def file @file end |
#projects ⇒ Object (readonly)
Returns array of it’s projects (initialized only once)
44 45 46 |
# File 'lib/alpacabuildtool/entities/solution.rb', line 44 def projects @projects end |
Instance Method Details
#build_version ⇒ Object
Returns current build version
94 95 96 |
# File 'lib/alpacabuildtool/entities/solution.rb', line 94 def build_version @semver.to_s '%M.%m.%p' end |
#configuration ⇒ Object
Returns Configuration object for current solution (initialized only once)
38 39 40 |
# File 'lib/alpacabuildtool/entities/solution.rb', line 38 def configuration @configuration ||= Configuration.new(self) end |
#no_build? ⇒ Boolean
Returns true if solution is marked as nobuild
84 85 86 87 88 89 90 |
# File 'lib/alpacabuildtool/entities/solution.rb', line 84 def no_build? solution_name = File.basename(@file, '.*') (configuration['no_build'] || []).each do |tag| return true if solution_name.include?(tag) end false end |
#package_version ⇒ Object
Returns current package version
100 101 102 |
# File 'lib/alpacabuildtool/entities/solution.rb', line 100 def package_version @semver.to_s '%M.%m.%p%s' end |
#project(name) ⇒ Object
Returns specific project by it’s name
name
-
project’s name
56 57 58 |
# File 'lib/alpacabuildtool/entities/solution.rb', line 56 def project(name) @projects.find { |p| p.name == name } end |
#specific_projects(type) ⇒ Object
Returns array of projects that correspondes to specific type
type
-
type of project defined in configuration project_types
74 75 76 77 78 79 80 |
# File 'lib/alpacabuildtool/entities/solution.rb', line 74 def specific_projects(type) types = configuration['project_types'].dup types.select! { |t| t['type'] == type } unless type == 'all' projects.select do |project| types.any? { |t| project.name.include? t['name'] } end end |
#to_s ⇒ Object
Overrides string representation. Spawned to multiple lines
27 28 29 30 31 32 33 34 |
# File 'lib/alpacabuildtool/entities/solution.rb', line 27 def to_s s = '------------' s += "\nFile: #{@file}" s += "\nVersion: #{build_version}" s += "\nProjects:" unless projects.empty? projects.each { |p| s += "\n\t#{p}" } s + "\n------------" end |
#update_projects_version(version) ⇒ Object
Updates all projects AssemblyInfo.cs files with specific version
version
-
version to be stored in AssemblyInfo.cs files
64 65 66 67 68 |
# File 'lib/alpacabuildtool/entities/solution.rb', line 64 def update_projects_version(version) projects.each do |project| project.update_version version end end |