model_driven_api 3.11.0 → 3.11.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
  SHA256:
3
- metadata.gz: af8d0733bb1c7ad78521684f1e9cd36879ce8fd2edac11554fae77a8857446a3
4
- data.tar.gz: 8d4f390e60a0edc7fbbe8070145768c317524887643ac5afe055dd8675cfe87d
3
+ metadata.gz: f10db84ebc3b2fbb5b3461fcaa14c879096999fcdef4c90353172ac8313af7eb
4
+ data.tar.gz: ca43a58797580f249f6b48c80f3be07b607731a6a1973d04dc6d9af64adc654c
5
5
  SHA512:
6
- metadata.gz: 607eb70c78ea78450ed752a1351c038736a7ad5f6023b969acb560ea59e20b95a3ff54a718b26465e01420ced20131a23d325bc05f34540a7fa77b6df6677c96
7
- data.tar.gz: 22704e9424cdba8feb897dafb62710cf41ebe205dd36ca1d0a4356771c8b5419dfc1d823d2e73d03619c3bc9be4bb10c420a8a50829d396982ffac74cc8cfed7
6
+ metadata.gz: 39ca452f1c60589d6406de607425ce798a84882a366aa42ad648a8dc6b16e05e9535d6db18a8ea578b623ba6fcf1ec2a9c241a667369dd0fc03f505acad1a96f
7
+ data.tar.gz: 1c2dfe78a0c08f66eaf09bc6550213a988c42295549f0e7ffb23a66d13bea8a134ce52fb06dc60e65e67cca91f3dbe818929ffd5743bbc2cb460318e2551b982
@@ -6,7 +6,7 @@ class Api::V2::InfoController < Api::V2::ApplicationController
6
6
 
7
7
  # api :GET, '/api/v2/info/version', "Just prints the APPVERSION."
8
8
  def version
9
- render json: { version: "TODO: Find a Way to Dynamically Obtain It" }.to_json, status: 200
9
+ render json: { version: ModelDrivenApi.app_version }.to_json, status: 200
10
10
  end
11
11
 
12
12
  # api :GET, '/api/v2/info/roles'
@@ -3,7 +3,12 @@ module ApiExceptionManagement
3
3
 
4
4
  included do
5
5
  if Rails.env.production?
6
- rescue_from NoMethodError, with: :not_found!
6
+ # ORDER MATTERS: Rails tries rescue_from handlers from the LAST declared to the
7
+ # first, so the StandardError catch-all must be declared FIRST. Declared last (as it
8
+ # was until 3.11.0) it shadowed every specific handler below: in production every
9
+ # AccessDenied (wrong login credentials), RecordNotFound, RecordInvalid, CanCan
10
+ # denial... answered 500. Covered by spec/lib/concerns/api_exception_management_spec.rb.
11
+ rescue_from StandardError, with: :fivehundred!
7
12
  rescue_from CanCan::AccessDenied, with: :unauthorized!
8
13
  rescue_from AuthenticateUser::AccessDenied, with: :unauthenticated!
9
14
  rescue_from ActionController::RoutingError, with: :not_found!
@@ -17,8 +22,12 @@ module ApiExceptionManagement
17
22
  rescue_from ActiveRecord::RecordNotUnique, with: :invalid!
18
23
  # Rescue Stale Object in Optimistick locking with stale!
19
24
  rescue_from ActiveRecord::StaleObjectError, with: :stale!
20
- rescue_from EndpointValidationError, with: :api_error
21
- rescue_from StandardError, with: :fivehundred!
25
+ rescue_from EndpointValidationError, with: :endpoint_invalid!
26
+ end
27
+
28
+ # api_error takes keywords only, so it can't be a rescue_from handler itself.
29
+ def endpoint_invalid! exception = EndpointValidationError.new
30
+ return api_error status: 501, errors: exception.message
22
31
  end
23
32
 
24
33
  def stale! exception = StandardError.new
@@ -1,3 +1,3 @@
1
1
  module ModelDrivenApi
2
- VERSION = "3.11.0".freeze
2
+ VERSION = "3.11.2".freeze
3
3
  end
@@ -28,6 +28,14 @@ require "api/v3/serializer_factory"
28
28
  module ModelDrivenApi
29
29
  UTC_ZONE_NAMES = %w[UTC Etc/UTC].freeze
30
30
 
31
+ # The host app's deployed version: the `version` file in its root (Thecore release convention —
32
+ # CI builds and deploys when it changes; the image is `ADD . /app`, so it ships in Rails.root).
33
+ # nil when the app has no such file. Served by GET /api/v2|v3/info/version.
34
+ def self.app_version
35
+ file = Rails.root.join("version")
36
+ file.file? ? file.read.strip.presence : nil
37
+ end
38
+
31
39
  # Raises unless the app is UTC-only: +time_zone+ is config.time_zone, +db_zone+ is
32
40
  # config.active_record.default_timezone (nil = Rails' default, :utc). Called at boot by
33
41
  # ModelDrivenApi::Engine's :enforce_utc_time_zone initializer.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: model_driven_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.11.0
4
+ version: 3.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni