supplejack_client 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/supplejack/config.rb +4 -1
- data/lib/supplejack/controllers/helpers.rb +0 -44
- data/lib/supplejack/search.rb +3 -3
- data/lib/supplejack/version.rb +1 -1
- data/spec/supplejack/search_spec.rb +7 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 950c231c1f7bf0f55b66622babdf1524376b02da
|
4
|
+
data.tar.gz: 497695e5a2d9ba4a8bc4fa690a9291eb328d9625
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31e663f7fcd4154e2d0bb71cfd4a076dcddc9ed426f61beb68cbf901f6272f3a65c47b06c442ada1805fbf73b5378f8784fcaa87d619484d6bdb622357e2cb70
|
7
|
+
data.tar.gz: fbc71a0fbcbb7c1421c71a19ab0d41a0fb40d73abf476dd288fa659b4026ff29e023fe791d1da6e99cd4ced6775e70120c3d6cbc6111d70b376405b01c3bbcad
|
data/lib/supplejack/config.rb
CHANGED
@@ -30,9 +30,10 @@ module Supplejack
|
|
30
30
|
PAGINATION_LIMIT = nil
|
31
31
|
TIMEOUT = 30
|
32
32
|
RECORD_KLASS = 'Record'
|
33
|
+
CURRENT_USER_METHOD = :current_user
|
33
34
|
SEARCH_KLASS = nil
|
34
35
|
FIELDS = [:default]
|
35
|
-
SUPPLEJACK_FIELDS
|
36
|
+
SUPPLEJACK_FIELDS = []
|
36
37
|
ADMIN_FIELDS = []
|
37
38
|
ENABLE_DEBUGGING = false
|
38
39
|
ENABLE_CACHING = false
|
@@ -53,6 +54,7 @@ module Supplejack
|
|
53
54
|
:pagination_limit,
|
54
55
|
:timeout,
|
55
56
|
:record_klass,
|
57
|
+
:current_user_method,
|
56
58
|
:search_klass,
|
57
59
|
:fields,
|
58
60
|
:supplejack_fields,
|
@@ -101,6 +103,7 @@ module Supplejack
|
|
101
103
|
self.pagination_limit = PAGINATION_LIMIT
|
102
104
|
self.timeout = TIMEOUT
|
103
105
|
self.record_klass = RECORD_KLASS
|
106
|
+
self.current_user_method = CURRENT_USER_METHOD
|
104
107
|
self.search_klass = SEARCH_KLASS
|
105
108
|
self.fields = FIELDS
|
106
109
|
self.supplejack_fields = SUPPLEJACK_FIELDS
|
@@ -113,50 +113,6 @@ module Supplejack
|
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
116
|
-
# Displays the next and/or previous links based on the record and current search
|
117
|
-
#
|
118
|
-
# @params [ Dnz::Record ] The record object which has information about the next/previous record and pages.
|
119
|
-
# @params [ Hash ] options Hash of options to customize the output,
|
120
|
-
# supported options: :prev_class, :next_class, :prev_label, :next_label
|
121
|
-
#
|
122
|
-
# @option options [ String ] :prev_class The CSS class to use on the previous button
|
123
|
-
# @option options [ String ] :next_class The CSS class to use on the next button
|
124
|
-
# @option options [ String ] :wrapper_class The CSS class to use on the wrapping span
|
125
|
-
# @option options [ String ] :prev_label Any HTML to be put inside the previous button
|
126
|
-
# @option options [ String ] :next_label Any HTML to be put inside the next button
|
127
|
-
#
|
128
|
-
def next_previous_links(record, html_options={})
|
129
|
-
html_options.reverse_merge!({prev_class: "prev", next_class: "next", wrapper_class: 'nav', prev_label: nil, next_label: nil})
|
130
|
-
|
131
|
-
return "" unless params[:search]
|
132
|
-
links = "".html_safe
|
133
|
-
|
134
|
-
options = search.options
|
135
|
-
|
136
|
-
previous_label = html_options[:prev_label] ||= t('supplejack_client.previous', default: "Previous")
|
137
|
-
next_label = html_options[:next_label] ||= t('supplejack_client.next', default: "Next")
|
138
|
-
previous_label = previous_label.html_safe
|
139
|
-
next_label = next_label.html_safe
|
140
|
-
|
141
|
-
options[:path] = params[:search][:path].gsub(/(\W|\d)/, '') if params[:search] && params[:search][:path]
|
142
|
-
|
143
|
-
if record.previous_record
|
144
|
-
options[:page] = record.previous_page if record.previous_page.to_i > 1
|
145
|
-
links += link_to(raw(previous_label), record_path(record.previous_record, search: options), class: html_options[:prev_class]).html_safe
|
146
|
-
else
|
147
|
-
links += content_tag(:span, previous_label, class: html_options[:prev_class])
|
148
|
-
end
|
149
|
-
|
150
|
-
if record.next_record
|
151
|
-
options[:page] = record.next_page if record.next_page.to_i > 1
|
152
|
-
links += link_to(raw(next_label), record_path(record.next_record, search: options), class: html_options[:next_class]).html_safe
|
153
|
-
else
|
154
|
-
links += content_tag(:span, next_label, class: html_options[:next_class])
|
155
|
-
end
|
156
|
-
|
157
|
-
content_tag(:span, links, class: html_options[:wrapper_class])
|
158
|
-
end
|
159
|
-
|
160
116
|
def attribute_link_replacement(value, link_pattern)
|
161
117
|
if link_pattern.is_a?(String)
|
162
118
|
link_pattern = URI.decode(link_pattern)
|
data/lib/supplejack/search.rb
CHANGED
@@ -217,9 +217,9 @@ module Supplejack
|
|
217
217
|
#
|
218
218
|
# @return [Hash{String => Integer}] A hash of type names and counts
|
219
219
|
#
|
220
|
-
def
|
221
|
-
return @
|
222
|
-
@
|
220
|
+
def types(options={})
|
221
|
+
return @types if @types
|
222
|
+
@types = facet_values('type', options)
|
223
223
|
end
|
224
224
|
|
225
225
|
# Gets the facet values unrestricted by the current filter
|
data/lib/supplejack/version.rb
CHANGED
@@ -533,7 +533,7 @@ module Supplejack
|
|
533
533
|
end
|
534
534
|
end
|
535
535
|
|
536
|
-
describe '#
|
536
|
+
describe '#types' do
|
537
537
|
before(:each) do
|
538
538
|
@search = Search.new({:i => {:category => 'Books', :year => 2001}, :text => 'Dogs'})
|
539
539
|
@search.stub(:get) { {'search' => {'facets' => {'category' => {'Books' => 123}}, 'result_count' => 123}} }
|
@@ -541,30 +541,30 @@ module Supplejack
|
|
541
541
|
|
542
542
|
it 'should call the fetch_values method' do
|
543
543
|
@search.should_receive(:facet_values).with('category', {})
|
544
|
-
@search.
|
544
|
+
@search.types
|
545
545
|
end
|
546
546
|
|
547
547
|
it 'removes category filter from the search request' do
|
548
548
|
@search.should_receive(:get).with('/records', hash_including(:and => {:year => 2001})).and_return({'search' => {'facets' => {'category' => {'Books' => 123}}}})
|
549
|
-
@search.
|
549
|
+
@search.types
|
550
550
|
end
|
551
551
|
|
552
552
|
it 'returns the category facet hash ' do
|
553
|
-
@search.
|
553
|
+
@search.types.should include('Books' => 123)
|
554
554
|
end
|
555
555
|
|
556
556
|
it 'asks the API for 0 results' do
|
557
557
|
@search.should_receive(:get).with('/records', hash_including({:per_page => 0}))
|
558
|
-
@search.
|
558
|
+
@search.types
|
559
559
|
end
|
560
560
|
|
561
561
|
it 'should return add the All count to the hash' do
|
562
|
-
@search.
|
562
|
+
@search.types['All'].should eq 123
|
563
563
|
end
|
564
564
|
|
565
565
|
it 'orders the category values by :count' do
|
566
566
|
@search.should_receive(:facet_values).with('category', {:sort => :count})
|
567
|
-
@search.
|
567
|
+
@search.types({:sort => :count})
|
568
568
|
end
|
569
569
|
end
|
570
570
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: supplejack_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Supplejack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|