File: client.rb

package info (click to toggle)
ruby-riddle 2.3.1-2~deb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 10,752 kB
  • sloc: sql: 25,022; php: 5,992; ruby: 4,757; sh: 59; makefile: 5
file content (34 lines) | stat: -rw-r--r-- 1,021 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true

Riddle::Client::Versions[:search]  = 0x117
Riddle::Client::Versions[:excerpt] = 0x102

class Riddle::Client
  private
  
  # Generation of the message to send to Sphinx for an excerpts request.
  def excerpts_message(options)
    message = Message.new
    
    message.append [0, excerpt_flags(options)].pack('N2') # 0 = mode
    message.append_string options[:index]
    message.append_string options[:words]
    
    # options
    message.append_string options[:before_match]
    message.append_string options[:after_match]
    message.append_string options[:chunk_separator]
    message.append_ints options[:limit], options[:around]
    message.append_ints options[:limit_passages], options[:limit_words]
    message.append_ints options[:start_passage_id]
    message.append_string options[:html_strip_mode]
    
    if Versions[:excerpt] >= 0x103
      message.append_string options[:passage_boundary]
    end
    
    message.append_array options[:docs]
    
    message.to_s
  end
end