Sha256: ad2dfcf8c1b5513ccef1b614714a0af9b48bce2730a72f445b67e8d4aac3c6ed

Contents?: true

Size: 660 Bytes

Versions: 20

Compression:

Stored size: 660 Bytes

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'
module EacEnvs
  module Http
    class Response < ::StandardError
      module Links
        # https://www.w3.org/wiki/LinkHeader
        LINKS_HEADER_NAME = 'Link'

        # https://www.w3.org/wiki/LinkHeader
        LINK_PARSER = /\A\<(.+)\>\s*;\s*rel\s*=\s*\"(.*)\"\z/.to_parser do |m|
          [m[2], m[1]]
        end

        def link(rel)
          hash_search(links, rel)
        end

        def links
          header(LINKS_HEADER_NAME).if_present({}) do |v|
            v.split(',').map { |w| LINK_PARSER.parse!(w.strip) }.to_h
          end
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
eac_tools-0.76.0 sub/eac_envs-http/lib/eac_envs/http/response/links.rb
eac_tools-0.75.2 sub/eac_envs-http/lib/eac_envs/http/response/links.rb
eac_envs-http-0.4.1 lib/eac_envs/http/response/links.rb
eac_tools-0.75.1 sub/eac_envs-http/lib/eac_envs/http/response/links.rb
eac_tools-0.75.0 sub/eac_envs-http/lib/eac_envs/http/response/links.rb
eac_tools-0.74.1 sub/eac_envs-http/lib/eac_envs/http/response/links.rb
eac_tools-0.74.0 sub/eac_envs-http/lib/eac_envs/http/response/links.rb
eac_tools-0.73.0 sub/eac_envs-http/lib/eac_envs/http/response/links.rb
eac_tools-0.72.0 sub/eac_envs-http/lib/eac_envs/http/response/links.rb
eac_envs-http-0.4.0 lib/eac_envs/http/response/links.rb
eac_tools-0.70.1 sub/eac_envs-http/lib/eac_envs/http/response/links.rb
eac_tools-0.70.0 sub/eac_envs-http/lib/eac_envs/http/response/links.rb
eac_tools-0.69.1 sub/eac_envs-http/lib/eac_envs/http/response/links.rb
eac_tools-0.69.0 sub/eac_envs-http/lib/eac_envs/http/response/links.rb
eac_tools-0.68.0 sub/eac_envs-http/lib/eac_envs/http/response/links.rb
eac_tools-0.67.1 sub/eac_envs-http/lib/eac_envs/http/response/links.rb
eac_tools-0.67.0 sub/eac_envs-http/lib/eac_envs/http/response/links.rb
eac_tools-0.66.0 sub/eac_envs-http/lib/eac_envs/http/response/links.rb
eac_envs-http-0.3.2 lib/eac_envs/http/response/links.rb
eac_tools-0.65.1 sub/eac_envs-http/lib/eac_envs/http/response/links.rb