Sha256: f33e1bd007fac95786c7504dedec83fa0aa2b0a30e44ef98666b39dcc4030813

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

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

            def initialize
              @prefix = Rake::Win32.windows? ? '/' : '-'
              @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/nunit.rb
rake-funnel-0.23.0 lib/rake/funnel/support/argument_mapper/styles/nunit.rb
rake-funnel-0.22.3 lib/rake/funnel/support/argument_mapper/styles/nunit.rb