srchio 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c88ec650b5d8a0f702bd76a8116d08fdeccf8b39
4
- data.tar.gz: 684d660029a1a5fdc1a75a12edf5b42691bea66f
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZjRiM2Q0M2Q1MTRkNmM1MWVkM2M1MWQ4MDZjNjMzMWU3ZjI1MzIyNg==
5
+ data.tar.gz: !binary |-
6
+ MDk2MTRlMzJkNmVkZTU2ZTM1MDM5NTUyYWMxYzg0ZTg2M2FiMmRiMA==
5
7
  SHA512:
6
- metadata.gz: 1612e171146e36f41f4072b49fc82ec92679866ab9ddde8b740e41f51de318e81062e068ec5bb5eccde56063e76b1b1aa5c1a68d7f20131d12c1d03b3a0f6dad
7
- data.tar.gz: f28473469566460da5020ec5559938037f4ebd3f3c26ed70ad9ee421a8dcdced4f2d1ee56ea9ec318ba2106106c2acbbb6e276ab1b8dc6c433bcacea07495bcb
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")</code></pre>
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 < ActiveRecord::Base
46
- # Tell srchio where to get the fields to index (these are the methods on your model that provide those values, like foo.id):
46
+ <pre><code>class Foo &lt; 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:
@@ -2,6 +2,7 @@ require 'httparty'
2
2
  require 'srchio/client'
3
3
  require 'srchio/response'
4
4
  require 'srchio/result'
5
+ require 'srchio/tag'
5
6
  require 'srchio/version'
6
7
  require 'srchio/concern'
7
8
 
@@ -44,7 +44,7 @@ module Srchio
44
44
  end
45
45
 
46
46
  def self.update_base_uri
47
- base_uri = "#{self.api_protocol}://#{self.api_domain}/"
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
@@ -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
 
@@ -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
- @results << Srchio::Result.new(result)
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
@@ -0,0 +1,10 @@
1
+ module Srchio
2
+ class Tag
3
+ attr_accessor :tag, :count
4
+
5
+ def initialize(result={})
6
+ @tag = result['tag']
7
+ @count = result['count']
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module Srchio
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
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
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-16 00:00:00.000000000 Z
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.11
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.