lhs 3.0.3 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5457dca94fecc849496d18aaff5a9caa087608f8
4
- data.tar.gz: c1854bf19ecd17ab7383cda4ee2cc482e068fecc
3
+ metadata.gz: 25c2f31fa82157c1d9a3b6afebaf02f5d71b926a
4
+ data.tar.gz: d464725b1cc5882bc182d460532fe26b6add315d
5
5
  SHA512:
6
- metadata.gz: ceabba06f22f3337a24ef9410b7f2cd17b072c4c86ba3d4e8e8f01991d98f51eaa10448d77021baf5bb3055fe5226127ab8d6ccebe1da993b43c68a5e0691cfd
7
- data.tar.gz: 861a4ff34ea47ed94c33e3b247ad75a25119f74a9a430b307a4b8f3bd05459cfb29fd280d00d4be986c86b3ea7a3062bb378f3a58390f8b5a8712c0cc10d4d05
6
+ metadata.gz: d3cce7225ad9cbd4e615e35af9362096c760dfb9603ed24ed4c207ecbaba98c7620f5efd02c5d41a5446d6ddc1d1b3d0d7048a10984a56aeb08650e9f2108250
7
+ data.tar.gz: 58446953d05a44c0d8e3af2d5c2be56725f22440aa6bf6d21731522bd4bbd849469e1964af675a8ff324dd880405e562e2f3fe347a652b44e44f4ce1f7f8604b
@@ -5,3 +5,9 @@ inherit_from:
5
5
 
6
6
  Lint/IneffectiveAccessModifier:
7
7
  Enabled: false
8
+
9
+ RSpec/DescribedClass:
10
+ Enabled: false
11
+
12
+ RSpec/AnyInstance:
13
+ Enabled: false
@@ -14,6 +14,8 @@ class LHS::Record
14
14
  include Request
15
15
  include Where
16
16
 
17
+ delegate :_proxy, to: :_data
18
+
17
19
  def initialize(data = nil)
18
20
  data = LHS::Data.new({}, nil, self.class) unless data
19
21
  data = LHS::Data.new(data, nil, self.class) unless data.is_a?(LHS::Data)
@@ -40,11 +42,10 @@ class LHS::Record
40
42
  protected
41
43
 
42
44
  def method_missing(name, *args, &block)
43
- _data.send(name, *args, &block)
45
+ _data._proxy.send(name, *args, &block)
44
46
  end
45
47
 
46
48
  def respond_to_missing?(name, include_all = false)
47
- (_data.root_item? && _data._root._record_class.instance_methods.include?(name)) ||
48
- _data._proxy.respond_to?(name, include_all)
49
+ _data.respond_to_missing?(name, include_all)
49
50
  end
50
51
  end
@@ -1,3 +1,3 @@
1
1
  module LHS
2
- VERSION = "3.0.3"
2
+ VERSION = "3.0.4"
3
3
  end
@@ -6,7 +6,7 @@ describe LHS::Collection do
6
6
  }
7
7
 
8
8
  let(:collection){
9
- described_class.new(LHS::Data.new(data))
9
+ LHS::Collection.new(LHS::Data.new(data))
10
10
  }
11
11
 
12
12
  context 'delegates methods to raw' do
@@ -6,7 +6,7 @@ describe LHS::Collection do
6
6
  }
7
7
 
8
8
  let(:collection){
9
- described_class.new(LHS::Data.new(data))
9
+ LHS::Collection.new(LHS::Data.new(data))
10
10
  }
11
11
 
12
12
  context 'enumerable' do
@@ -6,7 +6,7 @@ describe LHS::Collection do
6
6
  }
7
7
 
8
8
  let(:collection){
9
- described_class.new(LHS::Data.new(data))
9
+ LHS::Data.new(LHS::Data.new(data))
10
10
  }
11
11
 
12
12
  context '#respond_to?' do
@@ -6,14 +6,14 @@ describe LHS::Data do
6
6
  end
7
7
 
8
8
  let(:data) do
9
- described_class.new(json)
9
+ LHS::Data.new(json)
10
10
  end
11
11
 
12
12
  context 'collections' do
13
13
  it 'forwards calls to the collection' do
14
14
  expect(data.count).to be_kind_of Fixnum
15
- expect(data[0]).to be_kind_of described_class
16
- expect(data.sample).to be_kind_of described_class
15
+ expect(data[0]).to be_kind_of LHS::Data
16
+ expect(data.sample).to be_kind_of LHS::Data
17
17
  end
18
18
 
19
19
  it 'provides a total method to get the number of total records' do
@@ -23,7 +23,7 @@ describe LHS::Data do
23
23
 
24
24
  context 'collections from arrays' do
25
25
  let(:data) do
26
- described_class.new([1, 2, 3, 4])
26
+ LHS::Data.new([1, 2, 3, 4])
27
27
  end
28
28
 
