blurrily 0.3.0 → 1.0.0

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: 27ce94ccac1210a5ee4da5ad3e3d63b2a168c196
4
- data.tar.gz: b6cb53523c464a470a97a6e6d776322f88d899a9
3
+ metadata.gz: 10d0da3c08622113e1580e66c8dce70c440e5c84
4
+ data.tar.gz: ca80fdcd586ba8b9723799523e5eaef766116a0e
5
5
  SHA512:
6
- metadata.gz: 9785056cf139725e62a1cb4041cb78d1b3160d1ae050cc97085f6233ec442aa530088d60b6c13881aaf1b5546d950f056cf040af221dbb19851b870d21845264
7
- data.tar.gz: cb50cd6063d0d53c402af3014a52af3be8729f9bef698fbd324c8e707f97bb060842486d227f0b422a7faa6a7ccb6ccd2d46fc93976e666491deacfc84bd689b
6
+ metadata.gz: d563833faf1eb740600d6f628e378de3b4252a512a03758b8dc1e7dfd604837818ea7f53d8a6fef67522eabd355cd8d556e429406d09856a4151d48b232f8a5f
7
+ data.tar.gz: f46114e88375943a7423f094fe0b4c9a8fa2d28e22165434456b0b5d46758b175bb6106569738a3d118cd43fddcf174e04c51161287c3ce7683fb8583349e88a
@@ -8,64 +8,71 @@ module Blurrily
8
8
  class Client
9
9
  Error = Class.new(RuntimeError)
10
10
 
11
- # Public: Initialize a new Blurrily::Client connection to Blurrily::Server.
11
+ # Initialize a new {Blurrily::Client} connection to {Blurrily::Server}.
12
12
  #
13
- # host - IP Address or FQDN of the Blurrily::Server.
13
+ # @param host IP Address or FQDN of the Blurrily::Server.
14
14
  # Defaults to Blurrily::DEFAULT_HOST.
15
- # port - Port Blurrily::Server is listening on.
15
+ # @param port Port Blurrily::Server is listening on.
16
16
  # Defaults to Blurrily::DEFAULT_PORT.
17
- # db_name - Name of the data store being targeted.
17
+ # @param db_name Name of the data store being targeted.
18
18
  # Defaults to Blurrily::DEFAULT_DATABASE.
19
19
  #
20
20
  # Examples
21
21
  #
22
- # Blurrily::Client.new('127.0.0.1', 12021, 'location_en')
23
- # # => #<Blurrily::Client:0x007fcd0d33e708 @host="127.0.0.1", @port=12021, @db_name="location_en">
22
+ # ```
23
+ # Blurrily::Client.new('127.0.0.1', 12021, 'location_en')
24
+ # # => #<Blurrily::Client:0x007fcd0d33e708 @host="127.0.0.1", @port=12021, @db_name="location_en">
25
+ # ```
24
26
  #
25
- # Returns the instance of Blurrily::Client
27
+ # @returns the instance of {Blurrily::Client}
26
28
  def initialize(options = {})
27
29
  @host = options.fetch(:host, DEFAULT_HOST)
28
30
  @port = options.fetch(:port, DEFAULT_PORT)
29
31
  @db_name = options.fetch(:db_name, DEFAULT_DATABASE)
30
32
  end
31
33
 
32
- # Public: Find record references based on a given string (needle)
34
+ # Find record references based on a given string (needle)
33
35
  #
34
- # needle - The string you're searching for matches on.
36
+ # @param needle The string you're searching for matches on.
35
37
  # Must not contain tabs.
36
38
  # Required
37
- # limit - Limit the number of results retruned (default: 10).
38
- # MUST be numeric.
39
+ # @param limit Limit the number of results retruned (default: 10).
40
+ # Must be numeric.
39
41
  # Optional
40
42
  #
41
43
  # Examples
42
44
  #
43
- # @client.find('London')
44
- # # => [[123,6,3],[124,5,3]...]
45
+ # ```
46
+ # @client.find('London')
47
+ # # => [[123,6,3],[124,5,3]...]
48
+ # ```
45
49
  #
46
- # Returns an Array of matching [REF,SCORE,WEIGHT] ordered by score. REF is the identifying value of the original record.
50
+ # @returns an Array of matching [`ref`,`score`,`weight`] ordered by score. `ref` is the identifying value of the original record.
51
+ # Note that unless modified, `weight` is simply the string length.
47
52
  def find(needle, limit = nil)
48
53
  limit ||= LIMIT_DEFAULT
49
54
  check_valid_needle(needle)
50
55
  raise(ArgumentError, "LIMIT value must be in #{LIMIT_RANGE}") unless LIMIT_RANGE.include?(limit)
51
56
 
52
57
  cmd = ["FIND", @db_name, needle, limit]
53
- send_cmd_and_get_results(cmd).map(&:to_i)
58
+ send_cmd_and_get_results(cmd).map(&:to_i).each_slice(3).to_a
54
59
  end
55
60
 
56
- # Public: Index a given record.
61
+ # Index a given record.
57
62
  #
58
- # db_name - The name of the data store being targeted. Required
59
- # needle - The string you wish to index. Must not contain tabs. Required
60
- # ref - The indentifying value of the record being indexed. Must be numeric. Required
61
- # weight - Weight of this particular reference. Default 0. Don't change unless you know what you're doing. Optional.
63
+ # @param db_name The name of the data store being targeted. Required
64
+ # @param needle The string you wish to index. Must not contain tabs. Required
65
+ # @param ref The indentifying value of the record being indexed. Must be numeric. Required
66
+ # @param weight Weight of this particular reference. Default 0. Don't change unless you know what you're doing. Optional.
62
67
  #
63
68
  # Examples
64
69
  #
65
- # @client.put('location_en', 'London', 123, 0)
66
- # # => OK
70
+ # ```
71
+ # @client.put('location_en', 'London', 123, 0)
72
+ # # => OK
73
+ # ```
67
74
  #
68
- # Returns something to let you know that all is well.
75
+ # @returns something to let you know that all is well.
69
76
  def put(needle, ref, weight = 0)
70
77
  check_valid_needle(needle)
71
78
  check_valid_ref(ref)
@@ -126,4 +133,4 @@ module Blurrily
126
133
  end
127
134
 
128
135
  end
129
- end
136
+ end
@@ -42,8 +42,7 @@ module Blurrily
42
42
  raise ProtocolError, 'Limit must be a number' if limit && !LIMIT_RANGE.include?(limit.to_i)
43
43
 
44
44
  results = @map_group.map(map_name).find(*[needle, limit && limit.to_i].compact)
45
- refs = results.map{ |result| result.first }
46
- return refs
45
+ return results.flatten
47
46
  end
48
47
 
49
48
  def on_CLEAR(map_name)
@@ -1,3 +1,3 @@
1
1
  module Blurrily
2
- VERSION = "0.3.0"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blurrily
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Letessier