Sha256: e6dc6e8996d50283556aad61bf82580af036490550767cc540a8f6edb404be5e

Contents?: true

Size: 943 Bytes

Versions: 64

Compression:

Stored size: 943 Bytes

Contents

# encoding: utf-8

module Github
  module Validations
    module Token

      TOKEN_REQUIRED = [
        'get /user',
        'get /user/emails',
        'get /user/followers',
        'get /user/following',
        'get /user/keys',
        'get /user/repos',
        'patch /user',
        'post /user/emails',
        'post /user/keys',
        'post /user/repos'
      ]

      TOKEN_REQUIRED_REGEXP = [
        /repos\/.*\/.*\/comments/,
      ]

      # Ensures that required authentication token is present before
      # request is sent.
      #
      def validates_token_for(method, path)
        return true unless TOKEN_REQUIRED.grep("#{method} #{path}").empty?

        token_required = false
        TOKEN_REQUIRED_REGEXP.each do |regex|
          if "#{method} #{path}" =~ regex
            token_required = true
          end
        end
        return token_required
      end

    end # Token
  end # Validations
end # Github

Version data entries

64 entries across 64 versions & 3 rubygems

Version Path
github_api2-1.0.1 lib/github_api2/validations/token.rb
github_api2-1.0.0 lib/github_api2/validations/token.rb
github_api-0.19.0 lib/github_api/validations/token.rb
lingfennan-github_api-0.18.2 lib/github_api/validations/token.rb
github_api-0.18.2 lib/github_api/validations/token.rb
github_api-0.18.1 lib/github_api/validations/token.rb
github_api-0.17.0 lib/github_api/validations/token.rb
github_api-0.16.0 lib/github_api/validations/token.rb
github_api-0.15.0 lib/github_api/validations/token.rb
github_api-0.14.5 lib/github_api/validations/token.rb
github_api-0.14.4 lib/github_api/validations/token.rb
github_api-0.14.3 lib/github_api/validations/token.rb
github_api-0.14.2 lib/github_api/validations/token.rb
github_api-0.14.1 lib/github_api/validations/token.rb
github_api-0.14.0 lib/github_api/validations/token.rb
github_api-0.13.1 lib/github_api/validations/token.rb
github_api-0.13.0 lib/github_api/validations/token.rb
github_api-0.12.4 lib/github_api/validations/token.rb
github_api-0.12.3 lib/github_api/validations/token.rb
github_api-0.12.2 lib/github_api/validations/token.rb