Sha256: 7e7d570bb9e730df133b52ca014e286cfb28b18ffa95ae4d6ec6a663a6d7dfe4

Contents?: true

Size: 763 Bytes

Versions: 6

Compression:

Stored size: 763 Bytes

Contents

module Rake::Funnel::Support::MapperStyles
  class MSBuild
    attr_reader :prefix, :separator, :value_separator

    def initialize
      @prefix = '/'
      @separator = ':'
      @value_separator = '='
    end

    def generate_from(model)
      model.map { |switch|
        switch.values.flatten.map { |value|
          top_level(switch) + nested(value)
        }
      }.flatten(1)
    end

    private
    def top_level(switch)
      [prefix, switch.switch]
    end

    def nested(value)
      res = []
      res << separator unless value.key.nil? && value.value.nil?
      res << value.key
      res << value_separator unless value.key.nil? || value.value.nil?
      res << value.value
      res.compact
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rake-funnel-0.0.6.pre lib/rake/funnel/support/mapper_styles/msbuild.rb
rake-funnel-0.0.5.pre lib/rake/funnel/support/mapper_styles/msbuild.rb
rake-funnel-0.0.4.pre lib/rake/funnel/support/mapper_styles/msbuild.rb
rake-funnel-0.0.3.pre lib/rake/funnel/support/mapper_styles/msbuild.rb
rake-funnel-0.0.2.pre lib/rake/funnel/support/mapper_styles/msbuild.rb
rake-funnel-0.0.1.pre lib/rake/funnel/support/mapper_styles/msbuild.rb