29
29
  it 'uses collection as proxy for arrays' do
@@ -13,7 +13,7 @@ describe LHS::Data do
13
13
  end
14
14
 
15
15
  let(:data) do
16
- described_class.new(json, nil, Record)
16
+ LHS::Data.new(json, nil, Record)
17
17
  end
18
18
 
19
19
  let(:item) do
@@ -9,16 +9,11 @@ describe LHS::Data do
9
9
  end
10
10
 
11
11
  let(:data) do
12
- described_class.new({
13
- href: 'http://www.local.ch/v2/stuff'
14
- }, nil, Record)
12
+ LHS::Data.new({ href: 'http://www.local.ch/v2/stuff' }, nil, Record)
15
13
  end
16
14
 
17
15
  let(:loaded_data) do
18
- described_class.new({
19
- href: 'http://www.local.ch/v2/stuff',
20
- id: '123123123'
21
- }, nil, Record)
16
+ LHS::Data.new({ href: 'http://www.local.ch/v2/stuff', id: '123123123' }, nil, Record)
22
17
  end
23
18
 
24
19
  context 'merging' do
@@ -10,7 +10,7 @@ describe LHS::Data do
10
10
  end
11
11
 
12
12
  let(:data_from_raw) do
13
- described_class.new(
13
+ LHS::Data.new(
14
14
  href: 'http://www.local.ch/v2/stuff',
15
15
  id: '123123123'
16
16
  )
@@ -18,8 +18,8 @@ describe LHS::Data do
18
18
 
19
19
  let(:data_from_item) do
20
20
  raw = { href: 'http://www.local.ch/v2/stuff' }
21
- item = LHS::Item.new(described_class.new(raw))
22
- described_class.new(item)
21
+ item = LHS::Item.new(LHS::Data.new(raw))
22
+ LHS::Data.new(item)
23
23
  end
24
24
 
25
25
  context 'raw' do
@@ -9,14 +9,14 @@ describe LHS::Data do
9
9
 
10
10
  context '#respond_to?' do
11
11
  it 'it is true for mappings that are defined' do
12
- data = described_class.new({ 'campaign' => { 'id' => 123 } }, nil, Record)
12
+ data = LHS::Data.new({ 'campaign' => { 'id' => 123 } }, nil, Record)
13
13
 
14
14
  expect(data.respond_to?(:test_mapping?)).to be(true)
15
15
  end
16
16
 
17
17
  # proxy for this example is LHC::Collection which implements total
18
18
  it 'it is true for calls forwarded to proxy' do
19
- data = described_class.new({ 'items' => [{ 'campaign' => { 'id' => 123 } }] }, nil, Record)
19
+ data = LHS::Data.new({ 'items' => [{ 'campaign' => { 'id' => 123 } }] }, nil, Record)
20
20
 
21
21
  expect(data.respond_to?(:total)).to be(true)
22
22
  end
@@ -11,12 +11,12 @@ describe LHS::Data do
11
11
 
12
12
  context 'root' do
13
13
  it 'is navigateable from nested data' do
14
- root = described_class.new({ 'items' => [{ 'campaign' => { 'id' => 123 } }] }, nil, Record)
14
+ root = LHS::Data.new({ 'items' => [{ 'campaign' => { 'id' => 123 } }] }, nil, Record)
15
15
  child = root.first
16
16
  leafe = child.campaign
17
17
  expect(leafe._root).to eq root
18
- expect(leafe._parent).to be_kind_of described_class
19
- expect(leafe._parent._parent).to be_kind_of described_class
18
+ expect(leafe._parent).to be_kind_of LHS::Data
19
+ expect(leafe._parent._parent).to be_kind_of LHS::Data
20
20
  expect(leafe._parent._parent).to eq root
21
21
  end
22
22
  end
@@ -6,7 +6,7 @@ describe LHS::Data do
6
6
  end
7
7
 
8
8
  let(:data) do
9
- described_class.new(raw)
9
+ LHS::Data.new(raw)
10
10
  end
11
11
 
12
12
  context 'select' do
@@ -13,7 +13,7 @@ describe LHS::Data do
13
13
  end
14
14
 
15
15
  let(:collection) do
16
- described_class.new(json, nil, Record)
16
+ LHS::Data.new(json, nil, Record)
17
17
  end
18
18
 
19
19
  let(:item) do
@@ -12,13 +12,13 @@ describe LHS::Endpoint do
12
12
 
13
13
  it 'provides the endpoint for a given url' do
14
14
  expect(
15
- described_class.for_url('http://local.ch/v2/entries/123/content-ads/456/feedbacks').url
15
+ LHS::Endpoint.for_url('http://local.ch/v2/entries/123/content-ads/456/feedbacks').url
16
16
  ).to eq ':datastore/entries/:entry_id/content-ads/:campaign_id/feedbacks'
17
17
  expect(
18
- described_class.for_url('http://local.ch/123/feedbacks').url
18
+ LHS::Endpoint.for_url('http://local.ch/123/feedbacks').url
19
19
  ).to eq ':datastore/:campaign_id/feedbacks'
20
20
  expect(
21
- described_class.for_url('http://local.ch/feedbacks').url
21
+ LHS::Endpoint.for_url('http://local.ch/feedbacks').url
22
22
  ).to eq ':datastore/feedbacks'
23
23
  end
24
24
  end
@@ -2,7 +2,7 @@ require 'rails_helper'
2
2
 
3
3
  describe LHS::Item do
4
4
  let(:item){
5
- described_class.new(id: 1234)
5
+ LHS::Item.new(id: 1234)
6
6
  }
7
7
 
8
8
  context '#respond_to?' do
@@ -46,7 +46,7 @@ describe LHS::Item do
46
46
  .to_return(status: 400, body: item._raw.merge(likes: 'Banana').to_json)
47
47
  item.update(name: 'Andrea')
48
48
  expect(item.name).to eq 'Andrea'
49
- expect(item.likes).to_not eq 'Banana'
49
+ expect(item.likes).not_to eq 'Banana'
50
50
  end
51
51
  end
52
52
 
@@ -21,7 +21,7 @@ describe LHS::Collection do
21
21
  .to_return(status: 200, body: { items: (201..300).to_a, total: 300, limit: 100, offset: 201 }.to_json)
22
22
  all = Record.all
23
23
  expect(all).to be_kind_of Record
24
- expect(all._proxy).to be_kind_of described_class
24
+ expect(all._data._proxy).to be_kind_of LHS::Collection
25
25
  expect(all.count).to eq 300
26
26
  expect(all.last).to eq 300
27
27
  end
@@ -35,7 +35,7 @@ describe LHS::Collection do
35
35
  .to_return(status: 200, body: { items: (201..300).to_a, total: 300, offset: 201 }.to_json)
36
36
  all = Record.all
37
37
  expect(all).to be_kind_of Record
38
- expect(all._proxy).to be_kind_of described_class
38
+ expect(all._proxy).to be_kind_of LHS::Collection
39
39
  expect(all.count).to eq 300
40
40
  expect(all.last).to eq 300
41
41
  end
@@ -45,7 +45,7 @@ describe LHS::Collection do
45
45
  .to_return(status: 200, body: { items: [], total: 300, offset: 0 }.to_json)
46
46
  all = Record.all
47
47
  expect(all).to be_kind_of Record
48
- expect(all._proxy).to be_kind_of described_class
48
+ expect(all._proxy).to be_kind_of LHS::Collection
49
49
  expect(all.count).to eq 0
50
50
  end
51
51
  end
@@ -36,7 +36,7 @@ describe LHS::Collection do
36
36
  Record.find_in_batches do |records|
37
37
  count += records.count
38
38
  expect(records).to be_kind_of Record
39
- expect(records._proxy).to be_kind_of described_class
39
+ expect(records._proxy).to be_kind_of LHS::Collection
40
40
  end
41
41
  expect(count).to eq total
42
42
  end
@@ -51,7 +51,7 @@ describe LHS::Collection do
51
51
  Record.find_in_batches(batch_size: 230) do |records|
52
52
  count += records.count
53
53
  expect(records).to be_kind_of Record
54
- expect(records._proxy).to be_kind_of described_class
54
+ expect(records._proxy).to be_kind_of LHS::Collection
55
55
  end
56
56
  expect(count).to eq total
57
57
  end
@@ -0,0 +1,15 @@
1
+ require 'rails_helper'
2
+
3
+ describe LHS::Record do
4
+ let(:record) do
5
+ LHS::Record.new(LHS::Data.new(['cat', 'dog']))
6
+ end
7
+
8
+ context 'select' do
9
+ it 'works with select' do
10
+ expect(
11
+ record.select { |x| x }.join
12
+ ).to eq 'catdog'
13
+ end
14
+ end
15
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhs
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/local-ch/lhs/graphs/contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-15 00:00:00.000000000 Z
11
+ date: 2016-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lhc
@@ -258,6 +258,7 @@ files:
258
258
  - spec/record/model_name_spec.rb
259
259
  - spec/record/new_spec.rb
260
260
  - spec/record/request_spec.rb
261
+ - spec/record/select_spec.rb
261
262
  - spec/record/to_json_spec.rb
262
263
  - spec/record/where_spec.rb
263
264
  - spec/spec_helper.rb
@@ -376,6 +377,7 @@ test_files:
376
377
  - spec/record/model_name_spec.rb
377
378
  - spec/record/new_spec.rb
378
379
  - spec/record/request_spec.rb
380
+ - spec/record/select_spec.rb
379
381
  - spec/record/to_json_spec.rb
380
382
  - spec/record/where_spec.rb
381
383
  - spec/spec_helper.rb