lhc 3.5.1 → 3.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -0
- data/lib/lhc/endpoint.rb +5 -7
- data/lib/lhc/version.rb +1 -1
- data/non_rails_spec/request/request_spec.rb +1 -1
- data/spec/endpoint/match_spec.rb +6 -2
- data/spec/request/error_handling_spec.rb +0 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9eab71d5754c000d8a3810c90416a09b3c615b2e
|
4
|
+
data.tar.gz: 4de1ed988db86d463c7e573b48280f38d5172cb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f20cb466d43ff753fa3ec8b454879a100234d9231d4d440ba5132af9c79b245664b42953cc8e1e061e58bc1775b7eb6c7b32c0002782160c13a838f907f6c147
|
7
|
+
data.tar.gz: 45e4f0e2d27b4b30e072b504de2c6db24bb2a1bee673a33780e55c8a380db5f761f40871d14422fea3b4b6894ea7aeb4fbf5c6b7ba6405837b6be3e46077fe11
|
data/.rubocop.yml
CHANGED
data/lib/lhc/endpoint.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
# The url can also be an url-template.
|
3
3
|
class LHC::Endpoint
|
4
4
|
|
5
|
-
PLACEHOLDER =
|
5
|
+
PLACEHOLDER = %r{(?<=^):[^\/]+|(?<=\/):[^\/]+}
|
6
|
+
ANYTHING_BUT_SINGLE_SLASH = '([^\/]|\/\/)+'.freeze
|
6
7
|
|
7
8
|
attr_accessor :url, :options
|
8
9
|
|
@@ -60,13 +61,10 @@ class LHC::Endpoint
|
|
60
61
|
|
61
62
|
# Compares a concrete url with a template
|
62
63
|
# Returns true if concrete url is covered by the template
|
64
|
+
# Example: :datastore/contracts/:id == http://local.ch/contracts/1
|
63
65
|
def self.match?(url, template)
|
64
|
-
regexp = template
|
65
|
-
|
66
|
-
regexp = regexp.gsub(placeholder, '.*')
|
67
|
-
end
|
68
|
-
regexp = regexp.gsub('/', '(?<!/)/(?!/)')
|
69
|
-
url.match(Regexp.new("^#{regexp}$"))
|
66
|
+
regexp = template.gsub PLACEHOLDER, ANYTHING_BUT_SINGLE_SLASH
|
67
|
+
url.match "#{regexp}$"
|
70
68
|
end
|
71
69
|
|
72
70
|
# Returns all placeholders found in the url-template.
|
data/lib/lhc/version.rb
CHANGED
data/spec/endpoint/match_spec.rb
CHANGED
@@ -7,7 +7,10 @@ describe LHC::Endpoint do
|
|
7
7
|
{
|
8
8
|
':datastore/v2/places' => 'http://local.ch:8082/v2/places',
|
9
9
|
':datastore/v2/places/:id' => 'http://local.ch:8082/v2/places/ZW9OJyrbt4OZE9ueu80w-A',
|
10
|
-
':datastore/v2/places/:namespace/:id' => 'http://local.ch:8082/v2/places/switzerland/ZW9OJyrbt'
|
10
|
+
':datastore/v2/places/:namespace/:id' => 'http://local.ch:8082/v2/places/switzerland/ZW9OJyrbt',
|
11
|
+
':datastore/addresses/:id' => 'http://local.ch/addresses/123',
|
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'
|
11
14
|
}.each do |template, url|
|
12
15
|
expect(
|
13
16
|
described_class.match?(url, template)
|
@@ -20,7 +23,8 @@ describe LHC::Endpoint do
|
|
20
23
|
it 'checks if a url matches a template' do
|
21
24
|
{
|
22
25
|
':datastore/v2/places' => 'http://local.ch:8082/v2/places/ZW9OJyrbt4OZE9ueu80w-A',
|
23
|
-
':datastore/:campaign_id/feedbacks' => 'http://datastore.local.ch/feedbacks'
|
26
|
+
':datastore/:campaign_id/feedbacks' => 'http://datastore.local.ch/feedbacks',
|
27
|
+
':datastore/customers/:id' => 'http://local.ch:80/server/rest/v1/customers/123/addresses'
|
24
28
|
}.each do |template, url|
|
25
29
|
expect(
|
26
30
|
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.2
|
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-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -274,7 +274,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
274
274
|
requirements:
|
275
275
|
- Ruby >= 1.9.2
|
276
276
|
rubyforge_project:
|
277
|
-
rubygems_version: 2.
|
277
|
+
rubygems_version: 2.2.2
|
278
278
|
signing_key:
|
279
279
|
specification_version: 4
|
280
280
|
summary: LocalHttpServices
|