picky 4.4.1 → 4.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/aux/picky/cli.rb CHANGED
@@ -2,7 +2,7 @@ module Picky
2
2
 
3
3
  # A very simple CLI selector.
4
4
  #
5
- class CLI # :nodoc:all
5
+ class CLI
6
6
 
7
7
  # Execute a command.
8
8
  #
@@ -3,7 +3,7 @@
3
3
 
4
4
  # Analyzes indexes (index bundles, actually).
5
5
  #
6
- class Analyzer # :nodoc:all
6
+ class Analyzer
7
7
 
8
8
  attr_reader :analysis, :comments
9
9
 
@@ -1,6 +1,6 @@
1
1
  module Picky
2
2
 
3
- module Calculations # :nodoc:all
3
+ module Calculations
4
4
 
5
5
  # A location calculation recalculates a 1-d location
6
6
  # to the Picky internal 1-d "grid".
@@ -12,7 +12,7 @@ module Picky
12
12
  #
13
13
  class WestEuropean
14
14
 
15
- def initialize # :nodoc:
15
+ def initialize
16
16
  @chars = ActiveSupport::Multibyte.proxy_class
17
17
  end
18
18
 
@@ -45,7 +45,7 @@ module Picky
45
45
  }.pack 'U*'
46
46
  end
47
47
 
48
- def to_s # :nodoc:
48
+ def to_s
49
49
  self.class.name
50
50
  end
51
51
 
@@ -1,7 +1,7 @@
1
1
  require File.expand_path '../constants', __FILE__
2
2
 
3
- module Picky # :nodoc:
4
- module Capistrano # :nodoc:all
3
+ module Picky
4
+ module Capistrano
5
5
 
6
6
  # Include all
7
7
  #
@@ -1,4 +1,6 @@
1
- puts 'Compiling with Ruby 1.9'
1
+ RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
2
+
3
+ puts "Compiling on Ruby 1.9 with CC set to #{RbConfig::MAKEFILE_CONFIG['CC']}."
2
4
  require 'mkmf'
3
5
 
4
6
  abort 'need ruby.h' unless have_header("ruby.h")
@@ -1,6 +1,6 @@
1
1
  # The Array class we all know and love.
2
2
  #
3
- class Array # :nodoc:all
3
+ class Array
4
4
 
5
5
  # Cluster-uniqs equal neighborly elements.
6
6
  #
@@ -1,6 +1,6 @@
1
1
  # The original Class class.
2
2
  #
3
- class Class # :nodoc:all
3
+ class Class
4
4
 
5
5
  def instance_delegate *methods
6
6
  methods.each do |method|
@@ -1,6 +1,6 @@
1
1
  # Extensions for the Hash.
2
2
  #
3
- class Hash # :nodoc:all
3
+ class Hash
4
4
 
5
5
  # Use yajl's encoding.
6
6
  #
@@ -1,6 +1,6 @@
1
1
  # The original Module class.
2
2
  #
3
- class Module # :nodoc:all
3
+ class Module
4
4
 
5
5
  def each_delegate *methods
6
6
  options = methods.pop
@@ -1,4 +1,4 @@
1
- class Object # :nodoc:all
1
+ class Object
2
2
 
3
3
  # TODO Remove.
4
4
 
@@ -1,6 +1,6 @@
1
1
  # Extending the String class.
2
2
  #
3
- class String # :nodoc:all
3
+ class String
4
4
 
5
5
  # Returns a _single_ double metaphone code
6
6
  # for this string.
@@ -1,6 +1,6 @@
1
1
  # Extending the Symbol class.
2
2
  #
3
- class Symbol # :nodoc:all
3
+ class Symbol
4
4
 
5
5
  # Returns a _single_ double metaphone code
6
6
  # for this symbol.
@@ -27,7 +27,7 @@ module Picky
27
27
 
28
28
  # Tries to require the text gem.
29
29
  #
30
- def check_gem # :nodoc:
30
+ def check_gem
31
31
  require 'text'
32
32
  rescue LoadError
33
33
  warn_gem_missing 'text', 'a phonetic Similarity'
