<commit_before>module Evercam
  class APIv1

    get '/vendors' do
      vendors = Vendor.all

      data = vendors.map do |v|
        {
          id: v.exid,
          name: v.name,
          known_macs: v.known_macs
        }
      end

      { vendors: data }
    end

    get '/vendors/:mac', requirements: { mac: /([0-9A-F]{2}[:-]){2,5}([0-9A-F]{2})/i } do
      vendors = ::Vendor.by_mac(params[:mac][0,8])
      raise NotFoundError, 'mac address was not found' if vendors.empty?

      {
        vendors: vendors.map do |vn|
          {
            id: vn.exid,
            name: vn.name,
            known_macs: vn.known_macs,
            firmwares: vn.firmwares.map do |fm|
              fm.config.merge(name: fm.name)
            end
          }
        end
      }
    end

    get '/vendors/:exid' do
      vendor = ::Vendor.by_exid(params[:exid])
      raise NotFoundError, 'vendor was not found' unless vendor

      {
        vendors: [{
          id: vendor.exid,
          name: vendor.name,
          known_macs: vendor.known_macs,
          firmwares: vendor.firmwares.map do |fm|
            fm.config.merge(name: fm.name)
          end
        }]
      }
    end

  end
end<commit_msg>minor cosmetic rendering update to GET /v1/vendors/{id|mac} response<commit_after>module Evercam
  class APIv1

    get '/vendors' do
      vendors = Vendor.all

      data = vendors.map do |v|
        {
          id: v.exid,
          name: v.name,
          known_macs: v.known_macs
        }
      end

      { vendors: data }
    end

    get '/vendors/:mac', requirements: { mac: /([0-9A-F]{2}[:-]){2,5}([0-9A-F]{2})/i } do
      vendors = ::Vendor.by_mac(params[:mac][0,8])
      raise NotFoundError, 'mac address was not found' if vendors.empty?

      {
        vendors: vendors.map do |vn|
          {
            id: vn.exid,
            name: vn.name,
            known_macs: vn.known_macs,
            firmwares: vn.firmwares.map do |fm|
              { name: fm.name }.merge(fm.config)
            end
          }
        end
      }
    end

    get '/vendors/:exid' do
      vendor = ::Vendor.by_exid(params[:exid])
      raise NotFoundError, 'vendor was not found' unless vendor

      {
        vendors: [{
          id: vendor.exid,
          name: vendor.name,
          known_macs: vendor.known_macs,
          firmwares: vendor.firmwares.map do |fm|
            { name: fm.name }.merge(fm.config)
          end
        }]
      }
    end

  end
end
{'fraction_non_alphanumeric': 0.12444444444444444, 'fraction_numerical': 0.009292929292929294, 'mean_word_length': 1.5137055837563451, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3074027', 'n_tokens_mistral': 875, 'n_tokens_neox': 862, 'n_words': 186}