Sha256: 9e545ade7e77f6d203215f7c706f9aaa3099fca02d05ba083beab3a1b0a084a4

Contents?: true

Size: 898 Bytes

Versions: 37

Compression:

Stored size: 898 Bytes

Contents

# frozen_string_literal: true

require "strscan"

module ActionDispatch
  module Journey # :nodoc:
    module GTG # :nodoc:
      class MatchData # :nodoc:
        attr_reader :memos

        def initialize(memos)
          @memos = memos
        end
      end

      class Simulator # :nodoc:
        INITIAL_STATE = [0].freeze

        attr_reader :tt

        def initialize(transition_table)
          @tt = transition_table
        end

        def memos(string)
          input = StringScanner.new(string)
          state = INITIAL_STATE

          while sym = input.scan(%r([/.?]|[^/.?]+))
            state = tt.move(state, sym)
          end

          acceptance_states = state.each_with_object([]) do |s, memos|
            memos.concat(tt.memo(s)) if tt.accepting?(s)
          end

          acceptance_states.empty? ? yield : acceptance_states
        end
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 4 rubygems

Version Path
actionpack-6.1.7.10 lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.7.9 lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.7.8 lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.7.7 lib/action_dispatch/journey/gtg/simulator.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.7.6 lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.7.5 lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.7.4 lib/action_dispatch/journey/gtg/simulator.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.7.3 lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.7.2 lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.7.1 lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.7 lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.6.1 lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.6 lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.5.1 lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.5 lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.4.7 lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.4.6 lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.4.5 lib/action_dispatch/journey/gtg/simulator.rb