lhs 14.6.5 → 15.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/README.md +68 -68
  4. data/lhs.gemspec +1 -1
  5. data/lib/lhs/concerns/record/endpoints.rb +1 -1
  6. data/lib/lhs/concerns/record/request.rb +1 -1
  7. data/lib/lhs/version.rb +1 -1
  8. data/spec/autoloading_spec.rb +2 -2
  9. data/spec/collection/collection_items_spec.rb +1 -1
  10. data/spec/collection/configurable_spec.rb +1 -1
  11. data/spec/collection/meta_data_spec.rb +4 -4
  12. data/spec/collection/without_object_items_spec.rb +1 -1
  13. data/spec/data/collection_spec.rb +1 -1
  14. data/spec/data/inspect_spec.rb +1 -1
  15. data/spec/data/item_spec.rb +2 -2
  16. data/spec/data/merge_spec.rb +2 -2
  17. data/spec/data/raw_spec.rb +3 -3
  18. data/spec/data/root_spec.rb +3 -3
  19. data/spec/data/select_spec.rb +1 -1
  20. data/spec/data/to_json_spec.rb +2 -2
  21. data/spec/dummy/app/models/user.rb +1 -1
  22. data/spec/endpoint/for_url_spec.rb +6 -6
  23. data/spec/item/becomes_spec.rb +2 -2
  24. data/spec/item/delegate_spec.rb +2 -2
  25. data/spec/item/destroy_spec.rb +3 -3
  26. data/spec/item/dig_spec.rb +1 -1
  27. data/spec/item/errors_spec.rb +2 -2
  28. data/spec/item/fetch_spec.rb +1 -1
  29. data/spec/item/getter_spec.rb +2 -2
  30. data/spec/item/internal_data_structure_spec.rb +2 -2
  31. data/spec/item/map_spec.rb +1 -1
  32. data/spec/item/partial_update_spec.rb +4 -4
  33. data/spec/item/save_spec.rb +2 -2
  34. data/spec/item/setter_spec.rb +2 -2
  35. data/spec/item/update_spec.rb +2 -2
  36. data/spec/item/validation_spec.rb +2 -2
  37. data/spec/pagination/pages_left_spec.rb +1 -1
  38. data/spec/proxy/create_sub_resource_spec.rb +2 -2
  39. data/spec/proxy/load_spec.rb +2 -2
  40. data/spec/proxy/record_identification_spec.rb +1 -1
  41. data/spec/record/build_spec.rb +2 -2
  42. data/spec/record/cast_nested_data_spec.rb +6 -6
  43. data/spec/record/create_spec.rb +2 -2
  44. data/spec/record/creation_failed_spec.rb +2 -2
  45. data/spec/record/definitions_spec.rb +2 -2
  46. data/spec/record/destroy_spec.rb +1 -1
  47. data/spec/record/endpoint_inheritance_spec.rb +3 -3
  48. data/spec/record/endpoint_misconfiguration_spec.rb +4 -4
  49. data/spec/record/endpoint_options_spec.rb +1 -1
  50. data/spec/record/endpoints_spec.rb +19 -19
  51. data/spec/record/find_by_spec.rb +4 -4
  52. data/spec/record/find_each_spec.rb +2 -2
  53. data/spec/record/find_in_batches_spec.rb +4 -4
  54. data/spec/record/find_in_parallel_spec.rb +1 -1
  55. data/spec/record/find_spec.rb +4 -4
  56. data/spec/record/first_spec.rb +2 -2
  57. data/spec/record/has_many_spec.rb +1 -1
  58. data/spec/record/ignore_errors_spec.rb +1 -1
  59. data/spec/record/includes_all_spec.rb +7 -7
  60. data/spec/record/includes_spec.rb +28 -28
  61. data/spec/record/includes_warning_spec.rb +1 -1
  62. data/spec/record/item_key_spec.rb +1 -1
  63. data/spec/record/loading_twice_spec.rb +2 -2
  64. data/spec/record/mapping_spec.rb +5 -5
  65. data/spec/record/model_name_spec.rb +1 -1
  66. data/spec/record/new_spec.rb +3 -3
  67. data/spec/record/options_spec.rb +2 -2
  68. data/spec/record/paginatable_collection_spec.rb +4 -4
  69. data/spec/record/pagination_chain_spec.rb +3 -3
  70. data/spec/record/pagination_spec.rb +1 -1
  71. data/spec/record/persisted_spec.rb +1 -1
  72. data/spec/record/references_spec.rb +1 -1
  73. data/spec/record/reload_by_id_spec.rb +2 -2
  74. data/spec/record/reload_spec.rb +2 -2
  75. data/spec/record/request_spec.rb +6 -6
  76. data/spec/record/save_spec.rb +1 -1
  77. data/spec/record/scope_chains_spec.rb +1 -1
  78. data/spec/record/to_json_spec.rb +1 -1
  79. data/spec/record/where_chains_spec.rb +1 -1
  80. data/spec/record/where_spec.rb +2 -2
  81. data/spec/record/where_values_hash_spec.rb +1 -1
  82. data/spec/request_cycle_cache/main_spec.rb +1 -1
  83. data/spec/views/form_for_spec.rb +1 -1
  84. metadata +5 -5
