Sha256: aae1f91a44ced11b18372a8f6e166e7350ad04e006e51e7be39b396157bf0946

Contents?: true

Size: 1005 Bytes

Versions: 21

Compression:

Stored size: 1005 Bytes

Contents

# encoding: utf-8

# TODO: Set token required calls

module BitBucket
  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 # BitBucket

Version data entries

21 entries across 21 versions & 5 rubygems

Version Path
codenamev_bitbucket_api-0.4.1 lib/bitbucket_rest_api/validations/token.rb
codenamev_bitbucket_api-0.4.0 lib/bitbucket_rest_api/validations/token.rb
zz_bitbucket_rest_api-0.1.11 lib/bitbucket_rest_api/validations/token.rb
zz_bitbucket_rest_api-0.1.10 lib/bitbucket_rest_api/validations/token.rb
zz_bitbucket_rest_api-0.1.9 lib/bitbucket_rest_api/validations/token.rb
zz_bitbucket_rest_api-0.1.8 lib/bitbucket_rest_api/validations/token.rb
bitbucket_rest_api2-0.9.5 lib/bitbucket_rest_api/validations/token.rb
bitbucket_rest_api2-0.9.1 lib/bitbucket_rest_api/validations/token.rb
bitbucket_rest_api2-0.2.2 lib/bitbucket_rest_api/validations/token.rb
bitbucket_rest_api2-0.2.1 lib/bitbucket_rest_api/validations/token.rb
bitbucket_rest_api2-0.2.0 lib/bitbucket_rest_api/validations/token.rb
bitbucket_rest_api-0.1.7 lib/bitbucket_rest_api/validations/token.rb
reenhanced_bitbucket_api-0.3.2 lib/bitbucket_rest_api/validations/token.rb
reenhanced_bitbucket_api-0.3.1 lib/bitbucket_rest_api/validations/token.rb
reenhanced_bitbucket_api-0.3.0 lib/bitbucket_rest_api/validations/token.rb
reenhanced_bitbucket_api-0.1.6 lib/bitbucket_rest_api/validations/token.rb
bitbucket_rest_api-0.1.5 lib/bitbucket_rest_api/validations/token.rb
bitbucket_rest_api-0.1.4 lib/bitbucket_rest_api/validations/token.rb
bitbucket_rest_api-0.1.2 lib/bitbucket_rest_api/validations/token.rb
bitbucket_rest_api-0.1.1 lib/bitbucket_rest_api/validations/token.rb