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
sawyer-0.8.1 lib/sawyer/link_parsers/simple.rb
sawyer-0.8.0 lib/sawyer/link_parsers/simple.rb
tdiary-5.0.2 vendor/bundle/gems/sawyer-0.7.0/lib/sawyer/link_parsers/simple.rb
tdiary-5.0.1 vendor/bundle/gems/sawyer-0.7.0/lib/sawyer/link_parsers/simple.rb
sawyer-0.7.0 lib/sawyer/link_parsers/simple.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/sawyer-0.6.0/lib/sawyer/link_parsers/simple.rb
sawyer-0.6.0 lib/sawyer/link_parsers/simple.rb
sawyer-0.5.5 lib/sawyer/link_parsers/simple.rb
sawyer-0.5.4 lib/sawyer/link_parsers/simple.rb