searchlight 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NGRhMjI1Mjg1ZDRmYTA5Yjc1YTk1ZWVkZWY5M2VhNjQ2YmQ0YzRhYQ==
4
+ NGM3YWIxODBiNTM5MmM4NDJkNjk4Mzk3MmU5MGIwMzg4M2JlM2E2ZA==
5
5
  data.tar.gz: !binary |-
6
- NTU2MjMxYTdmY2YwNTYxZDY4YzU0NTY2ZjczNGRjMjlmNTM3MWFiZg==
6
+ Njc0ZDYxZjFkZWZmNDE2ZTJjNzY2Y2QzNjJjMTJiYjkwODZmODhiZA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OWE1NWE0ZDc3N2MyMGJiNzZmY2MwNGYzMzg4NWVmNjY4MWQyYzY5ZGEzZmQz
10
- YjIwYmE4ZGJkZDhkNzhkNmM0MDNhODBiMzRhMTVjODY1MjM2NjJkMzhkNzZi
11
- ODVmZDMyMGQ2N2Q1YWEwMDVlOTI0Zjg5YjBmYjYzZjZjOTU2M2U=
9
+ OGM2NjZmNTc2OTI3MjdkMmNlNTcwNzE2Mjk5Mzk3YmIzMzVmMjNjYTVmMGFi
10
+ ODhkYjQ2ZmNiNzJlNDNlYzhlOTVjMDIxN2M5ZGE4NDU5ZGI4NmYyN2JjMzI2
11
+ NWFmYWI0NDYwOTg4YjI1ZjhkOTJiNmQyNzkzNDRkMzc2ZjM2MjM=
12
12
  data.tar.gz: !binary |-
13
- YmNhN2M0M2VjMmM0MTZmMjBmOTI1ODJlMzE0NWI0YTVhZDA2ZDIzYWY0NTYx
14
- YjFhM2QxMGZmZGY3MTFkNzg0NWY0YmMzN2MxMTViMjlmMWQyMTRiYjEzZTAy
15
- MjMyZTY5YjRjYWM1NjI2ZTE0MjNmN2UyMWM2MDVmNzliMmMyMDU=
13
+ M2JiOGE2ODJiNjhlOTM0NDBiNGVkZDBlZDE5MDNiMDRjMGRjOTQ5MzViZmM4
14
+ YWZiOTVkNDFmZTdiZmRkMTM1ZjE3MGM2ZjBlMzFlMGE2ODM3NGM0OTBiN2I0
15
+ NDFlOTE0NzM3MjJkOGFiYmY5ZDFkMzBmNTdkNzcyZmE5M2U5YTE=
@@ -2,6 +2,17 @@
2
2
 
3
3
  Searchlight does its best to use [semantic versioning](http://semver.org).
4
4
 
5
+ ## v0.9.1
6
+
7
+ Bugfix for ActiveRecord adapter
8
+
9
+ ## v0.9.0
10
+
11
+ - Clean up dynamic module inclusion
12
+ - Better `ActionView` and `ActiveRecord` adapters
13
+ - Better error messages
14
+ - More documentation
15
+
5
16
  ## v0.0.1
6
17
 
7
18
  Experimental and unstable, Searchlight totters onto the scene and takes its first wide-eyed look at the world.
data/TODO.md CHANGED
@@ -3,3 +3,4 @@
3
3
  - Run rcov and mutant
4
4
  - Make nice Github page
5
5
  - Test with ActiveRecord 4
6
+ - Add more complex example searches to show where Searchlight shines. Eg: for a given disease, find people who've traveled in a given time period and visited countries that had an outbreak of that disease during their visit.
@@ -4,7 +4,10 @@ module Searchlight
4
4
 
5
5
  def search_on(target)
6
6
  super
7
- extend Search if target.is_a?(::ActiveRecord::Base) || target.is_a?(::ActiveRecord::Relation)
7
+ if target.is_a?(Class) && target.ancestors.include?(::ActiveRecord::Base) ||
8
+ target.is_a?(::ActiveRecord::Relation)
9
+ extend Search
10
+ end
8
11
  end
9
12
 
10
13
  module Search
@@ -1,3 +1,3 @@
1
1
  module Searchlight
2
- VERSION = "0.9.0"
2
+ VERSION = "0.9.1"
3
3
  end
@@ -7,29 +7,49 @@ describe 'Searchlight::Adapters::ActiveRecord', adapter: true do
7
7
  require 'active_record'
8
8
  end
9
9
 
10
- let(:search_class) { Named::Class.new('SearchClass', Searchlight::Search) { search_on MockActiveRecord } }
10
+ let(:search_class) { Named::Class.new('SearchClass', Searchlight::Search).tap { |klass| klass.search_on target } }
11
11
  let(:search_instance) { search_class.new(elephants: 'yes, please') }
12
12
 
13
13
  before :each do
14
14
  search_class.searches :elephants
15
15
  end
16
16
 
17
- it "adds search methods to the search class" do
18
- expect(search_class.new).to respond_to(:search_elephants)
19
- end
17
+ shared_examples "search classes with an ActiveRecord target" do
18
+
19
+ it "adds search methods to the search class" do
20
+ expect(search_class.new).to respond_to(:search_elephants)
21
+ end
22
+
23
+ it "adds search_elephants to the search_methods array" do
24
+ expect(search_instance.send(:search_methods)).to include('search_elephants')
25
+ end
26
+
27
+ it "defines search methods that call where on the search target" do
28
+ search_instance.results
29
+ expect(search_instance.search.called_methods).to eq([:where])
30
+ end
31
+
32
+ it "sets arguments properly in the defined method" do
33
+ search_instance.search.should_receive(:where).with('elephants' => 'yes, please')
34
+ search_instance.search_elephants
35
+ end
20
36
 
21
- it "adds search_elephants to the search_methods array" do
22
- expect(search_instance.send(:search_methods)).to include('search_elephants')
23
37
  end
24
38
 
25
- it "defines search methods that call where on the search target" do
26
- search_instance.results
27
- expect(search_instance.search.called_methods).to eq([:where])
39
+ context "when the search target is an ActiveRecord class" do
40
+
41
+ let(:target) { MockActiveRecord }
42
+
43
+ it_behaves_like "search classes with an ActiveRecord target"
44
+
28
45
  end
29
46
 
30
- it "sets arguments properly in the defined method" do
31
- search_instance.search.should_receive(:where).with('elephants' => 'yes, please')
32
- search_instance.search_elephants
47
+ context "when the search target is an ActiveRecord class" do
48
+
49
+ let(:target) { MockActiveRecord.joins(:dudes_named_milford).tap { |r| r.called_methods.clear } }
50
+
51
+ it_behaves_like "search classes with an ActiveRecord target"
52
+
33
53
  end
34
54
 
35
55
  end
@@ -8,8 +8,12 @@ end
8
8
 
9
9
  class MockActiveRecord < MockModel
10
10
 
11
+ def self.ancestors
12
+ super + [::ActiveRecord::Base]
13
+ end
14
+
11
15
  def self.is_a?(thing)
12
- thing == ActiveRecord::Base ? true : super
16
+ thing == ::ActiveRecord::Base ? true : super
13
17
  end
14
18
 
15
19
  end
@@ -24,4 +28,10 @@ class MockRelation
24
28
  def method_missing(method, *args, &block)
25
29
  tap { called_methods << method }
26
30
  end
31
+
32
+ def is_a?(thing)
33
+ thing == ::ActiveRecord::Relation ? true : super
34
+ end
35
+
27
36
  end
37
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: searchlight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Long
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-18 00:00:00.000000000 Z
12
+ date: 2013-04-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: named