lhc 3.1.1 → 3.2.0

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: a313eb836f98fd351f84b17f9fced2f0d3c89dde
4
- data.tar.gz: 3d694a9a7b02371bad5accbbacfb3b90e2895de4
3
+ metadata.gz: 43a289b03b874bf4db882437401c6f5f7ce76111
4
+ data.tar.gz: aa18dab5fe11eff93eada4ad91267a54357afb14
5
5
  SHA512:
6
- metadata.gz: a831f27b91dfdb214d7e65767d3ce8b2775d6dd0b2646ebff14fd71bc54d27f1ed8a99c64b601d6294a6db57a9bf88522854f06d13aff9dae3b0e8d6bdff4451
7
- data.tar.gz: b507a4579cba072c5e47a2d8053e11403ba9f9232919ccd6d32f56a05a3cd25612c508d8651b14cf1ca0ebdcf36a80662c3a732547136446ac499d88ffde91fd
6
+ metadata.gz: a6677681346af6436d59ed7201a7666e049aebb4ec35a8145a7c4afbb98ba37960544e982536d57e4d17a325236fcf2f217fe075fb5a1dd7f3ceeac35338f8d9
7
+ data.tar.gz: 08c21acba94b0f42aff47ae3168e02a9cb884f552c4b195e024c77d75fe20a02429355a92da14ef1e9c37d22cd239a7d50a612f96534bbae8f56cc6412650f35
data/README.md CHANGED
@@ -8,7 +8,7 @@ See [LHS](https://github.com/local-ch/LHS), if you are searching for something m
8
8
  ## Quick Start Guide
9
9
 
10
10
  ```ruby
11
- response = LHC.get('http://datastore.lb-service/v2/feedbacks')
11
+ response = LHC.get('http://datastore/v2/feedbacks')
12
12
  response.data.items[0]
13
13
  response.data.items[0].recommended
14
14
  response.body # String
@@ -21,13 +21,23 @@ Available are `get`, `post`, `put` & `delete`.
21
21
 
22
22
  Other methods are available using `LHC.request(options)`.
23
23
 
24
+ ## Formats: like json etc.
25
+
26
+ You can use any of the basic methods in combination with a format like `json`:
27
+
28
+ ```ruby
29
+ LHC.json.get(options)
30
+ ```
31
+
32
+ Currently supported formats: `json`
33
+
24
34
  ## A request from scratch
25
35
 
26
36
  ```ruby
27
37
  response = LHC.request(url: 'http://local.ch', method: :options)
28
38
  response.headers
29
39
 
30
- response = LHC.request(url: 'http://datastore.lb-service/v2/feedbacks', method: :get)
40
+ response = LHC.request(url: 'http://datastore/v2/feedbacks', method: :get)
31
41
  response.data
32
42
  ```
33
43
 
@@ -42,8 +52,8 @@ You will get back an array of LHC::Response objects.
42
52
 
43
53
  ```ruby
44
54
  options = []
45
- options << { url: 'http://datastore.lb-service/v2/feedbacks' }
46
- options << { url: 'http://datastore.lb-service/v2/content-ads/123/feedbacks' }
55
+ options << { url: 'http://datastore/v2/feedbacks' }
56
+ options << { url: 'http://datastore/v2/content-ads/123/feedbacks' }
47
57
  responses = LHC.request(options)
48
58
  ```
49
59
 
@@ -53,7 +63,7 @@ Data that is transfered using the HTTP request body is transfered as you provide
53
63
  Also consider setting the http header for content-type.
54
64
 
55
65
  ```ruby
56
- LHC.post('http://datastore.lb-service/v2/feedbacks',
66
+ LHC.post('http://datastore/v2/feedbacks',
57
67
  body: feedback.to_json,
58
68
  headers: { 'Content-Type' => 'application/json' }
59
69
  )
@@ -65,7 +75,7 @@ You can configure global endpoints, placeholders and interceptors.
65
75
 
66
76
  ```ruby
67
77
  LHC.configure do |c|
68
- c.placeholder :datastore, 'http://datastore.lb-service/v2'
78
+ c.placeholder :datastore, 'http://datastore/v2'
69
79
  c.endpoint :feedbacks, ':datastore/feedbacks', params: { has_reviews: true }
70
80
  c.interceptors = [CacheInterceptor]
71
81
  end
@@ -79,17 +89,17 @@ Instead of using concrete urls you can also use url-templates that contain place
79
89
  This is especially handy for configuring an endpoint once and generate the url from the params when doing the request.
80
90
 
81
91
  ```ruby
82
- url = 'http://datastore.lb-service/v2/feedbacks/:id'
92
+ url = 'http://datastore/v2/feedbacks/:id'
83
93
  LHC.config.endpoint(:find_feedback, url, options)
84
94
  LHC.get(:find_feedback, params:{ id: 123 })
85
- # GET http://datastore.lb-service/v2/feedbacks/123
95
+ # GET http://datastore/v2/feedbacks/123
86
96
  ```
87
97
 
88
98
  This also works in place without configuring an endpoint.
89
99
 
90
100
  ```ruby
91
- LHC.get('http://datastore-stg.lb-service/v2/feedbacks/:id', params:{ id: 123 })
92
- # GET http://datastore-stg.lb-service/v2/feedbacks/123
101
+ LHC.get('http://datastore/v2/feedbacks/:id', params:{ id: 123 })
102
+ # GET http://datastore/v2/feedbacks/123
93
103
  ```
94
104
 
95
105
  If you miss to provide a parameter that is part of the url-template, it will raise an exception.
@@ -0,0 +1,3 @@
1
+ jobs:
2
+ _cider-ci_include:
3
+ - cider-ci/jobs/tests.yml
@@ -0,0 +1,19 @@
1
+ subcontexts:
2
+
3
+ - name: 'All rspec tests'
4
+
5
+ task-defaults:
6
+
7
+ environment-variables:
8
+ RAILS_ENV: test
9
+
10
+ scripts:
11
+
12
+ test:
13
+
14
+ body: |
15
+ #!/usr/bin/env bash
16
+ bundle exec rspec $CIDER_CI_TASK_FILE
17
+
18
+ _cider-ci_generate-tasks:
19
+ include-match: spec/.*_spec.rb
@@ -0,0 +1,27 @@
1
+ tests:
2
+
3
+ name: 'Tests'
4
+
5
+ run-on:
6
+ - type: branch
7
+ include-match: ^.*$
8
+
9
+ context:
10
+
11
+ _cider-ci_include:
12
+ - cider-ci/contexts/rspec.yml
13
+
14
+ task-defaults:
15
+
16
+ scripts:
17
+
18
+ bundle:
19
+ body: sed 's/^source.*/source "http\:\/\/52.29.7.59:9292"/g' Gemfile > Gemfile.tmp ; mv Gemfile.tmp Gemfile && bundle install
20
+
21
+ ruby-version:
22
+ body: ruby --version
23
+
24
+ test:
25
+ start-when:
26
+ - script: bundle
27
+ - script: ruby-version
@@ -10,7 +10,7 @@ Take care that you only use `LHC.configure` once, because it is actually resetin
10
10
  ```ruby
11
11
 
12
12
  LHC.configure do |c|
13
- c.placeholder :datastore, 'http://datastore.lb-service/v2'
13
+ c.placeholder :datastore, 'http://datastore/v2'
14
14
  c.endpoint :feedbacks, ':datastore/feedbacks'
15
15
  c.interceptors = [CachingInterceptor, MonitorInterceptor, TrackingIdInterceptor]
16
16
  end
@@ -22,7 +22,7 @@ Take care that you only use `LHC.configure` once, because it is actually resetin
22
22
  You can configure endpoints, for later use, by giving them a name, an url and some parameters (optional).
23
23
 
24
24
  ```ruby
25
- url = 'http://datastore.lb-service/v2/feedbacks'
25
+ url = 'http://datastore/v2/feedbacks'
26
26
  options = { params: { has_reviews: true } }
27
27
  LHC.config.endpoint(:feedbacks, url, options)
28
28
  LHC.get(:feedbacks)
@@ -39,7 +39,7 @@ Explicit request options override configured options.
39
39
  You can configure global placeholders, that are used when generating urls from url-templates.
40
40
 
41
41
  ```ruby
42
- LHC.config.placeholder(:datastore, 'http://datastore.lb-service/v2')
42
+ LHC.config.placeholder(:datastore, 'http://datastore/v2')
43
43
  options = { params: { has_reviews: true } }
44
44
  LHC.config.endpoint(:feedbacks, url, options)
45
45
  LHC.get(:feedbacks)
data/lib/lhc.rb CHANGED
@@ -2,6 +2,7 @@ Dir[File.dirname(__FILE__) + '/lhc/concerns/lhc/*.rb'].sort.each {|file| require
2
2
 
3
3
  module LHC
4
4
  include BasicMethods
5
+ include Formats
5
6
 
6
7
  def self.config
7
8
  LHC::Config.instance
@@ -0,0 +1,13 @@
1
+ module LHC
2
+
3
+ module Formats
4
+ extend ActiveSupport::Concern
5
+
6
+ module ClassMethods
7
+
8
+ def json
9
+ JsonFormat
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ module JsonFormat
2
+
3
+ include LHC::BasicMethods
4
+
5
+ def self.request(options)
6
+ options[:headers] ||= {}
7
+ options[:headers]['Content-Type'] = 'application/json'
8
+ response = super(options)
9
+ end
10
+ end
@@ -16,7 +16,12 @@ class LHC::Response
16
16
  # Access response data.
17
17
  # Cache parsing.
18
18
  def data
19
- @data ||= JSON.parse(raw.body, object_class: OpenStruct)
19
+ @data ||= case format
20
+ when :json
21
+ JSON.parse(raw.body, object_class: OpenStruct)
22
+ else # default is json
23
+ JSON.parse(raw.body, object_class: OpenStruct)
24
+ end
20
25
  @data
21
26
  end
22
27
 
@@ -53,4 +58,10 @@ class LHC::Response
53
58
 
54
59
  attr_accessor :raw
55
60
 
61
+ def format
62
+ headers = {}
63
+ headers = request.options.fetch(:headers, {}) if request && request.options
64
+ return :json if headers['Content-Type'] == 'application/json'
65
+ end
66
+
56
67
  end
@@ -1,3 +1,3 @@
1
1
  module LHC
2
- VERSION = "3.1.1"
2
+ VERSION = "3.2.0"
3
3
  end
@@ -13,21 +13,21 @@ describe LHC do
13
13
  end
14
14
 
15
15
  before(:each) do
16
- stub_request(:delete, "http://datastore.lb-service/v2/feedbacks/12121")
16
+ stub_request(:delete, "http://datastore/v2/feedbacks/12121")
17
17
  .to_return(status: 200, body: feedback.to_json, headers: {'Content-Encoding' => 'UTF-8'})
18
18
  end
19
19
 
20
20
  it 'does a delete request when providing a complete url' do
21
- LHC.delete('http://datastore.lb-service/v2/feedbacks/12121')
21
+ LHC.delete('http://datastore/v2/feedbacks/12121')
22
22
  end
23
23
 
24
24
  it 'it makes response data available in a rails way' do
25
- response = LHC.delete('http://datastore.lb-service/v2/feedbacks/12121')
25
+ response = LHC.delete('http://datastore/v2/feedbacks/12121')
26
26
  expect(response.data.recommended).to eq true
27
27
  end
28
28
 
29
29
  it 'provides response headers' do
30
- response = LHC.delete('http://datastore.lb-service/v2/feedbacks/12121')
30
+ response = LHC.delete('http://datastore/v2/feedbacks/12121')
31
31
  expect(response.headers).to be
32
32
  end
33
33
  end
@@ -5,7 +5,7 @@ describe LHC do
5
5
  context 'get' do
6
6
 
7
7
  before(:each) do
8
- stub_request(:get, 'http://datastore.lb-service/v2/feedbacks?has_reviews=true')
8
+ stub_request(:get, 'http://datastore/v2/feedbacks?has_reviews=true')
9
9
  .to_return(status: 200, body: { total: 99 }.to_json, headers: {'Content-Encoding' => 'UTF-8'})
10
10
  end
11
11
 
@@ -14,24 +14,37 @@ describe LHC do
14
14
  end
15
15
 
16
16
  it 'does a get request when providing a complete url' do
17
- LHC.get('http://datastore.lb-service/v2/feedbacks', params: parameters)
17
+ LHC.get('http://datastore/v2/feedbacks', params: parameters)
18
18
  end
19
19
 
20
20
  it 'does a get request when providing the name of a configured endpoint' do
21
21
  url = 'http://:datastore/v2/feedbacks'
22
- options = { params: { datastore: 'datastore.lb-service' } }
22
+ options = { params: { datastore: 'datastore' } }
23
23
  LHC.configure { |c| c.endpoint(:feedbacks, url, options) }
24
24
  LHC.get(:feedbacks, params: parameters)
25
25
  end
26
26
 
27
27
  it 'it makes response data available in a rails way' do
28
- response = LHC.get('http://datastore.lb-service/v2/feedbacks', params: parameters)
28
+ response = LHC.get('http://datastore/v2/feedbacks', params: parameters)
29
29
  expect(response.data.total).to eq 99
30
30
  end
31
31
 
32
32
  it 'provides response headers' do
33
- response = LHC.get('http://datastore.lb-service/v2/feedbacks', params: parameters)
33
+ response = LHC.get('http://datastore/v2/feedbacks', params: parameters)
34
34
  expect(response.headers).to be
35
35
  end
36
36
  end
37
+
38
+ context 'get json' do
39
+
40
+ before(:each) do
41
+ stub_request(:get, 'http://datastore/v2/feedbacks').with(headers: {'Content-Type' => 'application/json'})
42
+ .to_return(body: {some: 'json'}.to_json)
43
+ end
44
+
45
+ it 'requests json and parses response body' do
46
+ data = LHC.json.get('http://datastore/v2/feedbacks').data
47
+ expect(data.some).to eq 'json'
48
+ end
49
+ end
37
50
  end
@@ -13,29 +13,29 @@ describe LHC do
13
13
  end
14
14
 
15
15
  before(:each) do
16
- stub_request(:post, "http://datastore.lb-service/v2/feedbacks")
16
+ stub_request(:post, "http://datastore/v2/feedbacks")
17
17
  .with(body: feedback.to_json)
18
18
  .to_return(status: 200, body: feedback.to_json, headers: {'Content-Encoding' => 'UTF-8'})
19
19
  end
20
20
 
21
21
  it 'does a post request when providing a complete url' do
22
- LHC.post('http://datastore.lb-service/v2/feedbacks', body: feedback.to_json)
22
+ LHC.post('http://datastore/v2/feedbacks', body: feedback.to_json)
23
23
  end
24
24
 
25
25
  it 'does a post request when providing the name of a configured endpoint' do
26
26
  url = 'http://:datastore/v2/feedbacks'
27
- options = { params: { datastore: 'datastore.lb-service' } }
27
+ options = { params: { datastore: 'datastore' } }
28
28
  LHC.configure { |c| c.endpoint(:feedbacks, url, options) }
29
29
  LHC.post(:feedbacks, body: feedback.to_json)
30
30
  end
31
31
 
32
32
  it 'it makes response data available in a rails way' do
33
- response = LHC.post('http://datastore.lb-service/v2/feedbacks', body: feedback.to_json)
33
+ response = LHC.post('http://datastore/v2/feedbacks', body: feedback.to_json)
34
34
  expect(response.data.source_id).to eq 'aaa'
35
35
  end
36
36
 
37
37
  it 'provides response headers' do
38
- response = LHC.post('http://datastore.lb-service/v2/feedbacks', body: feedback.to_json)
38
+ response = LHC.post('http://datastore/v2/feedbacks', body: feedback.to_json)
39
39
  expect(response.headers).to be
40
40
  end
41
41
  end
@@ -19,29 +19,29 @@ describe LHC do
19
19
  end
20
20
 
21
21
  before(:each) do
22
- stub_request(:put, "http://datastore.lb-service/v2/feedbacks")
22
+ stub_request(:put, "http://datastore/v2/feedbacks")
23
23
  .with(body: change.to_json)
24
24
  .to_return(status: 200, body: feedback.merge(change).to_json, headers: {'Content-Encoding' => 'UTF-8'})
25
25
  end
26
26
 
27
27
  it 'does a post request when providing a complete url' do
28
- LHC.put('http://datastore.lb-service/v2/feedbacks', body: change.to_json)
28
+ LHC.put('http://datastore/v2/feedbacks', body: change.to_json)
29
29
  end
30
30
 
31
31
  it 'does a post request when providing the name of a configured endpoint' do
32
32
  url = 'http://:datastore/v2/feedbacks'
33
- options = { params: { datastore: 'datastore.lb-service' } }
33
+ options = { params: { datastore: 'datastore' } }
34
34
  LHC.configure { |c| c.endpoint(:feedbacks, url, options) }
35
35
  LHC.put(:feedbacks, body: change.to_json)
36
36
  end
37
37
 
38
38
  it 'it makes response data available in a rails way' do
39
- response = LHC.put('http://datastore.lb-service/v2/feedbacks', body: change.to_json)
39
+ response = LHC.put('http://datastore/v2/feedbacks', body: change.to_json)
40
40
  expect(response.data.recommended).to eq false
41
41
  end
42
42
 
43
43
  it 'provides response headers' do
44
- response = LHC.put('http://datastore.lb-service/v2/feedbacks', body: change.to_json)
44
+ response = LHC.put('http://datastore/v2/feedbacks', body: change.to_json)
45
45
  expect(response.headers).to be
46
46
  end
47
47
  end
@@ -7,12 +7,12 @@ describe LHC do
7
7
  let(:total) { 99 }
8
8
 
9
9
  before(:each) do
10
- stub_request(:get, "http://datastore.lb-service/v2/feedbacks?has_reviews=true")
10
+ stub_request(:get, "http://datastore/v2/feedbacks?has_reviews=true")
11
11
  .to_return(status: 200, body: { total: total }.to_json, headers: {'Content-Encoding' => 'UTF-8'})
12
12
  end
13
13
 
14
14
  it 'does a request returning a response' do
15
- response = LHC.request(url: 'http://datastore.lb-service/v2/feedbacks', params: { has_reviews: true }, method: :get)
15
+ response = LHC.request(url: 'http://datastore/v2/feedbacks', params: { has_reviews: true }, method: :get)
16
16
  expect(response.data.total).to eq total
17
17
  end
18
18
  end
@@ -4,7 +4,7 @@ describe LHC do
4
4
 
5
5
  context 'configured endpoints' do
6
6
 
7
- let(:url) { 'http://analytics.lb-service/track/:entity_id/w/:type' }
7
+ let(:url) { 'http://analytics/track/:entity_id/w/:type' }
8
8
 
9
9
  let(:options) do
10
10
  {
@@ -25,33 +25,33 @@ describe LHC do
25
25
  end
26
26
 
27
27
  it 'compile url' do
28
- stub_request(:get, 'http://analytics.lb-service/track/123/w/request?env=PROD')
28
+ stub_request(:get, 'http://analytics/track/123/w/request?env=PROD')
29
29
  response = LHC.get(:kpi_tracker, params: { entity_id: 123, type: 'request' })
30
30
  expect(response.request.options[:followlocation]).to eq false
31
31
  end
32
32
 
33
33
  it 'gets overwritten by explicit request options' do
34
- stub_request(:get, 'http://analytics.lb-service/track/123/w/request?env=STG')
34
+ stub_request(:get, 'http://analytics/track/123/w/request?env=STG')
35
35
  response = LHC.get(:kpi_tracker, params: { entity_id: 123, type: 'request', env: 'STG' })
36
36
  end
37
37
 
38
38
  it 'raises in case of claching endpoint names' do
39
39
  expect(->{
40
- LHC.config.endpoint(:kpi_tracker, 'http://kpi-tracker.lb-service')
40
+ LHC.config.endpoint(:kpi_tracker, 'http://kpi-tracker')
41
41
  }).to raise_error 'Endpoint already exists for that name'
42
42
  end
43
43
 
44
44
  it 'enforces endpoint name to be a symbol' do
45
- LHC.configure { |c| c.endpoint('datastore', 'http://datastore.lb-service') }
46
- expect(LHC.config.endpoints[:datastore].url).to eq 'http://datastore.lb-service'
45
+ LHC.configure { |c| c.endpoint('datastore', 'http://datastore') }
46
+ expect(LHC.config.endpoints[:datastore].url).to eq 'http://datastore'
47
47
  end
48
48
  end
49
49
 
50
50
  context 'configured enpoints with default params' do
51
51
 
52
52
  before(:each) do
53
- LHC.config.endpoint(:telemarketers, 'http://datastore.lb-service/v2/spamnumbers?order_by=-user_frequency&swiss_number=true&offset=0&limit=:limit', params: { limit: 200 })
54
- stub_request(:get, 'http://datastore.lb-service/v2/spamnumbers?limit=200&offset=0&order_by=-user_frequency&swiss_number=true')
53
+ LHC.config.endpoint(:telemarketers, 'http://datastore/v2/spamnumbers?order_by=-user_frequency&swiss_number=true&offset=0&limit=:limit', params: { limit: 200 })
54
+ stub_request(:get, 'http://datastore/v2/spamnumbers?limit=200&offset=0&order_by=-user_frequency&swiss_number=true')
55
55
  .to_return(status: 200)
56
56
  end
57
57
 
@@ -5,28 +5,28 @@ describe LHC do
5
5
  context 'configuration of placeholders' do
6
6
 
7
7
  it 'uses values for placeholders defined globally' do
8
- LHC.configure { |c| c.placeholder(:datastore, 'http://datastore.lb-service/v2') }
9
- stub_request(:get, "http://datastore.lb-service/v2/feedbacks")
8
+ LHC.configure { |c| c.placeholder(:datastore, 'http://datastore/v2') }
9
+ stub_request(:get, "http://datastore/v2/feedbacks")
10
10
  LHC.get(':datastore/feedbacks')
11
11
  end
12
12
 
13
13
  it 'uses explicit values first' do
14
14
  LHC.configure {|c| c.placeholder(:campaign_id, '123') }
15
- stub_request(:get, 'http://datastore-stg.lb-service/v2/campaign/456/feedbacks')
16
- url = 'http://datastore-stg.lb-service/v2/campaign/:campaign_id/feedbacks'
15
+ stub_request(:get, 'http://datastore/v2/campaign/456/feedbacks')
16
+ url = 'http://datastore/v2/campaign/:campaign_id/feedbacks'
17
17
  LHC.get(url, params: { campaign_id: '456' })
18
18
  end
19
19
 
20
20
  it 'raises in case of claching placeholder name' do
21
- LHC.configure { |c| c.placeholder(:datastore, 'http://datastore.lb-service') }
21
+ LHC.configure { |c| c.placeholder(:datastore, 'http://datastore') }
22
22
  expect(->{
23
- LHC.config.placeholder(:datastore, 'http://datastore-stg.lb-service')
23
+ LHC.config.placeholder(:datastore, 'http://datastore')
24
24
  }).to raise_error 'Placeholder already exists for that name'
25
25
  end
26
26
 
27
27
  it 'enforces placeholder name to be a symbol' do
28
- LHC.configure { |c| c.placeholder('datatore', 'http://datastore.lb-service') }
29
- expect(LHC.config.placeholders[:datatore]).to eq 'http://datastore.lb-service'
28
+ LHC.configure { |c| c.placeholder('datatore', 'http://datastore') }
29
+ expect(LHC.config.placeholders[:datatore]).to eq 'http://datastore'
30
30
  end
31
31
  end
32
32
  end
@@ -7,19 +7,19 @@ describe LHC::Endpoint do
7
7
  it 'uses parameters for interpolation' do
8
8
  endpoint = LHC::Endpoint.new(':datastore/v2/:campaign_id/feedbacks')
9
9
  expect(
10
- endpoint.compile(datastore: 'http://datastore.lb-service', campaign_id: 'abc')
11
- ).to eq "http://datastore.lb-service/v2/abc/feedbacks"
10
+ endpoint.compile(datastore: 'http://datastore', campaign_id: 'abc')
11
+ ).to eq "http://datastore/v2/abc/feedbacks"
12
12
  end
13
13
 
14
14
  it 'uses provided proc to find values' do
15
15
  endpoint = LHC::Endpoint.new(':datastore/v2')
16
- config = { datastore: 'http://datastore.lb-service' }
16
+ config = { datastore: 'http://datastore' }
17
17
  find_value = ->(match){
18
18
  config[match.gsub(':', '').to_sym]
19
19
  }
20
20
  expect(
21
21
  endpoint.compile(find_value)
22
- ).to eq "http://datastore.lb-service/v2"
22
+ ).to eq "http://datastore/v2"
23
23
  end
24
24
  end
25
25
  end
@@ -4,13 +4,13 @@ describe LHC::Endpoint do
4
4
 
5
5
  it 'removes params used for interpolation' do
6
6
  params = {
7
- datastore: 'http://datastore.lb-service',
7
+ datastore: 'http://datastore',
8
8
  campaign_id: 'abc',
9
9
  has_reviews: true
10
10
  }
11
11
  endpoint = LHC::Endpoint.new(':datastore/v2/:campaign_id/feedbacks')
12
12
  removed = endpoint.remove_interpolated_params!(params)
13
13
  expect(params).to eq ({ has_reviews: true })
14
- expect(removed).to eq(datastore: 'http://datastore.lb-service', campaign_id: 'abc')
14
+ expect(removed).to eq(datastore: 'http://datastore', campaign_id: 'abc')
15
15
  end
16
16
  end
@@ -6,15 +6,15 @@ describe LHC::Endpoint do
6
6
 
7
7
  it 'provides params extracting values from a provided url and template' do
8
8
  [
9
- [':datastore/v2/places', 'http://silo1.intra.local.ch:8082/v2/places', {
10
- datastore: 'http://silo1.intra.local.ch:8082'
9
+ [':datastore/v2/places', 'http://local.ch:8082/v2/places', {
10
+ datastore: 'http://local.ch:8082'
11
11
  }],
12
- [':datastore/v2/places/:id', 'http://silo1.intra.local.ch:8082/v2/places/ZW9OJyrbt4OZE9ueu80w-A', {
13
- datastore: 'http://silo1.intra.local.ch:8082',
12
+ [':datastore/v2/places/:id', 'http://local.ch:8082/v2/places/ZW9OJyrbt4OZE9ueu80w-A', {
13
+ datastore: 'http://local.ch:8082',
14
14
  id: 'ZW9OJyrbt4OZE9ueu80w-A'
15
15
  }],
16
- [':datastore/v2/places/:namespace/:id', 'http://silo1.intra.local.ch:8082/v2/places/switzerland/ZW9OJyrbt', {
17
- datastore: 'http://silo1.intra.local.ch:8082',
16
+ [':datastore/v2/places/:namespace/:id', 'http://local.ch:8082/v2/places/switzerland/ZW9OJyrbt', {
17
+ datastore: 'http://local.ch:8082',
18
18
  namespace: 'switzerland',
19
19
  id: 'ZW9OJyrbt'
20
20
  }],
@@ -3,9 +3,9 @@ require 'rails_helper'
3
3
  describe LHC::Request do
4
4
 
5
5
  it 'does not alter the options that where passed' do
6
- LHC.configure { |c| c.endpoint(:kpi_tracker, 'http://analytics.lb-service/track/:entity_id/w', { params: { env: 'PROD' } }) }
6
+ LHC.configure { |c| c.endpoint(:kpi_tracker, 'http://analytics/track/:entity_id/w', { params: { env: 'PROD' } }) }
7
7
  options = { params: { entity_id: '123' } }
8
- stub_request(:get, "http://analytics.lb-service/track/123/w?env=PROD")
8
+ stub_request(:get, "http://analytics/track/123/w?env=PROD")
9
9
  LHC.get(:kpi_tracker, options)
10
10
  expect(options).to eq({ params: { entity_id: '123' } })
11
11
  end
@@ -6,14 +6,14 @@ describe LHC::Request do
6
6
  options = { params: {
7
7
  has_reviews: true
8
8
  }}
9
- url = 'http://datastore-stg.lb-service/v2/campaign/:campaign_id/feedbacks'
9
+ url = 'http://datastore/v2/campaign/:campaign_id/feedbacks'
10
10
  LHC.configure { |c| c.endpoint(:feedbacks, url, options) }
11
- stub_request(:get, 'http://datastore-stg.lb-service/v2/campaign/123/feedbacks?has_reviews=true')
11
+ stub_request(:get, 'http://datastore/v2/campaign/123/feedbacks?has_reviews=true')
12
12
  LHC.get(:feedbacks, params:{campaign_id: 123})
13
13
  end
14
14
 
15
15
  it 'compiles url when doing a request' do
16
- stub_request(:get, 'http://datastore-stg.lb-service:8080/v2/feedbacks/123')
17
- LHC.get('http://datastore-stg.lb-service:8080/v2/feedbacks/:id', params:{id: 123})
16
+ stub_request(:get, 'http://datastore:8080/v2/feedbacks/123')
17
+ LHC.get('http://datastore:8080/v2/feedbacks/:id', params:{id: 123})
18
18
  end
19
19
  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.1.1
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - local.ch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-03 00:00:00.000000000 Z
11
+ date: 2015-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -119,6 +119,9 @@ files:
119
119
  - Gemfile
120
120
  - README.md
121
121
  - Rakefile
122
+ - cider-ci.yml
123
+ - cider-ci/contexts/rspec.yml
124
+ - cider-ci/jobs/tests.yml
122
125
  - docs/configuration.md
123
126
  - docs/exceptions.md
124
127
  - docs/interceptors.md
@@ -127,6 +130,7 @@ files:
127
130
  - lhc.gemspec
128
131
  - lib/lhc.rb
129
132
  - lib/lhc/concerns/lhc/basic_methods.rb
133
+ - lib/lhc/concerns/lhc/formats.rb
130
134
  - lib/lhc/config.rb
131
135
  - lib/lhc/endpoint.rb
132
136
  - lib/lhc/error.rb
@@ -134,6 +138,7 @@ files:
134
138
  - lib/lhc/errors/server_error.rb
135
139
  - lib/lhc/errors/timeout.rb
136
140
  - lib/lhc/errors/unknown_error.rb
141
+ - lib/lhc/formats/json.rb
137
142
  - lib/lhc/interceptor.rb
138
143
  - lib/lhc/interceptor_processor.rb
139
144
  - lib/lhc/request.rb