Sha256: 17b477bd94ab86475af7176444d2799e0361c36d37e2ec3903c3da75f361a1a4

Contents?: true

Size: 928 Bytes

Versions: 1

Compression:

Stored size: 928 Bytes

Contents

def cmdlets
  commands.map do |command|
    category = categories.find { |c| c.name == command.category }
    
    log.error("Category '#{command.category}' not found") unless category
  
    OpenStruct.new(
      category: command.category,
      name: command.name,
      category_description: category.description,
      command_description: command.description,
      ruby: command.ruby,
      usecases: use_cases
        .select { |uc| uc.category == command.category && uc.command == command.name }
        .map { |uc| 
          OpenStruct.new({
            category:         uc.category,
            command:         uc.command,
            inputs:           uc.inputs,
            nice_inputs:      nice_inputs(uc.inputs),
            expected_output:  uc.expected_output 
          })
        }
    )
  end
end

def nice_inputs(values)
  values.map { |value| value.is_a?(String) ? "'#{value}'" : value }.join(', ')
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cmdlet-0.0.7 .builders/documents/cmdlets.rb