Sha256: 22caf5128612a6626aaf852eae3fd569517fcbcbbc258cc6a04e4e152b9fb2bd

Contents?: true

Size: 594 Bytes

Versions: 49

Compression:

Stored size: 594 Bytes

Contents

module Sawyer
  module LinkParsers

    class Simple

      LINK_REGEX = /_?url$/


      # Public: Parses simple *_url style links on resources
      #
      # data   - Hash of resource data
      #
      # Returns a Hash of data with separate links Hash
      def parse(data)

        links = {}
        inline_links = data.keys.select {|k| k.to_s[LINK_REGEX] }
        inline_links.each do |key|
          rel_name = key.to_s == 'url' ? 'self' : key.to_s.gsub(LINK_REGEX, '')
          links[rel_name.to_sym] = data[key]
        end

        return data, links
      end

    end

  end
end

Version data entries

49 entries across 35 versions & 2 rubygems

Version Path
tdiary-5.1.3 vendor/bundle/ruby/2.6.0/gems/sawyer-0.8.2/lib/sawyer/link_parsers/simple.rb
tdiary-5.1.3 vendor/bundle/ruby/2.7.0/gems/sawyer-0.8.2/lib/sawyer/link_parsers/simple.rb
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/sawyer-0.8.2/lib/sawyer/link_parsers/simple.rb
tdiary-5.1.2 vendor/bundle/ruby/2.7.0/gems/sawyer-0.8.2/lib/sawyer/link_parsers/simple.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/sawyer-0.8.2/lib/sawyer/link_parsers/simple.rb
tdiary-5.1.1 vendor/bundle/ruby/2.7.0/gems/sawyer-0.8.2/lib/sawyer/link_parsers/simple.rb
tdiary-5.1.0 vendor/bundle/gems/sawyer-0.8.2/lib/sawyer/link_parsers/simple.rb
sawyer-0.8.2 lib/sawyer/link_parsers/simple.rb
tdiary-5.0.13 vendor/bundle/gems/sawyer-0.8.1/lib/sawyer/link_parsers/simple.rb
tdiary-5.0.12.1 vendor/bundle/gems/sawyer-0.8.1/lib/sawyer/link_parsers/simple.rb
tdiary-5.0.11 vendor/bundle/gems/sawyer-0.8.1/lib/sawyer/link_parsers/simple.rb
tdiary-5.0.9 vendor/bundle/gems/sawyer-0.8.1/lib/sawyer/link_parsers/simple.rb
tdiary-5.0.8 vendor/bundle/ruby/2.5.0/gems/sawyer-0.8.1/lib/sawyer/link_parsers/simple.rb
tdiary-5.0.8 vendor/bundle/gems/tdiary-5.0.7/vendor/bundle/gems/sawyer-0.8.1/lib/sawyer/link_parsers/simple.rb
tdiary-5.0.8 vendor/bundle/gems/sawyer-0.8.1/lib/sawyer/link_parsers/simple.rb
tdiary-5.0.7 vendor/bundle/gems/sawyer-0.8.1/lib/sawyer/link_parsers/simple.rb
tdiary-5.0.6 vendor/bundle/gems/sawyer-0.8.1/lib/sawyer/link_parsers/simple.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/sawyer-0.8.1/lib/sawyer/link_parsers/simple.rb
tdiary-5.0.5 vendor/bundle/gems/sawyer-0.8.1/lib/sawyer/link_parsers/simple.rb
tdiary-5.0.4 vendor/bundle/gems/sawyer-0.8.1/lib/sawyer/link_parsers/simple.rb