lhc 3.5.3 → 3.5.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 +4 -4
- data/lib/lhc/endpoint.rb +3 -3
- data/lib/lhc/version.rb +1 -1
- data/spec/endpoint/compile_spec.rb +7 -0
- data/spec/endpoint/match_spec.rb +4 -2
- 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: 8b55a6d77b6a16bb202a4babfc914427d70f092e
|
4
|
+
data.tar.gz: c618090650536a4f7fbff41c8b83a59b91108e3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 036f5aa745a97701ef069a902b9ba7d6b6bb142d72ccfd028ebe91358d68ae23d98b6ea2f70d55c87ba7d064185f7c9b24b99b9a19107e8c00c802ff076fc0e7
|
7
|
+
data.tar.gz: 74db7500de0d6a3638c5f96ec918984e4dc9624a2405679fb7936e54178e98d9faa638f41b2fb61ad5bf3fe2c07e7fa1d06c5240a46a1296128209eb03d9525d
|
data/lib/lhc/endpoint.rb
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
# The url can also be an url-template.
|
3
3
|
class LHC::Endpoint
|
4
4
|
|
5
|
-
PLACEHOLDER = %r{(?<=^):[
|
6
|
-
|
5
|
+
PLACEHOLDER = %r{(?<=^):[^\/\.]+|(?<=\/):[^\/\.]+}
|
6
|
+
ANYTHING_BUT_SINGLE_SLASH_AND_DOT = '([^\/\.]|\/\/)+'.freeze
|
7
7
|
|
8
8
|
attr_accessor :url, :options
|
9
9
|
|
@@ -63,7 +63,7 @@ class LHC::Endpoint
|
|
63
63
|
# Returns true if concrete url is covered by the template
|
64
64
|
# Example: :datastore/contracts/:id == http://local.ch/contracts/1
|
65
65
|
def self.match?(url, template)
|
66
|
-
regexp = template.gsub PLACEHOLDER,
|
66
|
+
regexp = template.gsub PLACEHOLDER, ANYTHING_BUT_SINGLE_SLASH_AND_DOT
|
67
67
|
url.match "#{regexp}$"
|
68
68
|
end
|
69
69
|
|
data/lib/lhc/version.rb
CHANGED
@@ -19,5 +19,12 @@ describe LHC::Endpoint do
|
|
19
19
|
endpoint.compile(find_value)
|
20
20
|
).to eq "http://datastore/v2"
|
21
21
|
end
|
22
|
+
|
23
|
+
it 'compiles when templates contain dots' do
|
24
|
+
endpoint = described_class.new(':datastore/entries/:id.json')
|
25
|
+
expect(
|
26
|
+
endpoint.compile(datastore: 'http://datastore', id: 123)
|
27
|
+
).to eq "http://datastore/entries/123.json"
|
28
|
+
end
|
22
29
|
end
|
23
30
|
end
|
data/spec/endpoint/match_spec.rb
CHANGED
@@ -10,7 +10,8 @@ describe LHC::Endpoint do
|
|
10
10
|
':datastore/v2/places/:namespace/:id' => 'http://local.ch:8082/v2/places/switzerland/ZW9OJyrbt',
|
11
11
|
':datastore/addresses/:id' => 'http://local.ch/addresses/123',
|
12
12
|
'http://local.ch/addresses/:id' => 'http://local.ch/addresses/123',
|
13
|
-
':datastore/customers/:id/addresses' => 'http://local.ch:80/server/rest/v1/customers/123/addresses'
|
13
|
+
':datastore/customers/:id/addresses' => 'http://local.ch:80/server/rest/v1/customers/123/addresses',
|
14
|
+
':datastore/entries/:id.json' => 'http://local.ch/entries/123.json'
|
14
15
|
}.each do |template, url|
|
15
16
|
expect(
|
16
17
|
described_class.match?(url, template)
|
@@ -24,7 +25,8 @@ describe LHC::Endpoint do
|
|
24
25
|
{
|
25
26
|
':datastore/v2/places' => 'http://local.ch:8082/v2/places/ZW9OJyrbt4OZE9ueu80w-A',
|
26
27
|
':datastore/:campaign_id/feedbacks' => 'http://datastore.local.ch/feedbacks',
|
27
|
-
':datastore/customers/:id' => 'http://local.ch:80/server/rest/v1/customers/123/addresses'
|
28
|
+
':datastore/customers/:id' => 'http://local.ch:80/server/rest/v1/customers/123/addresses',
|
29
|
+
':datastore/entries/:id' => 'http://local.ch/entries/123.json'
|
28
30
|
}.each do |template, url|
|
29
31
|
expect(
|
30
32
|
described_class.match?(url, template)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lhc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.5.
|
4
|
+
version: 3.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- local.ch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|