lhs 19.4.1 → 19.5.0.pre.wherehref.1
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 +4 -4
- data/lib/lhs.rb +2 -0
- data/lib/lhs/concerns/is_href.rb +16 -0
- data/lib/lhs/concerns/record/chainable.rb +12 -4
- data/lib/lhs/concerns/record/find.rb +0 -4
- data/lib/lhs/record.rb +1 -0
- data/lib/lhs/version.rb +1 -1
- data/spec/record/where_spec.rb +28 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a88315dc4d085a6e2721ff9b3c64099474c255fb7b38a359347f6b970bce0b8d
|
4
|
+
data.tar.gz: 520edfda6e3f56e415e94433e18e2c0f8dd2f30f88aeb997a054b63c0ffa4fd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0069a65afd0775a0b672a5ec9d2ac859141e8d04c52c575fd217f6062ddfb9b6190ddda551d386baa1159f8b397bd75c36792be5fb8e4609d3c7b8a40af6b885'
|
7
|
+
data.tar.gz: 8f7e6060bbd95b062f827fa25ef1c6a57d8cbef128bf9fab4152b467adc680e1b773d250cc9b896dab5f71d3959c8ef0eecd951a8ffd68c11d12d16eaa12b382
|
data/lib/lhs.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support'
|
4
|
+
|
5
|
+
module LHS
|
6
|
+
module IsHref
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
|
11
|
+
def href?(input)
|
12
|
+
input.is_a?(String) && %r{^https?://}.match(input).present?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -14,8 +14,12 @@ class LHS::Record
|
|
14
14
|
end
|
15
15
|
|
16
16
|
module ClassMethods
|
17
|
-
def where(
|
18
|
-
|
17
|
+
def where(args = nil)
|
18
|
+
if href?(args)
|
19
|
+
Chain.new(self, Option.new(url: args))
|
20
|
+
else
|
21
|
+
Chain.new(self, Parameter.new(args))
|
22
|
+
end
|
19
23
|
end
|
20
24
|
|
21
25
|
def fetch
|
@@ -200,8 +204,12 @@ class LHS::Record
|
|
200
204
|
end
|
201
205
|
alias validate valid?
|
202
206
|
|
203
|
-
def where(
|
204
|
-
|
207
|
+
def where(args = nil)
|
208
|
+
if LHS::Record.href?(args)
|
209
|
+
push(Option.new(url: args))
|
210
|
+
else
|
211
|
+
push(Parameter.new(args))
|
212
|
+
end
|
205
213
|
end
|
206
214
|
|
207
215
|
def all(hash = nil)
|
data/lib/lhs/record.rb
CHANGED
data/lib/lhs/version.rb
CHANGED
data/spec/record/where_spec.rb
CHANGED
@@ -30,5 +30,33 @@ describe LHS::Record do
|
|
30
30
|
stub_request(:get, "#{datastore}/content-ads/123/feedbacks?campaign_id=456").to_return(status: 200, body: [].to_json)
|
31
31
|
Record.where(campaign_id: '123', params: { campaign_id: '456' })
|
32
32
|
end
|
33
|
+
|
34
|
+
context 'where with href' do
|
35
|
+
let(:return_body) { [ email: 'steve@local.ch' ].to_json }
|
36
|
+
|
37
|
+
context 'chain initialization' do
|
38
|
+
before do
|
39
|
+
stub_request(:get, "https://localch-accounts/?from_user_id=123")
|
40
|
+
.to_return(body: return_body)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'queries api with provided href' do
|
44
|
+
records = Record.where('https://localch-accounts?from_user_id=123').fetch
|
45
|
+
expect(records.first.email).to eq 'steve@local.ch'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'after chain initialization' do
|
50
|
+
before do
|
51
|
+
stub_request(:get, "https://localch-accounts/?color=blue&from_user_id=123")
|
52
|
+
.to_return(body: return_body)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'queries api with provided href also when passed after chain is initialized' do
|
56
|
+
records = Record.where(color: 'blue').where('https://localch-accounts?from_user_id=123').fetch
|
57
|
+
expect(records.first.email).to eq 'steve@local.ch'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
33
61
|
end
|
34
62
|
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: 19.
|
4
|
+
version: 19.5.0.pre.wherehref.1
|
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: 2019-07-
|
11
|
+
date: 2019-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -228,6 +228,7 @@ files:
|
|
228
228
|
- lib/lhs/concerns/data/json.rb
|
229
229
|
- lib/lhs/concerns/data/to_hash.rb
|
230
230
|
- lib/lhs/concerns/inspect.rb
|
231
|
+
- lib/lhs/concerns/is_href.rb
|
231
232
|
- lib/lhs/concerns/item/destroy.rb
|
232
233
|
- lib/lhs/concerns/item/endpoint_lookup.rb
|
233
234
|
- lib/lhs/concerns/item/save.rb
|
@@ -474,13 +475,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
474
475
|
version: 2.3.0
|
475
476
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
476
477
|
requirements:
|
477
|
-
- - "
|
478
|
+
- - ">"
|
478
479
|
- !ruby/object:Gem::Version
|
479
|
-
version:
|
480
|
+
version: 1.3.1
|
480
481
|
requirements:
|
481
482
|
- Ruby >= 2.3.0
|
482
483
|
rubyforge_project:
|
483
|
-
rubygems_version: 2.7.
|
484
|
+
rubygems_version: 2.7.8
|
484
485
|
signing_key:
|
485
486
|
specification_version: 4
|
486
487
|
summary: 'REST services accelerator: Rails gem providing an easy, active-record-like
|