@@ -4,7 +4,7 @@ describe LHS::Record do
4
4
  context 'includes warning' do
5
5
  before(:each) do
6
6
  class Customer < LHS::Record
7
- endpoint 'http://datastore/customers/:id'
7
+ endpoint 'http://datastore/customers/{id}'
8
8
  end
9
9
  end
10
10
 
@@ -5,7 +5,7 @@ describe LHS::Record do
5
5
  class Location < LHS::Record
6
6
  configuration item_key: [:response, :location]
7
7
  endpoint 'http://uberall/location'
8
- endpoint 'http://uberall/location/:id'
8
+ endpoint 'http://uberall/location/{id}'
9
9
  end
10
10
  end
11
11
 
@@ -6,11 +6,11 @@ describe LHS::Record do
6
6
 
7
7
  it 'is possible to load records twice' do
8
8
  class Feedback < LHS::Record
9
- endpoint ':datastore/feedbacks'
9
+ endpoint '{+datastore}/feedbacks'
10
10
  end
11
11
 
12
12
  class Feedback < LHS::Record
13
- endpoint ':datastore/feedbacks'
13
+ endpoint '{+datastore}/feedbacks'
14
14
  end
15
15
  end
16
16
  end
@@ -7,8 +7,8 @@ describe LHS::Record do
7
7
  before(:each) do
8
8
  LHC.config.placeholder('datastore', datastore)
9
9
  class LocalEntry < LHS::Record
10
- endpoint ':datastore/local-entries'
11
- endpoint ':datastore/local-entries/:id'
10
+ endpoint '{+datastore}/local-entries'
11
+ endpoint '{+datastore}/local-entries/{id}'
12
12
  end
13
13
  end
14
14
 
@@ -50,7 +50,7 @@ describe LHS::Record do
50
50
 
51
51
  it 'clones mappings when using include' do
52
52
  class Agb < LHS::Record
53
- endpoint ":datastore/agbs/active?agb_type=CC_TOU"
53
+ endpoint "{+datastore}/agbs/active?agb_type=CC_TOU"
54
54
  def pdf_url
55
55
  self['binary_url_pdf_de']
56
56
  end
@@ -84,8 +84,8 @@ describe LHS::Record do
84
84
  end
85
85
  end
86
86
  class Favorite < LHS::Record
87
- endpoint ':datastore/favorites'
88
- endpoint ':datastore/favorites/:id'
87
+ endpoint '{+datastore}/favorites'
88
+ endpoint '{+datastore}/favorites/{id}'
89
89
  end
90
90
  stub_request(:get, "#{datastore}/local-entries/1")
91
91
  .to_return(body: { company_name: 'local.ch' }.to_json)
@@ -4,7 +4,7 @@ describe LHS::Record do
4
4
  context 'model_name' do
5
5
  before(:each) do
6
6
  class LocalEntry < LHS::Record
7
- endpoint ':datastore/local-entries'
7
+ endpoint '{+datastore}/local-entries'
8
8
  end
9
9
  end
10
10
 
@@ -7,8 +7,8 @@ describe LHS::Record do
7
7
  before(:each) do
8
8
  LHC.config.placeholder('datastore', datastore)
9
9
  class Rating < LHS::Record
10
- endpoint ':datastore/content-ads/:campaign_id/feedbacks'
11
- endpoint ':datastore/feedbacks'
10
+ endpoint '{+datastore}/content-ads/{campaign_id}/feedbacks'
11
+ endpoint '{+datastore}/feedbacks'
12
12
  end
