umts-microservices-engine 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c7059c5b4276cd799095a1159f55508e38f6dbc
4
- data.tar.gz: a62ec3df503d7974fa5c46667110aa45c9a3a3cf
3
+ metadata.gz: b7166a43b8566873abe89546e2c9bb0e3620bc53
4
+ data.tar.gz: ade4b9cf5322aa048a946c1e1aeedc35b2512822
5
5
  SHA512:
6
- metadata.gz: 80491981f5041d68c49e949d54fa75671bdf0631b599c113ba6d0419f557bb0b9f8947b8c88307290af8c3379fa08733fac3666d014a73edb33e4cad9a105971
7
- data.tar.gz: 8abfcf265e995c7d6fc00662c876959ff0a922926e7ee35635b0443c05177dfa976de608e06e5e7fea4663a232c79bcbfe3354f4613dbc6b1245eb2899500e00
6
+ metadata.gz: b83b037d3af5652428d19374ed0dab344b71b9dc13336bb18b09c32d48785f9c8c5041ba345ea66c6723c713dc851d1057a366c323de265209206927e535f054
7
+ data.tar.gz: 49c28abb01b77d05f0806d7bc7934ebf6b387bfa4373fb2219beedb02eee6fcf47cc203a56b86319d8afba83e3d186eb4030a51d225a05717408f6cd3a48b844
@@ -2,28 +2,27 @@
2
2
  require 'net/http'
3
3
  config_file = 'config/mse_router_info.yml'
4
4
 
5
+ REPORT_MISSING_CONFIG_KEY = -> (key) {
6
+ raise ArgumentError, "Missing key #{key} in config/initializers/mse_router_info.yml."
7
+ }
8
+
5
9
  unless File.file?(config_file)
6
- raise IOError, '[MSE] > No router configuration YAML file found'
10
+ raise IOError, 'No router configuration YAML file found'
7
11
  end
8
12
 
9
13
  config_data = YAML.load_file(config_file)
10
14
 
11
- if [config_data['name'], config_data['uri'], config_data['security_token']].any?(&:blank?)
12
- raise '[MSE] > Please fill out config/mse_router_info.yml'
13
- end
14
-
15
- # Make sure the URI ends with a / character
16
- router_uri = config_data['router_uri']
17
-
18
- uri = config_data['uri']
19
- uri += '/' if uri[-1] != '/'
15
+ service_name = config_data.fetch :name, &REPORT_MISSING_CONFIG_KEY
16
+ service_url = config_data.fetch :uri, &REPORT_MISSING_CONFIG_KEY
17
+ router_url = config_data.fetch :router_uri, &REPORT_MISSING_CONFIG_KEY
18
+ security_token = config_data.fetch :security_token, &REPORT_MISSING_CONFIG_KEY
20
19
 
21
20
  res = Net::HTTP.post_form(
22
- URI(router_uri),
23
- 'name': config_data['name'],
24
- 'url': uri,
25
- 'models': config_data['accessible_models'],
26
- 'security_token': config_data['security_token']
21
+ URI.parse(router_url),
22
+ name: service_name,
23
+ url: service_url,
24
+ models: config_data['accessible_models'],
25
+ security_token: security_token
27
26
  )
28
27
 
29
- raise '[MSE] > The router API response was invalid' if res.code != '200'
28
+ raise 'The router API response was invalid' if res.code != '200'
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module MicroservicesEngine
3
- VERSION = '0.0.6'
3
+ VERSION = '0.0.7'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: umts-microservices-engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - UMass Transportation Services