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.4.4 lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.4.3 lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.4.2 lib/action_dispatch/journey/gtg/simulator.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/actionpack-6.1.4.1/lib/action_dispatch/journey/gtg/simulator.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/actionpack-6.1.4.1/lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.4.1 lib/action_dispatch/journey/gtg/simulator.rb
rails_mini_profiler-0.2.0 vendor/bundle/ruby/3.0.0/gems/actionpack-6.1.4/lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.4 lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.3.2 lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.3.1 lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.3 lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.2.1 lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.2 lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.1 lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.0 lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.0.rc2 lib/action_dispatch/journey/gtg/simulator.rb
actionpack-6.1.0.rc1 lib/action_dispatch/journey/gtg/simulator.rb