data/lib/picky/index.rb CHANGED
@@ -288,7 +288,7 @@ module Picky
288
288
  # THINK Will have to write a wrapper that combines two categories that are
289
289
  # indexed simultaneously, since lat/lng are correlated.
290
290
  #
291
- def geo_categories lat_name, lng_name, radius, options = {} # :nodoc:
291
+ def geo_categories lat_name, lng_name, radius, options = {}
292
292
 
293
293
  # Extract lat/lng specific options.
294
294
  #
@@ -316,7 +316,7 @@ module Picky
316
316
 
317
317
  end
318
318
 
319
- def to_stats # :nodoc:
319
+ def to_stats
320
320
  stats = <<-INDEX
321
321
  #{name} (#{self.class}):
322
322
  #{"source: #{source}".indented_to_s}
@@ -35,7 +35,7 @@ module Picky
35
35
  source.reconnect! if source.respond_to?(:reconnect!)
36
36
  end
37
37
 
38
- def check source # :nodoc:
38
+ def check source
39
39
  raise "Trying to index without a source for #{@index_or_category.name}." unless source
40
40
  end
41
41
 
data/lib/picky/loader.rb CHANGED
@@ -2,7 +2,7 @@ module Picky
2
2
 
3
3
  # Loads the search engine and it
4
4
  #
5
- module Loader # :nodoc:all
5
+ module Loader
6
6
 
7
7
  class << self
8
8
 
@@ -1,6 +1,6 @@
1
1
  module Picky
2
2
 
3
- module Performant # :nodoc:all
3
+ module Performant
4
4
  # C Code here.
5
5
  end
6
6
 
@@ -1,11 +1,17 @@
1
1
  module Picky
2
2
 
3
3
  module Query
4
-
5
- # An allocation has a number of combinations:
6
- # [token, index] [other_token, other_index], ...
4
+
5
+ # An Allocation contains an ordered list of
6
+ # tuples (Combinations).
7
+ # The Combinations are ordered according to the order
8
+ # of the words in the query.
9
+ #
10
+ # It offers convenience methods to calculate the #ids etc.
11
+ #
12
+ # An Allocation is normally contained in an Allocations container.
7
13
  #
8
- class Allocation # :nodoc:all
14
+ class Allocation
9
15
 
10
16
  attr_reader :count,
11
17
  :score,
@@ -2,9 +2,17 @@ module Picky
2
2
 
3
3
  module Query
4
4
 
5
- # Container class for allocations.
5
+ # Container class for Allocation s.
6
6
  #
7
- class Allocations # :nodoc:all
7
+ # This class is asked by the Results class to
8
+ # compile and process a query.
9
+ # It then asks each Allocation to process their
10
+ # ids and scores.
11
+ #
12
+ # It also offers convenience methods to access #ids
13
+ # of its Allocation s.
14
+ #
15
+ class Allocations
8
16
 
9
17
  delegate :each,
10
18
  :empty?,
@@ -88,8 +96,11 @@ module Picky
88
96
  end
89
97
  end
90
98
 
91
- # Same as #process! but with this added parameter:
92
- # * unique: If ids have already been found, do not find them anymore (if true)
99
+ # Same as #process! but removes duplicate ids from results.
100
+ #
101
+ # Note that in the result later on an allocation won't be
102
+ # included if it contains no ids (even in case they have been
103
+ # eliminated by the unique constraint in this method).
93
104
  #
94
105
  # Note: Slower than #process! especially with large offsets.
95
106
  #
@@ -2,16 +2,12 @@ module Picky
2
2
 
3
3
  module Query
4
4
 
5
- # Describes the combination of a token (the text) and
6
- # the index (the bundle): [text, index_bundle]
5
+ # Describes the Combination of a Token (the text) and
6
+ # the index (the bundle): [text, index_bundle].
7
7
  #
8
- # A combination is a single part of an allocation:
9
- # [..., [text2, index_bundle2], ...]
8
+ # An Allocation consists of an ordered number of Combinations.
10
9
  #
