Sha256: e979f8ff0d6b225f984845ed83ef1b76cb6ca639f0f815f122c1e1f9657169b1

Contents?: true

Size: 437 Bytes

Versions: 15

Compression:

Stored size: 437 Bytes

Contents

module RestCore; end
module RestCore::ParseLink
  module_function
  # http://tools.ietf.org/html/rfc5988
  parname = '"?([^"]+)"?'
  LINKPARAM = /#{parname}=#{parname}/
  def parse_link link
    link.split(',').inject({}) do |r, value|
      uri, *pairs = value.split(';')
      params = Hash[pairs.map{ |p| p.strip.match(LINKPARAM)[1..2] }]
      r[params['rel']] = params.merge('uri' => uri[/<([^>]+)>/, 1])
      r
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
rest-core-3.6.0 lib/rest-core/util/parse_link.rb
rest-core-3.5.92 lib/rest-core/util/parse_link.rb
rest-core-3.5.91 lib/rest-core/util/parse_link.rb
rest-core-3.5.9 lib/rest-core/util/parse_link.rb
rest-core-3.5.8 lib/rest-core/util/parse_link.rb
rest-core-3.5.7 lib/rest-core/util/parse_link.rb
rest-core-3.5.6 lib/rest-core/util/parse_link.rb
rest-core-3.5.5 lib/rest-core/util/parse_link.rb
rest-core-3.5.4 lib/rest-core/util/parse_link.rb
rest-core-3.5.3 lib/rest-core/util/parse_link.rb
rest-core-3.5.2 lib/rest-core/util/parse_link.rb
rest-core-3.5.1 lib/rest-core/util/parse_link.rb
rest-core-3.5.0 lib/rest-core/util/parse_link.rb
rest-core-3.3.0 lib/rest-core/util/parse_link.rb
rest-core-3.2.0 lib/rest-core/util/parse_link.rb