13
13
  end
14
14
 
@@ -29,7 +29,7 @@ describe LHS::Record do
29
29
  context 'initialise records with raw data' do
30
30
  before(:each) do
31
31
  class User < LHS::Record
32
- endpoint ':datastore/users'
32
+ endpoint '{+datastore}/users'
33
33
  end
34
34
  end
35
35
 
@@ -8,7 +8,7 @@ describe LHS::Record do
8
8
  before(:each) do
9
9
  LHC.config.placeholder('datastore', datastore)
10
10
  class Record < LHS::Record
11
- endpoint ':datastore/records', validates: { persist: false }
11
+ endpoint '{+datastore}/records', validates: { persist: false }
12
12
  end
13
13
  end
14
14
 
@@ -143,7 +143,7 @@ describe LHS::Record do
143
143
  before(:each) do
144
144
  stub_request(:post, 'http://datastore/v2/records?persist=false').to_return(body: {}.to_json)
145
145
  expect(LHC).to receive(:request)
146
- .with(options.merge(url: ':datastore/records', method: :post, params: { persist: false }, body: "{\"href\":\"http://datastore/v2/records/123\"}", headers: { "Content-Type" => "application/json" }))
146
+ .with(options.merge(url: '{+datastore}/records', method: :post, params: { persist: false }, body: "{\"href\":\"http://datastore/v2/records/123\"}", headers: { "Content-Type" => "application/json" }))
147
147
  .and_call_original
148
148
  end
149
149
 
@@ -8,7 +8,7 @@ describe LHS::Record do
8
8
  context 'default pagination behaviour' do
9
9
  before(:each) do
10
10
  class Record < LHS::Record
11
- endpoint ':datastore/feedbacks'
11
+ endpoint '{+datastore}/feedbacks'
12
12
  end
13
13
  end
14
14
 
@@ -52,7 +52,7 @@ describe LHS::Record do
52
52
  before(:each) do
53
53
  class Record < LHS::Record
54
54
  configuration pagination_strategy: 'offset', pagination_key: 'offset'
55
- endpoint ':datastore/feedbacks'
55
+ endpoint '{+datastore}/feedbacks'
56
56
  end
57
57
  end
58
58
 
@@ -132,7 +132,7 @@ describe LHS::Record do
132
132
  before(:each) do
133
133
  class Record < LHS::Record
134
134
  configuration pagination_strategy: 'page', pagination_key: 'page'
135
- endpoint ':datastore/feedbacks'
135
+ endpoint '{+datastore}/feedbacks'
136
136
  end
137
137
  end
138
138
 
@@ -210,7 +210,7 @@ describe LHS::Record do
210
210
  before(:each) do
211
211
  class Record < LHS::Record
212
212
  configuration pagination_strategy: 'start', pagination_key: 'start'
213
- endpoint ':datastore/feedbacks'
213
+ endpoint '{+datastore}/feedbacks'
214
214
  end
215
215
  end
216
216
 
@@ -6,7 +6,7 @@ describe LHS::Record do
6
6
  before(:each) do
7
7
  class Record < LHS::Record
8
8
  endpoint 'http://local.ch/records'
9
- endpoint 'http://local.ch/records/:id'
9
+ endpoint 'http://local.ch/records/{id}'
10
10
  end
11
11
  end
12
12
 
@@ -59,7 +59,7 @@ describe LHS::Record do
59
59
  class Record < LHS::Record
60
60
  configuration pagination_strategy: 'start', pagination_key: 'start'
61
61
  endpoint 'http://local.ch/records'
62
- endpoint 'http://local.ch/records/:id'
62
+ endpoint 'http://local.ch/records/{id}'
63
63
  end
64
64
  end
65
65
 
@@ -80,7 +80,7 @@ describe LHS::Record do
80
80
  class Record < LHS::Record
81
81
  configuration pagination_strategy: 'page', pagination_key: 'page'
82
82
  endpoint 'http://local.ch/records'
83
- endpoint 'http://local.ch/records/:id'
83
+ endpoint 'http://local.ch/records/{id}'
84
84
  end
85
85
  end
86
86
 
@@ -23,7 +23,7 @@ describe LHS::Record do
23
23
  before(:each) do
24
24
  LHC.config.placeholder('datastore', datastore)
25
25
  class Feedback < LHS::Record