11
- # An allocation consists of a number of combinations:
12
- # [[text1, index_bundle1], [text2, index_bundle2], [text3, index_bundle1]]
13
- #
14
- class Combination # :nodoc:all
10
+ class Combination
15
11
 
16
12
  attr_reader :token,
17
13
  :category
@@ -74,7 +70,7 @@ module Picky
74
70
  end
75
71
 
76
72
  # Example:
77
- # "exact title:Peter*:peter"
73
+ # "exact title:Peter*:peter"
78
74
  #
79
75
  def to_s
80
76
  "#{category.bundle_for(token).identifier}(#{to_result.join(':')})"
@@ -2,14 +2,15 @@ module Picky
2
2
 
3
3
  module Query
4
4
 
5
- # Combinations are a number of Combination-s.
5
+ # Combinations represent an ordered list of Combination s.
6
6
  #
7
- # They are the core of an allocation.
8
- # An allocation consists of a number of combinations.
7
+ # Combinations contain methods for calculating score (including
8
+ # the boost) and ids for each of its Combination s.
9
+ #
10
+ # They are the core of an Allocation.
11
+ # An Allocation consists of a number of Combinations.
9
12
  #
10
- # Base Combinations contain methods for calculating score and ids.
11
- #
12
- class Combinations # :nodoc:all
13
+ class Combinations
13
14
 
14
15
  attr_reader :combinations
15
16
 
@@ -36,8 +37,8 @@ module Picky
36
37
  # that are passed in, are removed.
37
38
  #
38
39
  # Note: This method is not totally independent of the calculate_ids one.
39
- # Since identifiers are only nullified, we need to not include the
40
- # ids that have an associated identifier that is nil.
40
+ # Since identifiers are only nullified, we need to not include the
41
+ # ids that have an associated identifier that is nil.
41
42
  #
42
43
  def remove categories = []
43
44
  @combinations.reject! { |combination| categories.include?(combination.category) }
@@ -14,13 +14,13 @@ module Picky
14
14
  #
15
15
  # Picky will raise a Query::Indexes::DifferentBackendsError.
16
16
  #
17
- def check_backends indexes # :nodoc:
17
+ def check_backends indexes
18
18
  backends = indexes.map &:backend
19
19
  backends.uniq! &:class
20
20
  raise_different backends if backends.size > 1
21
21
  backends
22
22
  end
23
- def raise_different backends # :nodoc:
23
+ def raise_different backends
24
24
  raise DifferentBackendsError.new(backends)
25
25
  end
26
26
 
@@ -31,7 +31,7 @@ module Picky
31
31
  # Currently it isn't possible using Memory and Redis etc.
32
32
  # indexes in the same query index group.
33
33
  #
34
- class DifferentBackendsError < StandardError # :nodoc:all
34
+ class DifferentBackendsError < StandardError
35
35
  def initialize backends
36
36
  @backends = backends
37
37
  end
@@ -6,7 +6,7 @@ module Picky
6
6
 
7
7
  # Collection class for qualifiers.
8
8
  #
9
- class QualifierCategoryMapper # :nodoc:all
9
+ class QualifierCategoryMapper
10
10
 
11
11
  attr_reader :mapping
12
12
 
@@ -9,7 +9,7 @@ module Picky
9
9
  # It also knows whether it needs to look for similarity (bla~),
10
10
  # or whether it is a partial (bla*).
11
11
  #
12
- class Token # :nodoc:all
12
+ class Token
13
13
 
14
14
  attr_reader :text, :original
15
15
  attr_writer :similar
@@ -6,7 +6,7 @@ module Picky
6
6
 
7
7
  # This class primarily handles switching through similar token constellations.
8
8
  #
9
- class Tokens # :nodoc:all
9
+ class Tokens
10
10
 
11
11
  attr_reader :ignore_unassigned
12
12
 
@@ -1,4 +1,4 @@
1
- module Rack # :nodoc:
1
+ module Rack
2
2
 
3
3
  # Simple Rack Middleware to kill Unicorns after X requests.
4
4
  #
data/lib/picky/search.rb CHANGED
@@ -227,7 +227,7 @@ module Picky
227
227
 
