ansr 0.0.3 → 0.0.4
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 +8 -8
- data/ansr_blacklight/ansr_blacklight.gemspec +2 -1
- data/ansr_blacklight/lib/ansr_blacklight/relation.rb +9 -0
- data/ansr_blacklight/spec/lib/loaded_relation_spec.rb +11 -11
- data/ansr_blacklight/spec/lib/queryable_relation_spec.rb +0 -1
- data/ansr_blacklight/spec/lib/relation/grouping_spec.rb +5 -3
- data/ansr_dpla/Gemfile.lock +37 -38
- data/ansr_dpla/lib/ansr_dpla/relation.rb +2 -3
- data/ansr_dpla/spec/lib/relation/facet_spec.rb +2 -2
- data/lib/ansr/arel/big_table.rb +5 -1
- data/lib/ansr/relation.rb +10 -2
- data/lib/ansr/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZTlkMGM1Njk2MWE1ZTFhOTVjMWRkZDE5NjZiYjFkNDE5YTM0ZDAyYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MWFjZTYxMTg3Y2I0NGM1MTQ0MzI0YjkxZjIxNjI5YmU4MTlkZTk2MQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NWM2NGM0ZjgwYzZkNzYyY2ZhOTE2OTA3YmI1ZjMyNGZjZmJhMzE1YWYxYzlj
|
10
|
+
ZGQyZjMwNWNlY2RiOWE4MmI0MmZiZjI0Mzk0Mjg0MTE1MWE2ZWU0Y2I1ZGUw
|
11
|
+
MjMyMTNhMzYxOWU2Yzg5ZGU5ZWUwNzE3NWYzYTI1ZTY1NjQ4NzI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTU1MGNkZGNjZDZkZjRhNzlhMjI0ZjA4MWM5ZTI4NDQ2OTlkM2Y2OTBjN2Jl
|
14
|
+
Y2ZhNDFlZjE2OTMzYTA5YTgwZmM1YzA0YmQ2NDlhMjdhZWQ1YjIzMGRjNjJi
|
15
|
+
MWZlYjNiZDQ3MzE2ZDU1OGQyODMzYTVmOTNjY2E1NDk1ZDg5NTk=
|
@@ -19,7 +19,8 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.add_dependency 'rest-client'
|
20
20
|
spec.add_dependency 'loggable'
|
21
21
|
spec.add_dependency "rails", ">= 3.2.6", "< 5"
|
22
|
-
|
22
|
+
spec.add_dependency "rsolr", "~> 1.0.6" # Library for interacting with rSolr.
|
23
|
+
spec.add_dependency "kaminari", "~> 0.13" # the pagination (page 1,2,3, etc..) of our search results
|
23
24
|
spec.add_dependency 'sass-rails'
|
24
25
|
spec.add_development_dependency("rake")
|
25
26
|
spec.add_development_dependency("bundler", ">= 1.0.14")
|
@@ -46,5 +46,14 @@ module Ansr::Blacklight
|
|
46
46
|
end
|
47
47
|
arel
|
48
48
|
end
|
49
|
+
|
50
|
+
def grouped?
|
51
|
+
loaded? ? response.grouped? : !group_values.blank?
|
52
|
+
end
|
53
|
+
|
54
|
+
def group_by(key=self.group_values.first)
|
55
|
+
loaded
|
56
|
+
response.grouped(model()).select { |x| x.key == key.to_s }
|
57
|
+
end
|
49
58
|
end
|
50
59
|
end
|
@@ -4,7 +4,7 @@ describe Ansr::Blacklight::Relation do
|
|
4
4
|
|
5
5
|
def create_response
|
6
6
|
raw_response = eval(mock_query_response)
|
7
|
-
Blacklight::
|
7
|
+
Ansr::Blacklight::Solr::Response.new(raw_response, raw_response['params'])
|
8
8
|
end
|
9
9
|
|
10
10
|
def stub_solr
|
@@ -133,64 +133,64 @@ describe Ansr::Blacklight::Relation do
|
|
133
133
|
it 'should provide the responseHeader params' do
|
134
134
|
raw_response = eval(mock_query_response)
|
135
135
|
raw_response['responseHeader']['params']['test'] = :test
|
136
|
-
r = Blacklight::
|
136
|
+
r = Ansr::Blacklight::Solr::Response.new(raw_response, raw_response['params'])
|
137
137
|
r.params['test'].should == :test
|
138
138
|
end
|
139
139
|
|
140
140
|
it 'should provide the solr-returned params and "rows" should be 11' do
|
141
141
|
raw_response = eval(mock_query_response)
|
142
|
-
r = Blacklight::
|
142
|
+
r = Ansr::Blacklight::Solr::Response.new(raw_response, {})
|
143
143
|
r.params[:rows].to_s.should == '11'
|
144
144
|
end
|
145
145
|
|
146
146
|
it 'should provide the ruby request params if responseHeader["params"] does not exist' do
|
147
147
|
raw_response = eval(mock_query_response)
|
148
148
|
raw_response.delete 'responseHeader'
|
149
|
-
r = Blacklight::
|
149
|
+
r = Ansr::Blacklight::Solr::Response.new(raw_response, :rows => 999)
|
150
150
|
r.params[:rows].to_s.should == '999'
|
151
151
|
end
|
152
152
|
|
153
153
|
it 'should provide spelling suggestions for regular spellcheck results' do
|
154
154
|
raw_response = eval(mock_response_with_spellcheck)
|
155
|
-
r = Blacklight::
|
155
|
+
r = Ansr::Blacklight::Solr::Response.new(raw_response, {})
|
156
156
|
r.spelling.words.should include("dell")
|
157
157
|
r.spelling.words.should include("ultrasharp")
|
158
158
|
end
|
159
159
|
|
160
160
|
it 'should provide spelling suggestions for extended spellcheck results' do
|
161
161
|
raw_response = eval(mock_response_with_spellcheck_extended)
|
162
|
-
r = Blacklight::
|
162
|
+
r = Ansr::Blacklight::Solr::Response.new(raw_response, {})
|
163
163
|
r.spelling.words.should include("dell")
|
164
164
|
r.spelling.words.should include("ultrasharp")
|
165
165
|
end
|
166
166
|
|
167
167
|
it 'should provide no spelling suggestions when extended results and suggestion frequency is the same as original query frequency' do
|
168
168
|
raw_response = eval(mock_response_with_spellcheck_same_frequency)
|
169
|
-
r = Blacklight::
|
169
|
+
r = Ansr::Blacklight::Solr::Response.new(raw_response, {})
|
170
170
|
r.spelling.words.should == []
|
171
171
|
end
|
172
172
|
|
173
173
|
it 'should provide spelling suggestions for a regular spellcheck results with a collation' do
|
174
174
|
raw_response = eval(mock_response_with_spellcheck_collation)
|
175
|
-
r = Blacklight::
|
175
|
+
r = Ansr::Blacklight::Solr::Response.new(raw_response, {})
|
176
176
|
r.spelling.words.should include("dell")
|
177
177
|
r.spelling.words.should include("ultrasharp")
|
178
178
|
end
|
179
179
|
|
180
180
|
it 'should provide spelling suggestion collation' do
|
181
181
|
raw_response = eval(mock_response_with_spellcheck_collation)
|
182
|
-
r = Blacklight::
|
182
|
+
r = Ansr::Blacklight::Solr::Response.new(raw_response, {})
|
183
183
|
r.spelling.collation.should == 'dell ultrasharp'
|
184
184
|
end
|
185
185
|
|
186
186
|
it "should provide MoreLikeThis suggestions" do
|
187
187
|
raw_response = eval(mock_response_with_more_like_this)
|
188
|
-
r = Blacklight::
|
188
|
+
r = Ansr::Blacklight::Solr::Response.new(raw_response, {})
|
189
189
|
r.more_like(double(:id => '79930185')).should have(2).items
|
190
190
|
end
|
191
191
|
|
192
192
|
it "should be empty when the response has no results" do
|
193
|
-
r = Blacklight::
|
193
|
+
r = Ansr::Blacklight::Solr::Response.new({}, {})
|
194
194
|
r.stub(:total => 0)
|
195
195
|
expect(r).to be_empty
|
196
196
|
end
|
@@ -106,7 +106,6 @@ describe Ansr::Blacklight::Relation do
|
|
106
106
|
let(:visitor) { @visitor }
|
107
107
|
|
108
108
|
it "should accept valid parameters" do
|
109
|
-
config = Blacklight::Configuration.new
|
110
109
|
query = visitor.accept subject.build_arel.ast
|
111
110
|
expect(query.path).to eq('outside')
|
112
111
|
expect(query.to_hash).to eq({"defType" => "had",
|
@@ -26,7 +26,7 @@ describe Ansr::Blacklight do
|
|
26
26
|
|
27
27
|
before do
|
28
28
|
Object.const_set('GroupModel', Class.new(TestModel))
|
29
|
-
GroupModel.solr = stub_solr(sample_response)
|
29
|
+
GroupModel.solr = stub_solr(sample_response.to_s)
|
30
30
|
GroupModel.configure do |config|
|
31
31
|
config[:table_class] = TestTable
|
32
32
|
end
|
@@ -37,11 +37,13 @@ describe Ansr::Blacklight do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
let(:response) do
|
40
|
-
|
40
|
+
rel = GroupModel.group("result_group_ssi")
|
41
|
+
rel.load
|
42
|
+
rel
|
41
43
|
end
|
42
44
|
|
43
45
|
let(:group) do
|
44
|
-
response.
|
46
|
+
response.group_by.first
|
45
47
|
end
|
46
48
|
|
47
49
|
subject do
|
data/ansr_dpla/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ansr_dpla (0.0.
|
5
|
-
ansr (= 0.0.
|
4
|
+
ansr_dpla (0.0.3)
|
5
|
+
ansr (= 0.0.3)
|
6
6
|
blacklight (>= 5.1.0)
|
7
7
|
json-ld
|
8
8
|
loggable
|
@@ -12,43 +12,43 @@ PATH
|
|
12
12
|
GEM
|
13
13
|
remote: http://rubygems.org/
|
14
14
|
specs:
|
15
|
-
actionmailer (4.0.
|
16
|
-
actionpack (= 4.0.
|
15
|
+
actionmailer (4.0.4)
|
16
|
+
actionpack (= 4.0.4)
|
17
17
|
mail (~> 2.5.4)
|
18
|
-
actionpack (4.0.
|
19
|
-
activesupport (= 4.0.
|
18
|
+
actionpack (4.0.4)
|
19
|
+
activesupport (= 4.0.4)
|
20
20
|
builder (~> 3.1.0)
|
21
21
|
erubis (~> 2.7.0)
|
22
22
|
rack (~> 1.5.2)
|
23
23
|
rack-test (~> 0.6.2)
|
24
|
-
activemodel (4.0.
|
25
|
-
activesupport (= 4.0.
|
24
|
+
activemodel (4.0.4)
|
25
|
+
activesupport (= 4.0.4)
|
26
26
|
builder (~> 3.1.0)
|
27
|
-
activerecord (4.0.
|
28
|
-
activemodel (= 4.0.
|
27
|
+
activerecord (4.0.4)
|
28
|
+
activemodel (= 4.0.4)
|
29
29
|
activerecord-deprecated_finders (~> 1.0.2)
|
30
|
-
activesupport (= 4.0.
|
30
|
+
activesupport (= 4.0.4)
|
31
31
|
arel (~> 4.0.0)
|
32
32
|
activerecord-deprecated_finders (1.0.3)
|
33
|
-
activesupport (4.0.
|
34
|
-
i18n (~> 0.6, >= 0.6.
|
33
|
+
activesupport (4.0.4)
|
34
|
+
i18n (~> 0.6, >= 0.6.9)
|
35
35
|
minitest (~> 4.2)
|
36
36
|
multi_json (~> 1.3)
|
37
37
|
thread_safe (~> 0.1)
|
38
38
|
tzinfo (~> 0.3.37)
|
39
|
-
ansr (0.0.
|
40
|
-
|
39
|
+
ansr (0.0.3)
|
40
|
+
activerecord
|
41
|
+
arel
|
41
42
|
loggable
|
42
43
|
arel (4.0.2)
|
43
|
-
|
44
|
-
blacklight (5.2.0)
|
44
|
+
blacklight (5.3.0)
|
45
45
|
bootstrap-sass (~> 3.0)
|
46
46
|
deprecation
|
47
47
|
kaminari (~> 0.13)
|
48
48
|
nokogiri (~> 1.6)
|
49
49
|
rails (>= 3.2.6, < 5)
|
50
50
|
rsolr (~> 1.0.6)
|
51
|
-
bootstrap-sass (3.1.1.
|
51
|
+
bootstrap-sass (3.1.1.1)
|
52
52
|
sass (~> 3.2)
|
53
53
|
builder (3.1.4)
|
54
54
|
deprecation (0.1.0)
|
@@ -57,8 +57,8 @@ GEM
|
|
57
57
|
erubis (2.7.0)
|
58
58
|
hike (1.2.3)
|
59
59
|
i18n (0.6.9)
|
60
|
-
json-ld (1.1.1)
|
61
|
-
rdf (
|
60
|
+
json-ld (1.1.3.1)
|
61
|
+
rdf (~> 1.1)
|
62
62
|
kaminari (0.15.1)
|
63
63
|
actionpack (>= 3.0.0)
|
64
64
|
activesupport (>= 3.0.0)
|
@@ -67,33 +67,33 @@ GEM
|
|
67
67
|
mime-types (~> 1.16)
|
68
68
|
treetop (~> 1.4.8)
|
69
69
|
mime-types (1.25.1)
|
70
|
-
mini_portile (0.5.
|
70
|
+
mini_portile (0.5.3)
|
71
71
|
minitest (4.7.5)
|
72
|
-
multi_json (1.9.
|
72
|
+
multi_json (1.9.2)
|
73
73
|
nokogiri (1.6.1)
|
74
74
|
mini_portile (~> 0.5.0)
|
75
75
|
polyglot (0.3.4)
|
76
76
|
rack (1.5.2)
|
77
77
|
rack-test (0.6.2)
|
78
78
|
rack (>= 1.0)
|
79
|
-
rails (4.0.
|
80
|
-
actionmailer (= 4.0.
|
81
|
-
actionpack (= 4.0.
|
82
|
-
activerecord (= 4.0.
|
83
|
-
activesupport (= 4.0.
|
79
|
+
rails (4.0.4)
|
80
|
+
actionmailer (= 4.0.4)
|
81
|
+
actionpack (= 4.0.4)
|
82
|
+
activerecord (= 4.0.4)
|
83
|
+
activesupport (= 4.0.4)
|
84
84
|
bundler (>= 1.3.0, < 2.0)
|
85
|
-
railties (= 4.0.
|
85
|
+
railties (= 4.0.4)
|
86
86
|
sprockets-rails (~> 2.0.0)
|
87
|
-
railties (4.0.
|
88
|
-
actionpack (= 4.0.
|
89
|
-
activesupport (= 4.0.
|
87
|
+
railties (4.0.4)
|
88
|
+
actionpack (= 4.0.4)
|
89
|
+
activesupport (= 4.0.4)
|
90
90
|
rake (>= 0.8.7)
|
91
91
|
thor (>= 0.18.1, < 2.0)
|
92
92
|
rake (10.1.1)
|
93
|
-
rdf (1.1.
|
93
|
+
rdf (1.1.3)
|
94
94
|
rest-client (1.6.7)
|
95
95
|
mime-types (>= 1.16)
|
96
|
-
rsolr (1.0.
|
96
|
+
rsolr (1.0.10)
|
97
97
|
builder (>= 2.1.2)
|
98
98
|
rspec (2.14.1)
|
99
99
|
rspec-core (~> 2.14.0)
|
@@ -103,12 +103,12 @@ GEM
|
|
103
103
|
rspec-expectations (2.14.5)
|
104
104
|
diff-lcs (>= 1.1.3, < 2.0)
|
105
105
|
rspec-mocks (2.14.6)
|
106
|
-
sass (3.3.
|
106
|
+
sass (3.3.5)
|
107
107
|
sass-rails (4.0.1)
|
108
108
|
railties (>= 4.0.0, < 5.0)
|
109
109
|
sass (>= 3.1.10)
|
110
110
|
sprockets-rails (~> 2.0.0)
|
111
|
-
sprockets (2.12.
|
111
|
+
sprockets (2.12.1)
|
112
112
|
hike (~> 1.2)
|
113
113
|
multi_json (~> 1.0)
|
114
114
|
rack (~> 1.0)
|
@@ -117,9 +117,8 @@ GEM
|
|
117
117
|
actionpack (>= 3.0)
|
118
118
|
activesupport (>= 3.0)
|
119
119
|
sprockets (~> 2.8)
|
120
|
-
thor (0.
|
121
|
-
thread_safe (0.
|
122
|
-
atomic (>= 1.1.7, < 2)
|
120
|
+
thor (0.19.1)
|
121
|
+
thread_safe (0.3.3)
|
123
122
|
tilt (1.4.1)
|
124
123
|
treetop (1.4.15)
|
125
124
|
polyglot
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'yaml'
|
2
|
-
require 'blacklight'
|
3
2
|
module Ansr::Dpla
|
4
3
|
class Relation < ::Ansr::Relation
|
5
4
|
|
@@ -41,10 +40,10 @@ module Ansr::Dpla
|
|
41
40
|
|
42
41
|
if v['total'] != 0
|
43
42
|
items = v['terms'].collect do |term|
|
44
|
-
|
43
|
+
Ansr::Facets::FacetItem.new(:value => term['term'], :hits => term['count'])
|
45
44
|
end
|
46
45
|
options = {:sort => 'asc', :offset => 0}
|
47
|
-
h[k] =
|
46
|
+
h[k] = Ansr::Facets::FacetField.new k, items, options
|
48
47
|
end
|
49
48
|
h
|
50
49
|
end
|
@@ -65,7 +65,7 @@ describe Ansr::Dpla::Relation do
|
|
65
65
|
test.load
|
66
66
|
fkey = test.filters.keys.first
|
67
67
|
facet = test.filters[fkey]
|
68
|
-
expect(facet).to be_a(
|
68
|
+
expect(facet).to be_a(Ansr::Facets::FacetField)
|
69
69
|
facet.items
|
70
70
|
end
|
71
71
|
it 'should dispatch a query with no docs requested if not loaded' do
|
@@ -73,7 +73,7 @@ describe Ansr::Dpla::Relation do
|
|
73
73
|
@mock_api.should_receive(:items).with(:q => 'kittens', :page_size=>0).once.and_return(@faceted)
|
74
74
|
fkey = test.filters.keys.first
|
75
75
|
facet = test.filters[fkey]
|
76
|
-
expect(facet).to be_a(
|
76
|
+
expect(facet).to be_a(Ansr::Facets::FacetField)
|
77
77
|
expect(test.loaded?).to be_false
|
78
78
|
test.filters # make sure we memoized the facet values
|
79
79
|
end
|
data/lib/ansr/arel/big_table.rb
CHANGED
@@ -27,7 +27,11 @@ module Ansr
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def primary_key
|
30
|
-
@primary_key ||= self.class.primary_key
|
30
|
+
@primary_key ||= ::Arel::Attribute.new( self, self.class.primary_key )
|
31
|
+
end
|
32
|
+
|
33
|
+
def primary_key=(key)
|
34
|
+
@primary_key = ::Arel::Attribute.new( self, key.to_s )
|
31
35
|
end
|
32
36
|
|
33
37
|
def [] name
|
data/lib/ansr/relation.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'yaml'
|
2
|
-
require '
|
2
|
+
require 'kaminari'
|
3
3
|
module Ansr
|
4
4
|
class Relation < ::ActiveRecord::Relation
|
5
5
|
attr_reader :response
|
@@ -9,7 +9,7 @@ module Ansr
|
|
9
9
|
|
10
10
|
include Sanitization::ClassMethods
|
11
11
|
include QueryMethods
|
12
|
-
include Kaminari::PageScopeMethods
|
12
|
+
include ::Kaminari::PageScopeMethods
|
13
13
|
alias :total_count :count
|
14
14
|
|
15
15
|
def initialize(klass, table, values = {})
|
@@ -98,6 +98,14 @@ module Ansr
|
|
98
98
|
s
|
99
99
|
end
|
100
100
|
|
101
|
+
def grouped?
|
102
|
+
false
|
103
|
+
end
|
104
|
+
|
105
|
+
def group_by(key=self.group_values.first)
|
106
|
+
[]
|
107
|
+
end
|
108
|
+
|
101
109
|
private
|
102
110
|
|
103
111
|
# override to prevent default selection of all fields
|
data/lib/ansr/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ansr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Armintor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: loggable
|