picky 4.27.0 → 4.27.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20377f0b4ac92cd75659306842de34204b7bf85d
4
- data.tar.gz: 7c3e252193f4be20dd6fb5013b11a9d427662051
3
+ metadata.gz: 3a32ef9ec55047df769e8a264eee585bab738f5d
4
+ data.tar.gz: 6574e4c5d634313b160d0ff291a4c68e8ee9f553
5
5
  SHA512:
6
- metadata.gz: 02e007ee3b0e7be2a4ce3c337bde4d496c4ccce05450196d8e7135d69d08dec5020d4fa8858b58ae54e170b64fd62677bd08df6c7eb348ada0c78252b7effbd2
7
- data.tar.gz: 41285d5f985a0ed59407ba0b8f52526f122a86af8be4f90341b39d79884a2b922d9883a16ae39f0f6ecb997fb5edd1e5208c960d8811dedd09b1c22821c3bb8f
6
+ metadata.gz: ecbb19fb08c6e69ad40bc9a9d6b7416db8ad5b5fc1ac6d340070714cc1e02d70c01ed68fd0de8bd79628af5cb847126983b92c1f847b9bedbd5ffaa2134d85aa
7
+ data.tar.gz: 9fe9fbcd9109b245777bd48246d466078646a602260e278f73e9c0ba0233e2b69e852903af046412acdebc169072544435d8b2b0eef4d5a9ffdb8f0b400ea693
@@ -64,7 +64,7 @@ module Picky
64
64
  #
65
65
  def dump hash
66
66
  offset = 0
67
- mapping = {}
67
+ mapping = Hash.new
68
68
 
69
69
  create_directory cache_path
70
70
  ::File.open(cache_path, 'w:utf-8') do |out_file|
@@ -1,6 +1,8 @@
1
1
  if require 'google_hash'
2
2
 
3
3
  class ::GoogleHashSparseRubyToRuby
4
+
5
+ alias each_pair each
4
6
 
5
7
  # This is mainly used in tests, which is
6
8
  # why we allow for a silly implementation.
@@ -24,7 +26,7 @@ if require 'google_hash'
24
26
  true
25
27
  end
26
28
 
27
- #
29
+ # TODO
28
30
  #
29
31
  def inject init, &block
30
32
  result = init
@@ -34,6 +36,8 @@ if require 'google_hash'
34
36
  result
35
37
  end
36
38
 
39
+ # TODO
40
+ #
37
41
  def size
38
42
  result = 0
39
43
  # each only accepts a block
@@ -45,15 +45,6 @@ module Picky
45
45
  def empty
46
46
  @empty && @empty.clone || hash_type.new
47
47
  end
48
-
49
- def empty_hash
50
- # TODO Make this an explicit option.
51
- if defined? GoogleHashSparseRubyToRuby
52
- GoogleHashSparseRubyToRuby.new # TODO Use GoogleHashDenseIntToRuby where possible.
53
- else
54
- {}
55
- end
56
- end
57
48
 
58
49
  # The initial content before loading from file/indexing.
59
50
  #
@@ -44,14 +44,15 @@ module Picky
44
44
  # object[id] # => [:sym1, :sym2]
45
45
  #
46
46
  def create_realtime bundle, hints = nil
47
- json bundle.index_path(:realtime), hash_for(hints) # GoogleHashSparseLongToRuby # FIXME This is only true on number keys (add Picky hints).
47
+ # GoogleHashSparseLongToRuby # FIXME This is only true on number keys (add Picky hints).
48
+ json bundle.index_path(:realtime), hash_for(hints)
48
49
  end
49
50
 
50
51
  private
51
52
 
52
53
  def hash_for hints
53
54
  if hints && hints.does?(:no_dump)
54
- ::GoogleHashSparseRubyToRuby
55
+ ::GoogleHashSparseRubyToRuby # TODO Use GoogleHashSparseIntToRuby where possible.
55
56
  else
56
57
  ::Hash
57
58
  end
data/lib/picky/bundle.rb CHANGED
@@ -54,8 +54,8 @@ module Picky
54
54
  @partial_strategy = partial_strategy
55
55
  @similarity_strategy = similarity_strategy
56
56
 
57
- @hints = options.delete :hints
58
- @backend = options.delete :backend
57
+ @hints = options[:hints]
58
+ @backend = options[:backend]
59
59
 
60
60
  reset_backend
61
61
  end
@@ -30,7 +30,7 @@ module Picky
30
30
  #
31
31
  def clear_categories
32
32
  @categories = []
33
- @category_hash = {}
33
+ @category_hash = Hash.new
34
34
  end
35
35
 
36
36
  # Updates the qualifier ("qualifier:searchterm") mapping.
@@ -71,7 +71,7 @@ module Picky
71
71
  weights = weights_from options
72
72
  partial = partial_from options
73
73
  similarity = similarity_from options
74
-
74
+
75
75
  @exact = exact_for weights, similarity, options
76
76
  @partial = partial_for @exact, partial, weights, options
77
77
  end
data/lib/picky/indexes.rb CHANGED
@@ -41,7 +41,7 @@ module Picky
41
41
  #
42
42
  def clear_indexes
43
43
  @indexes = []
44
- @index_mapping = {}
44
+ @index_mapping = Hash.new
45
45
  end
46
46
 
47
47
  # Registers an index with the indexes.
@@ -9,7 +9,7 @@ module Picky
9
9
  #
10
10
  #
11
11
  def initialize categories
12
- @mapping = {}
12
+ @mapping = Hash.new
13
13
  categories.each { |category| add category }
14
14
  end
15
15
 
@@ -85,12 +85,11 @@ module Picky
85
85
 
86
86
  # Generates a reused stem.
87
87
  #
88
- # TODO Probably should not cache, as not
89
- # the same stemmer will be used always.
88
+ # Caches a stem for a tokenizer.
90
89
  #
91
90
  def stem tokenizer
92
91
  if stem?
93
- @stems ||= {}
92
+ @stems ||= Hash.new
94
93
  @stems[tokenizer] ||= tokenizer.stem(@text)
95
94
  else
96
95
  @text
@@ -36,8 +36,8 @@ module Picky
36
36
  # Reset the memoization.
37
37
  #
38
38
  def reset_memoization
39
- @exact_memo = {}
40
- @partial_memo = {}
39
+ @exact_memo = Hash.new
40
+ @partial_memo = Hash.new
41
41
  end
42
42
 
43
43
  # Split the given text into its most
@@ -27,9 +27,11 @@ describe "Hint: no_dump" do
27
27
  it "raises" do
28
28
  index.replace Book.new(2, "Title New", "Author New")
29
29
 
30
- index.dump
31
- index.load
32
- index.build_realtime_mapping
30
+ expect {
31
+ index.dump
32
+ index.load
33
+ index.build_realtime_mapping
34
+ }.to raise_error # TODO Clarify error.
33
35
  end
34
36
  end
35
37
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: picky
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.27.0
4
+ version: 4.27.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Hanke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-01 00:00:00.000000000 Z
11
+ date: 2015-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport