Sha256: d7bed547c3770abaefb4a2b1b7675fbd94f537498b8b7a129c3344cdddf97812

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

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

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

            def generate_from(model)
              model.flat_map do |switch|
                switch.values.flatten.map do |value|
                  top_level(switch) + nested(value)
                end
              end
            end

            private

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

            def nested(value) # rubocop:disable Metrics/AbcSize
              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
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rake-funnel-0.24.0 lib/rake/funnel/support/argument_mapper/styles/msbuild.rb
rake-funnel-0.23.0 lib/rake/funnel/support/argument_mapper/styles/msbuild.rb
rake-funnel-0.22.3 lib/rake/funnel/support/argument_mapper/styles/msbuild.rb