Sha256: 7abf9216f7c155c18a161334f327c62ff023f6c68261bdfc11cd25a834b722c8

Contents?: true

Size: 938 Bytes

Versions: 18

Compression:

Stored size: 938 Bytes

Contents

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

            def initialize
              @prefix = '/'
              @value_separator = ','
            end

            def generate_from(model)
              model.map { |switch|
                switch.values.flatten.map { |value|
                  [top_level(switch), nested(value)].reject(&:empty?)
                }
              }.flatten(2)
            end

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

            def nested(value)
              res = []
              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

18 entries across 18 versions & 1 rubygems

Version Path
rake-funnel-0.18.0 lib/rake/funnel/support/argument_mapper/styles/default.rb
rake-funnel-0.17.0 lib/rake/funnel/support/argument_mapper/styles/default.rb
rake-funnel-0.16.1 lib/rake/funnel/support/argument_mapper/styles/default.rb
rake-funnel-0.16.0 lib/rake/funnel/support/argument_mapper/styles/default.rb
rake-funnel-0.15.0.pre lib/rake/funnel/support/argument_mapper/styles/default.rb
rake-funnel-0.14.0.pre lib/rake/funnel/support/argument_mapper/styles/default.rb
rake-funnel-0.13.0.pre lib/rake/funnel/support/argument_mapper/styles/default.rb
rake-funnel-0.12.0.pre lib/rake/funnel/support/argument_mapper/styles/default.rb
rake-funnel-0.11.0.pre lib/rake/funnel/support/argument_mapper/styles/default.rb
rake-funnel-0.10.0.pre lib/rake/funnel/support/argument_mapper/styles/default.rb
rake-funnel-0.9.1.pre lib/rake/funnel/support/argument_mapper/styles/default.rb
rake-funnel-0.9.0.pre lib/rake/funnel/support/argument_mapper/styles/default.rb
rake-funnel-0.8.0.pre lib/rake/funnel/support/argument_mapper/styles/default.rb
rake-funnel-0.7.0.pre lib/rake/funnel/support/argument_mapper/styles/default.rb
rake-funnel-0.6.1.pre lib/rake/funnel/support/argument_mapper/styles/default.rb
rake-funnel-0.6.0.pre lib/rake/funnel/support/argument_mapper/styles/default.rb
rake-funnel-0.5.0.pre lib/rake/funnel/support/argument_mapper/styles/default.rb
rake-funnel-0.4.0.pre lib/rake/funnel/support/argument_mapper/styles/default.rb