228
228
  # Gets sorted allocations for the tokens.
229
229
  #
230
- def sorted_allocations tokens, amount = nil # :nodoc:
230
+ def sorted_allocations tokens, amount = nil
231
231
  indexes.prepared_allocations_for tokens, boosts, amount
232
232
  end
233
233
 
@@ -6,7 +6,7 @@ module Picky
6
6
 
7
7
  # Gathers various statistics.
8
8
  #
9
- class Statistics # :nodoc:all
9
+ class Statistics
10
10
 
11
11
  def initialize
12
12
  @indexes = ["\033[1mIndexes analysis\033[m:"]
data/lib/tasks/try.rb CHANGED
@@ -1,5 +1,9 @@
1
1
  module Picky
2
-
2
+
3
+ # Try is used by
4
+ # rake try[text,index,category]
5
+ # to test how the text would be indexed and processed during a search.
6
+ #
3
7
  class Try
4
8
 
5
9
  attr_reader :text, :specific
@@ -13,6 +13,25 @@ describe Picky::Backends::Memory::JSON do
13
13
  it "works with cyrillic characters" do
14
14
  backend.dump_json key: 'й'
15
15
  end
16
+ it "works with ascii strings" do
17
+ # See https://github.com/floere/picky/pull/69.
18
+ #
19
+ # Rails sets both encodings to UTF-8.
20
+ #
21
+ old_default_external = Encoding.default_external
22
+ old_default_internal = Encoding.default_internal
23
+ Encoding.default_external = 'UTF-8'
24
+ Encoding.default_internal = 'UTF-8'
25
+
26
+ ascii = "\xE5".force_encoding 'ASCII-8BIT'
27
+ # ascii.encode('UTF-8') # Uncomment this to get the error mentioned in the pull request.
28
+ backend.dump_json ascii => ascii # Pass in the string as both key and value
29
+
30
+ # Reset encodings.
31
+ #
32
+ Encoding.default_external = old_default_external
33
+ Encoding.default_internal = old_default_internal
34
+ end
16
35
  end
17
36
 
18
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: picky
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.1
4
+ version: 4.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-13 00:00:00.000000000 Z
12
+ date: 2012-06-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70307499892700 !ruby/object:Gem::Requirement
16
+ requirement: &70255381661400 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,21 +21,21 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70307499892700
24
+ version_requirements: *70255381661400
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: picky-client
27
- requirement: &70307499891000 !ruby/object:Gem::Requirement
27
+ requirement: &70255381659920 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: 4.4.1
32
+ version: 4.4.2
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70307499891000
35
+ version_requirements: *70255381659920
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: text
38
- requirement: &70307499888240 !ruby/object:Gem::Requirement
38
+ requirement: &70255381674980 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70307499888240
46
+ version_requirements: *70255381674980
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: yajl-ruby
49
- requirement: &70307499901520 !ruby/object:Gem::Requirement
49
+ requirement: &70255381674320 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70307499901520
57
+ version_requirements: *70255381674320
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: activesupport
60
- requirement: &70307499899220 !ruby/object:Gem::Requirement
60
+ requirement: &70255381673560 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '3.0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70307499899220
68
+ version_requirements: *70255381673560
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: procrastinate
71
- requirement: &70307499897140 !ruby/object:Gem::Requirement
71
+ requirement: &70255381672800 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0.4'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70307499897140
79
+ version_requirements: *70255381672800
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rack_fast_escape
82
- requirement: &70307499895940 !ruby/object:Gem::Requirement
82
+ requirement: &70255381672420 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *70307499895940
90
+ version_requirements: *70255381672420
91
91
  description: Fast Ruby semantic text search engine with comfortable single field interface.
92
92
  email: florian.hanke+picky@gmail.com
93
93
  executables:
@@ -521,3 +521,4 @@ test_files:
521
521
  - spec/lib/statistics_spec.rb
522
522
  - spec/lib/tasks/try_spec.rb
523
523
  - spec/lib/tokenizer_spec.rb
524
+ has_rdoc: