Sha256: 33f2667bf911788e998eb66250cf0b5a52b8d8c065d294a2784285275efe4aa5

Contents?: true

Size: 921 Bytes

Versions: 87

Compression:

Stored size: 921 Bytes

Contents

module Picky
  
  # Try is used by
  #   rake try[text,index,category]
  # to test how the text would be indexed and processed during a search.
  #
  class Try

    attr_reader :text, :specific

    def initialize text, index = nil, category = nil
      @text = text
      @specific = Picky::Indexes
      @specific = @specific[index.intern]    if index
      @specific = @specific[category.intern] if category
    end

    def saved
      specific.tokenizer.tokenize(text.dup).first
    end

    def searched
      Picky::Tokenizer.searching.tokenize(text.dup).first
    end

    def output
      <<-OUTPUT
\"#{text}\" is saved in the #{specific.identifier} index as #{saved}
\"#{text}\" as a search will be tokenized as #{searched}

(category qualifiers, e.g. title: are removed if they do not exist as a qualifier, so 'toitle:bla' -> 'bla')
      OUTPUT
    end

    def to_stdout
      puts output
    end

  end

end

Version data entries

87 entries across 87 versions & 1 rubygems

Version Path
picky-4.31.3 lib/tasks/try.rb
picky-4.31.2 lib/tasks/try.rb
picky-4.31.1 lib/tasks/try.rb
picky-4.31.0 lib/tasks/try.rb
picky-4.30.0 lib/tasks/try.rb
picky-4.29.0 lib/tasks/try.rb
picky-4.28.1 lib/tasks/try.rb
picky-4.27.1 lib/tasks/try.rb
picky-4.27.0 lib/tasks/try.rb
picky-4.26.2 lib/tasks/try.rb
picky-4.26.1 lib/tasks/try.rb
picky-4.26.0 lib/tasks/try.rb
picky-4.25.3 lib/tasks/try.rb
picky-4.25.2 lib/tasks/try.rb
picky-4.25.1 lib/tasks/try.rb
picky-4.25.0 lib/tasks/try.rb
picky-4.24.0 lib/tasks/try.rb
picky-4.23.2 lib/tasks/try.rb
picky-4.23.1 lib/tasks/try.rb
picky-4.23.0 lib/tasks/try.rb