26
- endpoint ':datastore/feedbacks'
26
+ endpoint '{+datastore}/feedbacks'
27
27
  end
28
28
  stub_request(:get, 'http://local.ch/v2/feedbacks?entry_id=1')
29
29
  .to_return(body: body_json)
@@ -7,7 +7,7 @@ describe LHS::Record do
7
7
  before(:each) do
8
8
  LHC.config.placeholder('datastore', datastore)
9
9
  class Feedback < LHS::Record
10
- endpoint ':datastore/content-ads/:campaign_id/feedbacks'
10
+ endpoint '{+datastore}/content-ads/{campaign_id}/feedbacks'
11
11
  end
12
12
  end
13
13
 
@@ -4,7 +4,7 @@ describe LHS::Record do
4
4
  context 'references' do
5
5
  before(:each) do
6
6
  class Customer < LHS::Record
7
- endpoint 'http://datastore/customers/:id'
7
+ endpoint 'http://datastore/customers/{id}'
8
8
  end
9
9
  end
10
10
 
@@ -4,12 +4,12 @@ describe LHS::Record do
4
4
  before(:each) do
5
5
  class Record < LHS::Record
6
6
  endpoint 'http://datastore/records'
7
- endpoint 'http://datastore/records/:id'
7
+ endpoint 'http://datastore/records/{id}'
8
8
  end
9
9
 
10
10
  class AnotherRecord < LHS::Record
11
11
  endpoint 'http://datastore/otherrecords'
12
- endpoint 'http://datastore/otherrecords/:id'
12
+ endpoint 'http://datastore/otherrecords/{id}'
13
13
 
14
14
  def id
15
15
  another_id
@@ -4,7 +4,7 @@ describe LHS::Record do
4
4
  before(:each) do
5
5
  class Record < LHS::Record
6
6
  endpoint 'http://datastore/records'
7
- endpoint 'http://datastore/records/:id'
7
+ endpoint 'http://datastore/records/{id}'
8
8
  end
9
9
  end
10
10
 
@@ -27,7 +27,7 @@ describe LHS::Record do
27
27
  before(:each) do
28
28
  class Location < LHS::Record
29
29
  endpoint 'http://uberall/locations'
30
- endpoint 'http://uberall/locations/:id'
30
+ endpoint 'http://uberall/locations/{id}'
31
31
 
32
32
  configuration item_key: [:response, :location], items_key: [:response, :locations]
33
33
  end
@@ -3,7 +3,7 @@ require 'rails_helper'
3
3
  describe LHS::Record do
4
4
  before(:each) do
5
5
  class Record < LHS::Record
6
- endpoint 'http://datastore/feedbacks/:id'
6
+ endpoint 'http://datastore/feedbacks/{id}'
7
7
  end
8
8
  end
9
9
 
@@ -13,8 +13,8 @@ describe LHS::Record do
13
13
  before(:each) do
14
14
  LHC.config.placeholder(:datastore, datastore)
15
15
  class Record < LHS::Record
16
- endpoint ':datastore/content-ads/:campaign_id/feedbacks'
17
- endpoint ':datastore/feedbacks'
16
+ endpoint '{+datastore}/content-ads/{campaign_id}/feedbacks'
17
+ endpoint '{+datastore}/feedbacks'
18
18
  end
19
19
  end
20
20
 
@@ -28,20 +28,20 @@ describe LHS::Record do
28
28
  context '#convert_options_to_endpoint' do
29
29
  before(:each) do
30
30
  class Record < LHS::Record
31
- endpoint 'http://datastore/feedbacks/:id', params: { tracking: 123 }
31
+ endpoint 'http://datastore/feedbacks/{id}', params: { tracking: 123 }
32
32
  end
33
33
  end
34
34
 
35
35
  it 'identifies endpoint by given url and merges back endpoint template parameters' do
36
36
  options = LHS::Record.send(:convert_options_to_endpoints, url: 'http://datastore/feedbacks/1')
37
37
  expect(options[:params][:id]).to eq '1'
38
- expect(options[:url]).to eq 'http://datastore/feedbacks/:id'
38
+ expect(options[:url]).to eq 'http://datastore/feedbacks/{id}'
39
39
  end
40
40
 
41
41
  it 'identifies endpoint by given url and merges back endpoint template parameters into an array, if array was given' do
