Sha256: 1dce01e7e78e080f40ed3eaab07d25560d962cedc0ee9ce7f82c724b81f94feb

Contents?: true

Size: 1.22 KB

Versions: 15

Compression:

Stored size: 1.22 KB

Contents

require 'albacore/logging'
require 'albacore/project'

module Albacore
  # a solution encapsulates the properties from a sln file.
  class Solution
    include Logging

    attr_reader :path_base, :filename, :content

    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

    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

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

    end

    # get the path of the solution file
    def path
      File.join @path_base, @filename
    end

    # Gets the path of the solution file
    def to_s
      path
    end

    private

    def project_matches
      project_regexp = /^\s*Project\(.+\) = "(?<name>.+?)", "(?<location>.+?)", "(?<guid>.+?)"/
      @content.map { |line| project_regexp.match(line) }.reject(&:nil?)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
albacore-3.0.1 ./lib/albacore/solution.rb
albacore-3.0.0.pre.alpha.6 ./lib/albacore/solution.rb
albacore-3.0.0.pre.alpha.5 ./lib/albacore/solution.rb
albacore-3.0.0.pre.alpha.4 ./lib/albacore/solution.rb
albacore-3.0.0.pre.alpha.3 ./lib/albacore/solution.rb
albacore-3.0.0.pre.alpha.2 ./lib/albacore/solution.rb
albacore-3.0.0.pre.alpha ./lib/albacore/solution.rb
albacore-2.8.0 ./lib/albacore/solution.rb
albacore-2.7.0 ./lib/albacore/solution.rb
albacore-2.6.8 ./lib/albacore/solution.rb
albacore-2.6.7 ./lib/albacore/solution.rb
albacore-2.6.6 ./lib/albacore/solution.rb
albacore-2.6.4 ./lib/albacore/solution.rb
albacore-2.6.3 ./lib/albacore/solution.rb
albacore-2.6.2 ./lib/albacore/solution.rb