CloudSesame 0.6.5 → 0.6.6

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,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 113fa988a5f56af84b938e9e6f2be6205e21498f
4
- data.tar.gz: 8749217be498c2d118741d82fdc7df12f054094c
3
+ metadata.gz: abce83b940d11489cc9207132fa660a000a0b015
4
+ data.tar.gz: 2118d371495f9053784308ace4aa407c9f79ce60
5
5
  SHA512:
6
- metadata.gz: bfef37d940b85c67e6053090ac778fcca59e1a621be72b6a656833c4f58f7557203b8762d97d38ef2b681a9bbc90b6214664e4b974013785f6aa2b49dee125e3
7
- data.tar.gz: e638257ead3937c1eff555a4cdae928db092b91552c7d755537bbf281a177f07d856430eb9ed3eda87fef57f5690baf1b9571101eaab18f96c96a4e804601654
6
+ metadata.gz: 934e078e5ba9f79ffd3b8119ade826f0837c59ef03aeb63ed16b1f906d174adc40cd6529745c92c391b228f24f307ca7b491bff2a8c65d04b656d242960e128e
7
+ data.tar.gz: 8e894da3fda36c571a95f2e746c74737b3c1c4bf53e9905e4c761919f73ad5a202b5829a156cfa45115cfa7ece5dd4b96b3749486965d0ec8ad1ff8fa4f8de8b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- CloudSesame (0.6.5)
4
+ CloudSesame (0.6.6)
5
5
  aws-sdk (~> 2)
6
6
 
7
7
  GEM
data/cloud_sesame.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'CloudSesame'
3
- s.version = '0.6.5'
3
+ s.version = '0.6.6'
4
4
  s.date = '2016-02-16'
5
5
  s.summary = "AWS CloudSearch Query DSL"
6
6
  s.description = "AWS CloudSearch Query DSL"
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "result": {
3
- "covered_percent": 85.83
3
+ "covered_percent": 85.85
4
4
  }
5
5
  }
@@ -1655,7 +1655,7 @@
1655
1655
  1,
1656
1656
  null,
1657
1657
  1,
1658
- 11,
1658
+ 17,
1659
1659
  null,
1660
1660
  null,
1661
1661
  1,
@@ -2331,6 +2331,10 @@
2331
2331
  null,
2332
2332
  null,
2333
2333
  1,
2334
+ 1,
2335
+ null,
2336
+ null,
2337
+ 1,
2334
2338
  null,
2335
2339
  1,
2336
2340
  1,
@@ -2418,6 +2422,6 @@
2418
2422
  null
2419
2423
  ]
2420
2424
  },
2421
- "timestamp": 1455600857
2425
+ "timestamp": 1455637625
2422
2426
  }
2423
2427
  }
@@ -13,11 +13,11 @@ module CloudSesame
13
13
  end
14
14
 
15
15
  def executor
16
- @executor ||= Caching::NoCache.new(aws_client, @searchable)
16
+ @executor ||= Caching::NoCache.new(@searchable) { aws_client }
17
17
  end
18
18
 
19
19
  def executor=(executor)
20
- @executor = executor.new(aws_client, @searchable)
20
+ @executor = executor.new(@searchable) { aws_client }
21
21
  end
22
22
 
23
23
  private
@@ -4,9 +4,13 @@ module CloudSesame
4
4
  module Caching
5
5
  class Base
6
6
 
7
- def initialize(client, searchable)
8
- @client = client
7
+ def initialize(searchable, &lazy_client)
9
8
  @searchable = searchable
9
+ @lazy_client = lazy_client
10
+ end
11
+
12
+ def client
13
+ @client ||= @lazy_client.call
10
14
  end
11
15
 
12
16
  def fetch(_params)
@@ -16,7 +20,7 @@ module CloudSesame
16
20
  private
17
21
 
18
22
  def search(params)
19
- @client.search params
23
+ client.search params
20
24
  end
21
25
 
22
26
  end
@@ -4,7 +4,7 @@ module CloudSesame
4
4
  module Caching
5
5
  class RailsCache < Base
6
6
 
7
- def initialize(client, searchable)
7
+ def initialize(searchable, &lazy_client)
8
8
  ensure_environment_exists
9
9
  super
10
10
  end
@@ -16,7 +16,7 @@ module CloudSesame
16
16
  '|' << fuzziness.compile(query) if fuzziness
17
17
  }#{
18
18
  '|' << sloppiness.compile(query) if sloppiness
19
- }" }
19
+ }" } if query && !query.empty?
20
20
  end
21
21
 
22
22
  private
@@ -6,7 +6,7 @@ module CloudSesame
6
6
 
7
7
  class Searchable; end
8
8
 
9
- subject { Base.new({}, Searchable) }
9
+ subject { Base.new(Searchable) {} }
10
10
 
11
11
  describe 'fetch' do
12
12
  it 'should raise an error by default' do
@@ -8,7 +8,7 @@ module CloudSesame
8
8
 
9
9
  let(:client) { OpenStruct.new(search: nil) }
10
10
 
11
- subject { NoCache.new(client, Searchable) }
11
+ subject { NoCache.new(Searchable) { client } }
12
12
 
13
13
  describe 'fetch' do
14
14
  let(:params) {{}}
@@ -35,7 +35,7 @@ module CloudSesame
35
35
  # =====================================
36
36
 
37
37
  let(:client) { OpenStruct.new(search: nil) }
38
- subject { RailsCache.new(client, Searchable) }
38
+ subject { RailsCache.new(Searchable) { client } }
39
39
 
40
40
  shared_examples 'cache stored' do
41
41
  it 'should cache the result' do
@@ -50,14 +50,18 @@ module CloudSesame
50
50
 
51
51
  describe 'executor getter' do
52
52
  it 'should default to Caching::NoCache' do
53
- expect(Caching::NoCache).to receive(:new).with(subject.aws_client, subject.searchable).and_call_original
53
+ expect(Caching::NoCache).to receive(:new).with(subject.searchable) do |_, &lazy_client|
54
+ expect(lazy_client.call).to eq subject.client
55
+ end.and_call_original
54
56
  expect(subject.executor).to be_kind_of Caching::NoCache
55
57
  end
56
58
  end
57
59
 
58
60
  describe 'executor setter' do
59
61
  it 'should accept a caching module' do
60
- expect(Caching::GoodCache).to receive(:new).with(subject.aws_client, subject.searchable).and_call_original
62
+ expect(Caching::GoodCache).to receive(:new).with(subject.searchable) do |_, &lazy_client|
63
+ expect(lazy_client.call).to eq subject.client
64
+ end.and_call_original
61
65
  subject.executor = Caching::GoodCache
62
66
  expect(subject.executor).to be_kind_of Caching::GoodCache
63
67
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: CloudSesame
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Chu