otpor 0.1.1 → 0.2.1

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
  SHA256:
3
- metadata.gz: e3ced36a01688e33c91ed19acb56db5cb5e2069e87690ca30d5291801d2ede9e
4
- data.tar.gz: c0914f535c28cd87f401e2e9d89d9d76af4afe2cdfa62425da73b568bb6f0524
3
+ metadata.gz: 4340270f71be5b4cbd00baccd71c95a2c033a39471929a462fb03afde8130aa8
4
+ data.tar.gz: a409d5bda7dece03040e0dcb2cf4708aa17d686e554526430309246aa961562f
5
5
  SHA512:
6
- metadata.gz: 11aae080122348da4b71e1e45676485ff89e742b2be873806766d96f10f24e088cfc34ca776881c029b69a82ce94b62ed707fc5ff16b9fb07b5c2eb9283609f8
7
- data.tar.gz: a698ec7378167155a9e48fa4112e9a1b2f72a6a2e96935817282b4f4cb90b836d8d57c2c34dd6348e31e47a296e3b733f2125afd5cf2d8c205d35380fb476d57
6
+ metadata.gz: ef54d3dd06854ec8c2fd6eccb796d67b8e6593e178c2586465d9728ae621f328814fde258bb7da2b25d71127b2f5bf73834bd98724f46c1119f7341bf10bebe8
7
+ data.tar.gz: 1ad41976acf90f647ca04b7d9d9857a9102211390c19fe25f192fdf864e04e02c8e360a955d0165deea90db6a2faa64f8ed2306fab2f2eb3ac3b0bc3aff59128
@@ -103,7 +103,23 @@ module Otpor
103
103
  end
104
104
 
105
105
  def infer_meta
106
- @instance_variables.each do |key, value|
106
+ pagination = infer_pagination
107
+ api_version = infer_api_version
108
+
109
+ return nil if pagination.nil? && api_version.nil?
110
+
111
+ meta = {}
112
+ meta = meta.merge(pagination) if pagination.present?
113
+ meta = meta.merge(api_version) if api_version.present?
114
+ meta
115
+ end
116
+
117
+ def infer_api_version
118
+ { api_version: "v#{::Regexp.last_match(1)}" } if request.path =~ %r{/v(\d+)/}
119
+ end
120
+
121
+ def infer_pagination
122
+ @instance_variables.each do |_key, value|
107
123
  next unless value.respond_to?(:total_pages)
108
124
 
109
125
  return {
@@ -11,4 +11,5 @@ end
11
11
  json.errors @errors
12
12
  json.notes @notes
13
13
  json.meta @meta
14
+ json.api_version @api_version if @api_version.present?
14
15
  json.exception_log @exception_log
data/lib/otpor/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Otpor
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: otpor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Renan Garcia
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-09-24 00:00:00.000000000 Z
11
+ date: 2024-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jbuilder