Sha256: 86a710a71148bc114f0a3b16b12c7b031702715a0cda201619d45645cb44a8d3

Contents?: true

Size: 856 Bytes

Versions: 19

Compression:

Stored size: 856 Bytes

Contents

# frozen_string_literal: true

module Aserto
  module PolicyPathMapper
    class << self
      def execute(policy_root, request)
        method = request.request_method
        path = request.path_info

        if defined? ::Rails
          require_relative "rails/utils"

          route = Aserto::Rails::Utils.route(request)
          path = route[:path] if route
        end

        if defined? ::Sinatra
          require_relative "sinatra/utils"

          route = Aserto::Sinatra::Utils.route(request)
          path = route[:path] if route
        end

        policy_path = +"#{policy_root}.#{method}.#{path}"
        policy_path.tr!("/", ".")
        policy_path.gsub!("..", ".")
        policy_path.gsub!(":", "__")
        policy_path.gsub!(/[^a-zA-Z0-9._]/, "_")
        policy_path.chomp!(".")
        policy_path
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
aserto-0.31.3 lib/aserto/policy_path_mapper.rb
aserto-0.31.2 lib/aserto/policy_path_mapper.rb
aserto-0.31.1 lib/aserto/policy_path_mapper.rb
aserto-0.31.0 lib/aserto/policy_path_mapper.rb
aserto-0.30.6 lib/aserto/policy_path_mapper.rb
aserto-0.30.5 lib/aserto/policy_path_mapper.rb
aserto-0.30.4 lib/aserto/policy_path_mapper.rb
aserto-0.30.1 lib/aserto/policy_path_mapper.rb
aserto-0.30.0 lib/aserto/policy_path_mapper.rb
aserto-0.20.6 lib/aserto/policy_path_mapper.rb
aserto-0.20.5 lib/aserto/policy_path_mapper.rb
aserto-0.20.4 lib/aserto/policy_path_mapper.rb
aserto-0.20.3 lib/aserto/policy_path_mapper.rb
aserto-0.20.2 lib/aserto/policy_path_mapper.rb
aserto-0.0.6 lib/aserto/policy_path_mapper.rb
aserto-0.0.5 lib/aserto/policy_path_mapper.rb
aserto-0.0.4 lib/aserto/policy_path_mapper.rb
aserto-0.0.3 lib/aserto/policy_path_mapper.rb
aserto-0.0.2 lib/aserto/policy_path_mapper.rb