Sha256: 45b93083d2f0b135cdfc514c90ac6f1e107dade28f9051abb414061a94d89e22

Contents?: true

Size: 944 Bytes

Versions: 3

Compression:

Stored size: 944 Bytes

Contents

def commands
  functions.map do |function|
    category = categories.find { |c| c.name == function.category }

    
    log.error("Category '#{function.category}' not found") unless category
  
    OpenStruct.new(
      category: function.category,
      name: function.name,
      category_description: category.description,
      function_description: function.description,
      ruby: function.ruby,
      usecases: use_cases
        .select { |uc| uc.category == function.category && uc.function == function.name }
        .map { |uc| 
          OpenStruct.new({
            category:         uc.category,
            function:         uc.function,
            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

3 entries across 3 versions & 1 rubygems

Version Path
cmdlet-0.0.6 .builders/documents/commands.rb
cmdlet-0.0.5 .builders/documents/commands.rb
cmdlet-0.0.4 .builders/documents/commands.rb