Class: Rack::Mount::Analysis::Splitting

### Home Classes Methods

### In Files

- lib/rack/mount/analysis/splitting.rb

### Parent

Object

### Namespace

- CLASS Rack::Mount::Analysis::Splitting::Key

### Methods

- ::new
- #<<
- #clear
- #expire!
- #possible_keys
- #process_key
- #report

### Class/Module Index

Quicksearch

- Rack
- Rack::Mount
- Rack::Mount::Analysis
- Rack::Mount::Analysis::Splitting
- Rack::Mount::Analysis::Splitting::Key
- Rack::Mount::GeneratableRegexp
- Rack::Mount::GeneratableRegexp::InstanceMethods
- Rack::Mount::RegexpWithNamedGroups
- Rack::Mount::Route
- Rack::Mount::RouteSet
- Rack::Mount::RoutingError
- Rack::Mount::Strexp
- Rack::Mount::StrexpParser
- Rack::Mount::StrexpParser::ScanError
- Rack::Mount::Utils
- Regin
- Regin::Alternation
- Regin::Anchor
- Regin::Atom
- Regin::Character
- Regin::CharacterClass
- Regin::Collection
- Regin::Expression
- Regin::Group
- Regin::Options
- Regin::Parser
- Regin::Parser::ScanError

No matching classes.

# Rack::Mount::Analysis::Splitting

### Constants

NULL

### Public Class Methods

new(*keys) click to toggle source

    # File lib/rack/mount/analysis/splitting.rb, line 29
    def initialize(*keys)
      clear
      keys.each { |key| self << key }
    end

### Public Instance Methods

<<(key) click to toggle source

    # File lib/rack/mount/analysis/splitting.rb, line 40
    def <<(key)
      raise ArgumentError unless key.is_a?(Hash)
      @raw_keys << key
      nil
    end

clear() click to toggle source

    # File lib/rack/mount/analysis/splitting.rb, line 34
    def clear
      @raw_keys = []
      @key_frequency = Analysis::Histogram.new
      self
    end

expire!() click to toggle source

    # File lib/rack/mount/analysis/splitting.rb, line 65
    def expire!
      @possible_keys = @report = nil
    end

possible_keys() click to toggle source

    # File lib/rack/mount/analysis/splitting.rb, line 46
    def possible_keys
      @possible_keys ||= begin
        @raw_keys.map do |key|
          key.inject({}) { |requirements, (method, requirement)|
            process_key(requirements, method, requirement)
            requirements
          }
        end
      end
    end

process_key(requirements, method, requirement) click to toggle source

    # File lib/rack/mount/analysis/splitting.rb, line 69
    def process_key(requirements, method, requirement)
      separators = separators(method)
      if requirement.is_a?(Regexp) && separators.any?
        generate_split_keys(requirement, separators).each_with_index do |value, index|
          requirements[Key.new(method, index, Regexp.union(*separators))] = value
        end
      else
        if requirement.is_a?(Regexp)
          expression = Utils.parse_regexp(requirement)

          if expression.is_a?(Regin::Expression) && expression.anchored_to_line?
            expression = Regin::Expression.new(expression.reject { |e| e.is_a?(Regin::Anchor) })
            return requirements[method] = expression.to_s if expression.literal?
          end
        end

        requirements[method] = requirement
      end
    end

report() click to toggle source

    # File lib/rack/mount/analysis/splitting.rb, line 57
    def report
      @report ||= begin
        possible_keys.each { |keys| keys.each_pair { |key, _| @key_frequency << key } }
        return [] if @key_frequency.count <= 1
        @key_frequency.keys_in_upper_quartile
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.