otpor 0.1.0 → 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: d65aa7219b3a7e0218aceb14abc70ffa459989de2421eb8dddf56eb9e902462f
4
- data.tar.gz: 491bb18692f97fe0525c01f87ba99a89f78576208b8fa16e2d35eb92d90808e7
3
+ metadata.gz: 4340270f71be5b4cbd00baccd71c95a2c033a39471929a462fb03afde8130aa8
4
+ data.tar.gz: a409d5bda7dece03040e0dcb2cf4708aa17d686e554526430309246aa961562f
5
5
  SHA512:
6
- metadata.gz: bedbe5c976532ce83c83ee2e99d864cf9be6f223ac2834d382791128a09022ec4fab145e728c980b819b25900390989a5f66cde56b3587cca37346f2e44cbe81
7
- data.tar.gz: 55b496f6d2b6bfb4d56f3a92f7e0456d6741d941cf53764357ae53cbe1f6705d6088df1a0d50b850c43db7b19c13fded9a7c7d37dc862de5d89c725cb33b433e
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.0"
4
+ VERSION = "0.2.1"
5
5
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: otpor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
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-21 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
- name: rails
14
+ name: jbuilder
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 5.0.0
19
+ version: 2.12.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: 5.0.0
26
+ version: 2.12.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: kaminari
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -39,19 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.2.2
41
41
  - !ruby/object:Gem::Dependency
42
- name: jbuilder
42
+ name: rails
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 2.12.0
47
+ version: 5.0.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 2.12.0
54
+ version: 5.0.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: request_store
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -110,7 +110,10 @@ files:
110
110
  homepage: https://github.com/renan-garcia/otpor
111
111
  licenses:
112
112
  - MIT
113
- metadata: {}
113
+ metadata:
114
+ changelog_uri: https://github.com/renan-garcia/otpor/main/CHANGELOG.md
115
+ source_code_uri: https://github.com/renan-garcia/otpor/
116
+ rubygems_mfa_required: 'true'
114
117
  post_install_message:
115
118
  rdoc_options: []
116
119
  require_paths: