srchio 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +13 -5
- data/README.md +8 -3
- data/lib/srchio.rb +1 -0
- data/lib/srchio/client.rb +10 -1
- data/lib/srchio/concern.rb +11 -1
- data/lib/srchio/response.rb +5 -1
- data/lib/srchio/tag.rb +10 -0
- data/lib/srchio/version.rb +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZjRiM2Q0M2Q1MTRkNmM1MWVkM2M1MWQ4MDZjNjMzMWU3ZjI1MzIyNg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MDk2MTRlMzJkNmVkZTU2ZTM1MDM5NTUyYWMxYzg0ZTg2M2FiMmRiMA==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NmQ2MjY1MWQyODIxZjZhZmFjNjA1NTEwZjlkNjcxMjk4ODVkZDE3NzIzZTQ5
|
10
|
+
MmY4M2VkMzA4YmQ4NmY1ZTU3MmM1NzA3N2ViMmY5MzAzM2NjZWI3OWQxNGUy
|
11
|
+
ZmFkOGI4ZWUxMTg5OTIyMWRiYjFlOTk5ZWIxMGM2NTdlYWIwMDc=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZDM4Mzk4ZWM2NjBkYjg2MDhkNTdjMjY3MWE5ZDUwZTJlZTNlMWU4YmNmMmJj
|
14
|
+
NzY5NDU5OGY4NDIzNzhkYTJlOTMyMzIyYjhhMDYzMjE2ZmNhYjA1NjQyOGQ0
|
15
|
+
NzE5YTRkYTM5N2IzNTIzZjQzZWIzOGZkM2U3YzE3YjY4MDQ2Y2U=
|
data/README.md
CHANGED
@@ -32,7 +32,8 @@ client.add_document(
|
|
32
32
|
tags: ['fun', 'api', 'awesome']
|
33
33
|
)
|
34
34
|
|
35
|
-
client.search(query: "fun")
|
35
|
+
client.search(query: "fun")
|
36
|
+
client.tag_cloud</code></pre>
|
36
37
|
|
37
38
|
If you need to delete a document, you can do it either with your remote_id or the index_id returned in the add_document call:
|
38
39
|
|
@@ -42,8 +43,11 @@ If you need to delete a document, you can do it either with your remote_id or th
|
|
42
43
|
|
43
44
|
Since we're so nice, we went ahead and created a handy ActiveSupport::Concern to include in your models to get all the srch.io goodness right in your model and the make wiring things up faster. Here's how you'd use it in a standard ActiveRecord model:
|
44
45
|
|
45
|
-
<pre><code>class Foo
|
46
|
-
|
46
|
+
<pre><code>class Foo < ActiveRecord::Base
|
47
|
+
include Srchio::Concern
|
48
|
+
|
49
|
+
# Tell srchio where to get the fields to index
|
50
|
+
# (these are the methods on your model that provide those values, like foo.id):
|
47
51
|
|
48
52
|
configure_srch searcher_id: 1,
|
49
53
|
title: :foo_title,
|
@@ -54,6 +58,7 @@ Since we're so nice, we went ahead and created a handy ActiveSupport::Concern to
|
|
54
58
|
|
55
59
|
after_save :srch_save
|
56
60
|
after_destroy :srch_destroy
|
61
|
+
|
57
62
|
end</code></pre>
|
58
63
|
|
59
64
|
If you're adding search to an existing model, you'll probably want to do something like the following to get all of your documents indexed:
|
data/lib/srchio.rb
CHANGED
data/lib/srchio/client.rb
CHANGED
@@ -44,7 +44,7 @@ module Srchio
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def self.update_base_uri
|
47
|
-
base_uri
|
47
|
+
base_uri "#{self.api_protocol}://#{self.api_domain}/"
|
48
48
|
true
|
49
49
|
end
|
50
50
|
|
@@ -133,5 +133,14 @@ options:
|
|
133
133
|
|
134
134
|
Srchio::Response.new(self.class.get("/api/searchers/#{searcher_id}/search", :query => opts))
|
135
135
|
end
|
136
|
+
|
137
|
+
=begin rdoc
|
138
|
+
Returns the tag cloud for your searcher. It will only return the number of unique tags you have that appear in at least one document.
|
139
|
+
options:
|
140
|
+
* :n: The number of tags to return. Defaults to 1,000.
|
141
|
+
=end
|
142
|
+
def tag_cloud(opts={})
|
143
|
+
Srchio::Response.new(self.class.get("/api/searchers/#{searcher_id}/tag_cloud", :query => opts))
|
144
|
+
end
|
136
145
|
end
|
137
146
|
end
|
data/lib/srchio/concern.rb
CHANGED
@@ -96,7 +96,17 @@ options:
|
|
96
96
|
def srch(opts={})
|
97
97
|
srch_client.search(opts)
|
98
98
|
end
|
99
|
-
|
99
|
+
|
100
|
+
=begin rdoc
|
101
|
+
tag_cloud: Return the tags for your searcher.
|
102
|
+
|
103
|
+
options:
|
104
|
+
* n: The number of tags to return. Defaults to 1,000.
|
105
|
+
=end
|
106
|
+
def tag_cloud(opts={})
|
107
|
+
srch_client.tag_cloud(opts)
|
108
|
+
end
|
109
|
+
|
100
110
|
=begin rdoc
|
101
111
|
srch_destroy: Destroy a document.
|
102
112
|
|
data/lib/srchio/response.rb
CHANGED
@@ -18,7 +18,11 @@ module Srchio
|
|
18
18
|
if r['results'].is_a?(Array)
|
19
19
|
@results = []
|
20
20
|
r['results'].each do |result|
|
21
|
-
|
21
|
+
if result['tag']
|
22
|
+
@results << Srchio::Tag.new(result)
|
23
|
+
else
|
24
|
+
@results << Srchio::Result.new(result)
|
25
|
+
end
|
22
26
|
end
|
23
27
|
end
|
24
28
|
end
|
data/lib/srchio/tag.rb
ADDED
data/lib/srchio/version.rb
CHANGED
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: srchio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Lawver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - '>='
|
17
|
+
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.12.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - '>='
|
24
|
+
- - ! '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.12.0
|
27
27
|
description: The official gem and wrapper for the srch.io API. More info @ http://srch.io
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- lib/srchio/concern.rb
|
39
39
|
- lib/srchio/response.rb
|
40
40
|
- lib/srchio/result.rb
|
41
|
+
- lib/srchio/tag.rb
|
41
42
|
- lib/srchio/version.rb
|
42
43
|
- srchio.gemspec
|
43
44
|
homepage: http://github.com/railsmachine/srchio
|
@@ -50,17 +51,17 @@ require_paths:
|
|
50
51
|
- lib
|
51
52
|
required_ruby_version: !ruby/object:Gem::Requirement
|
52
53
|
requirements:
|
53
|
-
- - '>='
|
54
|
+
- - ! '>='
|
54
55
|
- !ruby/object:Gem::Version
|
55
56
|
version: 1.9.3
|
56
57
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
58
|
requirements:
|
58
|
-
- - '>='
|
59
|
+
- - ! '>='
|
59
60
|
- !ruby/object:Gem::Version
|
60
61
|
version: '0'
|
61
62
|
requirements: []
|
62
63
|
rubyforge_project:
|
63
|
-
rubygems_version: 2.1.
|
64
|
+
rubygems_version: 2.1.9
|
64
65
|
signing_key:
|
65
66
|
specification_version: 4
|
66
67
|
summary: The official gem for srch.io! Makes searching fun and easy.
|