active_record_api-request 0.1.2 → 0.1.3

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
  SHA256:
3
- metadata.gz: 102d3a90af469696deab008415af7876435723a1abefba3f9a6a77cd4e0ded3c
4
- data.tar.gz: dbc653aac113569109d5c1ad0d4f5e570c515823cbfc758a9bf215c6ea41bdda
3
+ metadata.gz: c9b1c727ec4ee388980af548ae528f864c0f3896ca8e864a28a24b1150a7fd24
4
+ data.tar.gz: ea10096b28d8c450fd094beae5957db04e410270eb80ce36de2912e32d0b0f1b
5
5
  SHA512:
6
- metadata.gz: 603749044688bbb163af6838e9b131b0f73337f44d03a90d2c9e9e864cb1cf947e14648dcb18204a52ddda88a747c45d6e9402f940ef7bc25dc0bf4c0545be34
7
- data.tar.gz: 5ef2f6f1e37c632729542df0a92f84f06a9c5e10ae3478c2675fe6a7502bbe07c8335ca0cb62df4d1a1fee18cc2659da393b80696a04480a43868075698b5837
6
+ metadata.gz: 9b829fe9aa579c3b8728343277c8ffe06de97c09329d0701fa3ac8070d31648b4aec4ca811097a4b91fd9490da875238ef82a8572c97a0dcbf040564a96224cd
7
+ data.tar.gz: 84381b29e5bf6aa27f2b0a1678fd8f10e450fe31d4f6444090bbb102ec3d759beec9bd1eebd6fe11f61c042a511698fa45f592d59488528bf95f3d736f1816ae
@@ -10,5 +10,6 @@ module ActiveRecordApi
10
10
  autoload :Connection
11
11
  autoload :FaradayFollowNextLinks
12
12
  autoload :FaradayCacheServiceDown
13
+ autoload :MicroServices
13
14
  end
14
15
  end
@@ -31,7 +31,12 @@ module ActiveRecordApi
31
31
  end
32
32
 
33
33
  def full_url
34
- @full_url ||= "#{strip_trailing_slash(host)}/#{strip_trailing_slash(path)}"
34
+ @full_url ||= "#{strip_trailing_slash(host)}#{strip_double_slash("/#{strip_trailing_slash(path)}")}"
35
+ end
36
+
37
+ def service_url(suffix)
38
+ parts = full_url.split('/')
39
+ "#{parts[0]}//#{parts[2]}/#{parts[3]}/#{parts[4]}#{strip_double_slash("/#{suffix}")}"
35
40
  end
36
41
 
37
42
  def full_url_with_params(params: {}, id: nil)
@@ -49,7 +54,13 @@ module ActiveRecordApi
49
54
  end
50
55
 
51
56
  def http_cache_options
52
- { shared_cache: false, store: cache_store }
57
+ http_cache_options = { shared_cache: false, store: cache_store }
58
+ http_cache_options[:logger] = Rails.logger if debug
59
+ http_cache_options
60
+ end
61
+
62
+ def strip_double_slash(string)
63
+ string.gsub(%r{//}, '/')
53
64
  end
54
65
 
55
66
  def strip_trailing_slash(string)
@@ -16,6 +16,14 @@ module ActiveRecordApi
16
16
  def put(id:, payload:, params: {})
17
17
  symbolize_response(authenticated_connection.put(full_url_with_params(id: id, params: params), payload).body)
18
18
  end
19
+
20
+ def service_healthy?
21
+ authenticated_connection.get(service_url(health_endpoint)).body.dig('default', 'success')
22
+ end
23
+
24
+ def health_endpoint
25
+ '/okcomputer/all.json'
26
+ end
19
27
  end
20
28
  end
21
29
  end
@@ -0,0 +1,15 @@
1
+ module ActiveRecordApi
2
+ module Request
3
+ module MicroServices
4
+ MICRO_SERVICE_PATHS.each do |path_hash|
5
+ klass = Class.new(Methods) do
6
+ define_method :path do
7
+ "#{path_hash[:service_path]}/#{path_hash[:model_path]}"
8
+ end
9
+ end
10
+ klass_name = klass.new.path.tr('/', '_').gsub(/[^a-z_]/i, '').camelcase
11
+ const_set klass_name, klass
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
1
  module ActiveRecordApi
2
2
  module Request
3
- VERSION = '0.1.2'.freeze
3
+ VERSION = '0.1.3'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_api-request
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Full Measure Education
@@ -181,6 +181,7 @@ files:
181
181
  - lib/active_record_api/request/faraday_cache_service_down.rb
182
182
  - lib/active_record_api/request/faraday_follow_next_links.rb
183
183
  - lib/active_record_api/request/methods.rb
184
+ - lib/active_record_api/request/micro_services.rb
184
185
  - lib/active_record_api/request/version.rb
185
186
  homepage: https://gitlab.com/fullmeasure/public/gems/active_record_api-request
186
187
  licenses: