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.2.4 vendor/bundle/ruby/3.1.0/gems/sawyer-0.9.2/lib/sawyer/link_parsers/simple.rb
tdiary-5.2.3 vendor/bundle/ruby/3.1.0/gems/sawyer-0.9.2/lib/sawyer/link_parsers/simple.rb
sawyer-0.9.2 lib/sawyer/link_parsers/simple.rb
tdiary-5.2.2 vendor/bundle/ruby/3.1.0/gems/sawyer-0.9.1/lib/sawyer/link_parsers/simple.rb
sawyer-0.9.1 lib/sawyer/link_parsers/simple.rb
tdiary-5.2.1 vendor/bundle/ruby/3.1.0/gems/sawyer-0.8.2/lib/sawyer/link_parsers/simple.rb
sawyer-0.9.0 lib/sawyer/link_parsers/simple.rb
tdiary-5.2.0 vendor/bundle/ruby/2.7.0/gems/sawyer-0.8.2/lib/sawyer/link_parsers/simple.rb
tdiary-5.2.0 vendor/bundle/ruby/3.0.0/gems/sawyer-0.8.2/lib/sawyer/link_parsers/simple.rb
tdiary-5.1.7 vendor/bundle/ruby/3.0.0/gems/sawyer-0.8.2/lib/sawyer/link_parsers/simple.rb
tdiary-5.1.7 vendor/bundle/ruby/2.7.0/gems/sawyer-0.8.2/lib/sawyer/link_parsers/simple.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/sawyer-0.8.2/lib/sawyer/link_parsers/simple.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/sawyer-0.8.2/lib/sawyer/link_parsers/simple.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/2.7.0/gems/sawyer-0.8.2/lib/sawyer/link_parsers/simple.rb
tdiary-5.1.6 vendor/bundle/ruby/3.0.0/gems/sawyer-0.8.2/lib/sawyer/link_parsers/simple.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/sawyer-0.8.2/lib/sawyer/link_parsers/simple.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/sawyer-0.8.2/lib/sawyer/link_parsers/simple.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/sawyer-0.8.2/lib/sawyer/link_parsers/simple.rb
tdiary-5.1.5 vendor/bundle/ruby/2.7.0/gems/sawyer-0.8.2/lib/sawyer/link_parsers/simple.rb
tdiary-5.1.4 vendor/bundle/ruby/2.7.0/gems/sawyer-0.8.2/lib/sawyer/link_parsers/simple.rb