42
42
  options = LHS::Record.send(:convert_options_to_endpoints, [{ url: 'http://datastore/feedbacks/1' }])
43
43
  expect(options[0][:params][:id]).to eq '1'
44
- expect(options[0][:url]).to eq 'http://datastore/feedbacks/:id'
44
+ expect(options[0][:url]).to eq 'http://datastore/feedbacks/{id}'
45
45
  end
46
46
 
47
47
  it 'returnes nil if endpoint was not found for the given url' do
@@ -6,7 +6,7 @@ describe LHS::Record do
6
6
  before do
7
7
  LHC.config.placeholder('datastore', datastore)
8
8
  class Feedback < LHS::Record
9
- endpoint ':datastore/content-ads/:campaign_id/feedbacks'
9
+ endpoint '{+datastore}/content-ads/{campaign_id}/feedbacks'
10
10
  end
11
11
  end
12
12
 
@@ -12,7 +12,7 @@ describe LHS::Record do
12
12
  before(:each) do
13
13
  LHC.config.placeholder('datastore', datastore)
14
14
  class Record < LHS::Record
15
- endpoint ':datastore/records/'
15
+ endpoint '{+datastore}/records/'
16
16
  scope :blue, -> { where(color: 'blue') }
17
17
  scope :available, -> { where(availalbe: 'true') }
18
18
  scope :limited_to, ->(limit) { where(limit: limit) }
@@ -7,7 +7,7 @@ describe LHS::Record do
7
7
  before(:each) do
8
8
  LHC.config.placeholder('datastore', datastore)
9
9
  class Feedback < LHS::Record
10
- endpoint ':datastore/feedbacks'
10
+ endpoint '{+datastore}/feedbacks'
11
11
  end
12
12
  end
13
13
 
@@ -12,7 +12,7 @@ describe LHS::Record do
12
12
  before(:each) do
13
13
  LHC.config.placeholder('datastore', datastore)
14
14
  class Record < LHS::Record
15
- endpoint ':datastore/records/'
15
+ endpoint '{+datastore}/records/'
16
16
 
17
17
  def uppercase_name
18
18
  name.upcase
@@ -8,8 +8,8 @@ describe LHS::Record do
8
8
  before(:each) do
9
9
  LHC.config.placeholder('datastore', datastore)
10
10
  class Record < LHS::Record
11
- endpoint ':datastore/content-ads/:campaign_id/feedbacks'
12
- endpoint ':datastore/feedbacks'
11
+ endpoint '{+datastore}/content-ads/{campaign_id}/feedbacks'
12
+ endpoint '{+datastore}/feedbacks'
13
13
  end
14
14
  end
15
15
 
@@ -12,7 +12,7 @@ describe LHS::Record do
12
12
  before(:each) do
13
13
  LHC.config.placeholder('datastore', datastore)
14
14
  class Record < LHS::Record
15
- endpoint ':datastore/records/'
15
+ endpoint '{+datastore}/records/'
16
16
  end
17
17
  end
18
18
 
@@ -13,7 +13,7 @@ describe 'Request Cycle Cache', type: :request do
13
13
  before(:each) do
14
14
  class User < LHS::Record
15
15
  endpoint 'http://datastore/v2/users'
16
- endpoint 'http://datastore/v2/users/:id'
16
+ endpoint 'http://datastore/v2/users/{id}'
17
17
  end
18
18
  LHC.configure do |config|
19
19
  config.interceptors = [LHC::Caching]
@@ -3,7 +3,7 @@ require 'capybara/rspec'
3
3
 
4
4
  describe 'form_for helper' do
5
5
  class Feedback < LHS::Record
6
- endpoint ':datastore/v2/feedbacks'
6
+ endpoint '{+datastore}/v2/feedbacks'
7
7
  end
8
8
 
9
9
  before(:each) do
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: 14.6.5
4
+ version: 15.0.0
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: 2017-12-13 00:00:00.000000000 Z
11
+ date: 2018-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lhc
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 6.4.0
19
+ version: 7.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 6.4.0
26
+ version: 7.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -436,7 +436,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
436
436
  requirements:
437
437
  - Ruby >= 2.3.0
438
438
  rubyforge_project:
439
- rubygems_version: 2.6.8
439
+ rubygems_version: 2.6.14
440
440
  signing_key:
441
441
  specification_version: 4
442
442
  summary: Rails gem providing an easy, active-record-like interface for http json services