lhc 3.5.1 → 3.5.2

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: 8e631c244f0c874a0e113aba5d070801abfefcc3
4
- data.tar.gz: 1bbf13adcedef0adb7820069c08493153ce851c4
3
+ metadata.gz: 9eab71d5754c000d8a3810c90416a09b3c615b2e
4
+ data.tar.gz: 4de1ed988db86d463c7e573b48280f38d5172cb9
5
5
  SHA512:
6
- metadata.gz: a376e211801678d57d28fa29abe0f3eb31f1d8e3a3e0d03740b1e663a53c3dc53df4f61af1e3ec2bf716e13cd5ca3968f0a082b705a9103bc6bc9d6a4c2f9515
7
- data.tar.gz: 7d082bb04aaebb3bc32c977876a93a82305d93020a873c87b165ffaba689f9f124226e5833878a260717a66d70112d86e6c77d808e78fd68295e529f28141e0d
6
+ metadata.gz: f20cb466d43ff753fa3ec8b454879a100234d9231d4d440ba5132af9c79b245664b42953cc8e1e061e58bc1775b7eb6c7b32c0002782160c13a838f907f6c147
7
+ data.tar.gz: 45e4f0e2d27b4b30e072b504de2c6db24bb2a1bee673a33780e55c8a380db5f761f40871d14422fea3b4b6894ea7aeb4fbf5c6b7ba6405837b6be3e46077fe11
data/.rubocop.yml CHANGED
@@ -8,3 +8,12 @@ Lint/IneffectiveAccessModifier:
8
8
 
9
9
  Rails:
10
10
  Enabled: false
11
+
12
+ RSpec/AnyInstance:
13
+ Enabled: false
14
+
15
+ RSpec/DescribedClass:
16
+ Enabled: false
17
+
18
+ Style/Lambda:
19
+ Enabled: false
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 = /\:[A-Z,a-z,_,-]+/
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
- LHC::Endpoint.placeholders(template).each do |placeholder|
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
@@ -1,3 +1,3 @@
1
1
  module LHC
2
- VERSION = "3.5.1"
2
+ VERSION = "3.5.2"
3
3
  end
@@ -7,7 +7,7 @@ describe LHC::Request do
7
7
  end
8
8
  context 'request without rails' do
9
9
  it 'does have deep_merge dependency met' do
10
- expect { described_class.new({}, false) }.to_not raise_error
10
+ expect { described_class.new({}, false) }.not_to raise_error
11
11
  end
12
12
  end
13
13
  end
@@ -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)
@@ -49,7 +49,6 @@ describe LHC::Request do
49
49
  end
50
50
 
51
51
  context 'parsing error' do
52
-
53
52
  before(:each) do
54
53
  stub_request(:get, 'http://datastore/v2/feedbacks').to_return(body: 'invalid json')
55
54
  end
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.1
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-03-09 00:00:00.000000000 Z
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.4.1
277
+ rubygems_version: 2.2.2
278
278
  signing_key:
279
279
  specification_version: 4
280
280
  summary: LocalHttpServices