Module: Mail::Parsers::MessageIdsParser

Extended by:
Mail::ParserTools
Defined in:
lib/mail/parsers/message_ids_parser.rb

Defined Under Namespace

Classes: MessageIdsStruct

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Mail::ParserTools

chars

Class Attribute Details

._eof_actionsObject

Returns the value of attribute _eof_actions


2500
2501
2502
# File 'lib/mail/parsers/message_ids_parser.rb', line 2500

def _eof_actions
  @_eof_actions
end

._index_offsetsObject

Returns the value of attribute _index_offsets


134
135
136
# File 'lib/mail/parsers/message_ids_parser.rb', line 134

def _index_offsets
  @_index_offsets
end

._indiciesObject

Returns the value of attribute _indicies


168
169
170
# File 'lib/mail/parsers/message_ids_parser.rb', line 168

def _indicies
  @_indicies
end

._key_spansObject

Returns the value of attribute _key_spans


100
101
102
# File 'lib/mail/parsers/message_ids_parser.rb', line 100

def _key_spans
  @_key_spans
end

._trans_actionsObject

Returns the value of attribute _trans_actions


2443
2444
2445
# File 'lib/mail/parsers/message_ids_parser.rb', line 2443

def _trans_actions
  @_trans_actions
end

._trans_keysObject

Returns the value of attribute _trans_keys


13
14
15
# File 'lib/mail/parsers/message_ids_parser.rb', line 13

def _trans_keys
  @_trans_keys
end

._trans_targsObject

Returns the value of attribute _trans_targs


2386
2387
2388
# File 'lib/mail/parsers/message_ids_parser.rb', line 2386

def _trans_targs
  @_trans_targs
end

.en_comment_tailObject

Returns the value of attribute en_comment_tail


2547
2548
2549
# File 'lib/mail/parsers/message_ids_parser.rb', line 2547

def en_comment_tail
  @en_comment_tail
end

.en_mainObject

Returns the value of attribute en_main


2551
2552
2553
# File 'lib/mail/parsers/message_ids_parser.rb', line 2551

def en_main
  @en_main
end

.errorObject

Returns the value of attribute error


2542
2543
2544
# File 'lib/mail/parsers/message_ids_parser.rb', line 2542

def error
  @error
end

.first_finalObject

Returns the value of attribute first_final


2538
2539
2540
# File 'lib/mail/parsers/message_ids_parser.rb', line 2538

def first_final
  @first_final
end

.startObject

Returns the value of attribute start


2534
2535
2536
# File 'lib/mail/parsers/message_ids_parser.rb', line 2534

def start
  @start
end

Class Method Details

.parse(data) ⇒ Object


2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
# File 'lib/mail/parsers/message_ids_parser.rb', line 2555

def self.parse(data)
  data = data.dup.force_encoding(Encoding::ASCII_8BIT) if data.respond_to?(:force_encoding)

  raise Mail::Field::NilParseError.new(Mail::MessageIdsElement) if data.nil?

  # Parser state
  message_ids = MessageIdsStruct.new([])
  msg_id_s = nil

  # 5.1 Variables Used by Ragel
  p = 0
  eof = pe = data.length
  stack = []

  begin
    p ||= 0
    pe ||= data.length
    cs = start
    top = 0
  end

  begin
    testEof = false
    _slen, _trans, _keys, _inds, _acts, _nacts = nil
    _goto_level = 0
    _resume = 10
    _eof_trans = 15
    _again = 20
    _test_eof = 30
    _out = 40
    while true
      if _goto_level <= 0
        if p == pe
          _goto_level = _test_eof
          next
        end
        if cs == 0
          _goto_level = _out
          next
        end
      end
      if _goto_level <= _resume
        _keys = cs << 1
        _inds = _index_offsets[cs]
        _slen = _key_spans[cs]
        _wide = data[p].ord
        _trans = if (_slen > 0 &&
                     _trans_keys[_keys] <= _wide &&
                     _wide <= _trans_keys[_keys + 1])
                   _indicies[_inds + _wide - _trans_keys[_keys]]
                 else
                   _indicies[_inds + _slen]
                 end
        cs = _trans_targs[_trans]
        if _trans_actions[_trans] != 0
          case _trans_actions[_trans]
          when 2
            begin
              msg_id_s = p
            end
          when 30
            begin
              message_ids.message_ids << chars(data, msg_id_s, p - 1).rstrip
            end
          when 3
            begin
            end
          when 26
            begin
            end
          when 15
            begin
            end
          when 13
            begin
            end
          when 11
            begin
            end
          when 8
            begin
            end
          when 6
            begin
            end
          when 19
            begin
            end
          when 17
            begin
            end
          when 23
            begin
            end
          when 1
            begin
              begin
                stack[top] = cs
                top += 1
                cs = 196
                _goto_level = _again
                next
              end
            end
          when 29
            begin
              begin
                top -= 1
                cs = stack[top]
                _goto_level = _again
                next
              end
            end
          when 32
            begin
              message_ids.message_ids << chars(data, msg_id_s, p - 1).rstrip
            end
            begin
              msg_id_s = p
            end
          when 31
            begin
              message_ids.message_ids << chars(data, msg_id_s, p - 1).rstrip
            end
            begin
              begin
                stack[top] = cs
                top += 1
                cs = 196
                _goto_level = _again
                next
              end
            end
          when 5
            begin
            end
            begin
              msg_id_s = p
            end
          when 16
            begin
            end
            begin
            end
          when 12
            begin
            end
            begin
            end
          when 25
            begin
            end
            begin
            end
          when 24
            begin
            end
            begin
            end
          when 4
            begin
            end
            begin
              begin
                stack[top] = cs
                top += 1
                cs = 196
                _goto_level = _again
                next
              end
            end
          when 27
            begin
            end
            begin
              begin
                stack[top] = cs
                top += 1
                cs = 196
                _goto_level = _again
                next
              end
            end
          when 28
            begin
            end
            begin
              begin
                top -= 1
                cs = stack[top]
                _goto_level = _again
                next
              end
            end
          when 14
            begin
            end
            begin
              begin
                stack[top] = cs
                top += 1
                cs = 196
                _goto_level = _again
                next
              end
            end
          when 21
            begin
            end
            begin
            end
          when 10
            begin
            end
            begin
            end
          when 9
            begin
            end
            begin
              begin
                stack[top] = cs
                top += 1
                cs = 196
                _goto_level = _again
                next
              end
            end
          when 7
            begin
            end
            begin
              begin
                stack[top] = cs
                top += 1
                cs = 196
                _goto_level = _again
                next
              end
            end
          when 18
            begin
            end
            begin
            end
          when 22
            begin
            end
            begin
            end
            begin
            end
          when 20
            begin
            end
            begin
            end
            begin
            end
          end
        end
      end
      if _goto_level <= _again
        if cs == 0
          _goto_level = _out
          next
        end
        p += 1
        if p != pe
          _goto_level = _resume
          next
        end
      end
      if _goto_level <= _test_eof
        if p == eof
          case _eof_actions[cs]
          when 30
            begin
              message_ids.message_ids << chars(data, msg_id_s, p - 1).rstrip
            end
          when 3
            begin
            end
          end
        end
      end
      if _goto_level <= _out
        break
      end
    end
  end

  if p != eof || cs < 208
    raise Mail::Field::IncompleteParseError.new(Mail::MessageIdsElement, data, p)
  end

  message_ids
end