seeker 0.0.1 → 0.2.0

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 CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4e54247641dde163562c6f30672589e81ec77e60
4
- data.tar.gz: ff0b0de84416467abeb06ff8319448cee81a2528
5
- SHA512:
6
- metadata.gz: ec497af4007218b339a5f787299a0c652e3c5c830dd6b0907b5e1ad11168db5ff094ac5e9551795658784799c022876f83c47c74fe38f152bdac86e0ea6abdf1
7
- data.tar.gz: 994fc23535869b905d5736ef16e94a2eeee670234ece7215be98d8b3b71fa9e3cca479463b4c34b9e9a53fde63c41f308512051cdc7c7fe5bab0c8d566dcac95
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ M2RkZTVhMjU3MzkzZDA3OTY4NWEyNjUwM2E4MzM1M2JiNmJlYTM0OQ==
5
+ data.tar.gz: !binary |-
6
+ NWU5ZDllNTgyYTUwN2M0MjdmMDY4ZDhiYjcyYzVhODBkMzAyZGJkOA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NGY0MGU3NDk2ZDk5Nzg4YmM2YjMzZmNiNjQ4NWNlN2JiZGI4Y2MzYjQzYTgy
10
+ NDA5NDQ4NjI2YmM2YTJlZTVmOTQxMzAxMDYwMzE2MmQzNzk5Mjc1ZWI4Mjcy
11
+ YTg4MDg5YTUxYzMwNGE0NzQwZGZhZDMxMThmMWUyMTJkMWZlZWE=
12
+ data.tar.gz: !binary |-
13
+ MTY4YzJhNGIxMjI2ZjVlYTQ3NDNjNDM4YTlhYzMwZTRhYTY5MTljZjFhM2Zl
14
+ N2Q3MjVkNDJmNWYzY2FmZTM3ZjBjNmZiYzE5YmUyZDg5Njg0NDJkNDI5ZDZl
15
+ NTNjZDhjYTU5NDJjZDQ2M2Y5OWJmMTFmZWU1YzIyMGM3YjhkNTE=
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # Seeker
2
2
 
3
- This Ruby on Rails gem provides an elegant way to separate search logic out of models.
3
+ This Ruby on Rails gem provides an elegant way to separate search logic out of models
4
+ and build search forms just like create/update ones.
4
5
 
5
- Right now it supports only [sunspot](https://github.com/sunspot/sunspot).
6
+ Right now it supports only [sunspot](https://github.com/sunspot/sunspot) and was tested on Rails 3.2.13.
6
7
 
7
8
  ## Installation
8
9
 
@@ -61,4 +62,4 @@ And use it in your view with form helper, just like model:
61
62
  ## TODO
62
63
 
63
64
  * add tests
64
- * add support for ThinkingSphinx
65
+ * add support for [ThinkingSphinx](https://github.com/pat/thinking-sphinx)
data/lib/seeker/base.rb CHANGED
@@ -1,4 +1,12 @@
1
1
  class Seeker::Base
2
+ class_attribute :model
3
+
4
+ def self.construct(model)
5
+ self.model = model
6
+ model.searchable &@_searchable if @_searchable
7
+ self
8
+ end
9
+
2
10
  def initialize(params={})
3
11
  params.each do |attr, value|
4
12
  self.public_send("#{attr}=", value)
@@ -8,18 +16,11 @@ class Seeker::Base
8
16
  end
9
17
 
10
18
  def self.model_name
11
- @_model_name ||= begin
12
- model = eval self.name.sub(/Searcher$/, '')
13
- ActiveModel::Name.new(model)
14
- end
15
- end
16
-
17
- def self.model
18
- model_name.constantize
19
+ @_model_name ||= ActiveModel::Name.new model
19
20
  end
20
21
 
21
22
  def self.searchable(&block)
22
- self.model.searchable &block
23
+ @_searchable = block
23
24
  end
24
25
 
25
26
  # Searcher needs to implement it
@@ -1,10 +1,15 @@
1
1
  require 'seeker/form_helper'
2
2
  require 'seeker/route_helper'
3
+ require 'seeker/searcher_mounter'
3
4
 
4
5
  module Seeker
5
6
  class Railtie < Rails::Railtie
6
7
  initializer 'seeker.form_helper' do
7
8
  ActionView::Base.send :include, FormHelper
8
9
  end
10
+
11
+ initializer 'seeker.searcher_mounter' do
12
+ ActiveRecord::Base.send :extend, SearcherMounter
13
+ end
9
14
  end
10
15
  end
@@ -0,0 +1,9 @@
1
+ module SearcherMounter
2
+ def mount_searcher(searcher)
3
+ @_searcher = searcher.construct self
4
+ end
5
+
6
+ def searcher(attributes = {})
7
+ @_searcher.new attributes
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Seeker
2
- VERSION = "0.0.1"
2
+ VERSION = '0.2.0'
3
3
  end
data/seeker.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["szymon@estender.net"]
11
11
  spec.description = %q{This Ruby on Rails gem provides an elegant way to separate search logic out of models.}
12
12
  spec.summary = %q{It separates search indecies setup and search rules to searchers. They also may be used in form helpers just like models.}
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/szymon-przybyl/seeker"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seeker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Szymon Przybył
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-17 00:00:00.000000000 Z
11
+ date: 2013-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,14 +28,14 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: This Ruby on Rails gem provides an elegant way to separate search logic
@@ -57,9 +57,10 @@ files:
57
57
  - lib/seeker/form_helper.rb
58
58
  - lib/seeker/railtie.rb
59
59
  - lib/seeker/route_helper.rb
60
+ - lib/seeker/searcher_mounter.rb
60
61
  - lib/seeker/version.rb
61
62
  - seeker.gemspec
62
- homepage: ''
63
+ homepage: https://github.com/szymon-przybyl/seeker
63
64
  licenses:
64
65
  - MIT
65
66
  metadata: {}
@@ -69,17 +70,17 @@ require_paths:
69
70
  - lib
70
71
  required_ruby_version: !ruby/object:Gem::Requirement
71
72
  requirements:
72
- - - '>='
73
+ - - ! '>='
73
74
  - !ruby/object:Gem::Version
74
75
  version: '0'
75
76
  required_rubygems_version: !ruby/object:Gem::Requirement
76
77
  requirements:
77
- - - '>='
78
+ - - ! '>='
78
79
  - !ruby/object:Gem::Version
79
80
  version: '0'
80
81
  requirements: []
81
82
  rubyforge_project:
82
- rubygems_version: 2.0.3
83
+ rubygems_version: 2.0.5
83
84
  signing_key:
84
85
  specification_version: 4
85
86
  summary: It separates search indecies setup and search rules to searchers. They also