readme-metrics 2.2.0 → 2.3.0

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: 7e56a6d3e2f6345dcc6b17a00b3de12223b5982bbf2ed1d88c78e7bc6155a4a1
4
- data.tar.gz: 40223680001e31af74173f227cc0b56cd74ef5c0c81437328d2506a303482d2b
3
+ metadata.gz: e9d2cf2f3a6e81a4ee2658ac887b8bb7ec3b9fc8cdbef76c627a7ab702f529ec
4
+ data.tar.gz: 83bfccb057682371e7c26a3b37133bf48f44aa77a7fc4eceeec9ab6f4a937210
5
5
  SHA512:
6
- metadata.gz: afd8efd488128281a9d3e5c952b17a678e499e145aa6a448fdbe05a8b748bdcd36e2d01ff83195362931fd8158d884a8804b72e8f9d863237a729e632acab611
7
- data.tar.gz: ebd3eb9482710916a7d969d6315147ab36526d53de86f12abc49892325d7405de2074d2744a89cb3160ea9b37050117335b1fc834900d74470d2301273865fda
6
+ metadata.gz: 204c6c2d98d6b7300f4ec160ab7c224acba62e4dafae77eae6d135adf84f54443ec7e83ae1d437185e621710553b720885335784a4cd85e60bb6807159b9805c
7
+ data.tar.gz: 0476a102da1dc9659cd965897df2ad2dd40baf07482c97b4519b1680e792639eebd9ed98864287354318702ddd93f85356544be9a69b1cc4ad6f0fbdfa9073af
data/Gemfile.lock CHANGED
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- readme-metrics (2.1.0)
4
+ readme-metrics (2.2.0)
5
5
  httparty (~> 0.18)
6
+ rack (>= 2.2, < 4)
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
@@ -14,15 +15,13 @@ GEM
14
15
  safe_yaml (~> 1.0.0)
15
16
  diff-lcs (1.4.4)
16
17
  hashdiff (1.0.1)
17
- httparty (0.20.0)
18
- mime-types (~> 3.0)
18
+ httparty (0.21.0)
19
+ mini_mime (>= 1.0.0)
19
20
  multi_xml (>= 0.5.2)
20
21
  json (2.6.2)
21
22
  json-schema (2.8.1)
22
23
  addressable (>= 2.4)
23
- mime-types (3.4.1)
24
- mime-types-data (~> 3.2015)
25
- mime-types-data (3.2022.0105)
24
+ mini_mime (1.1.2)
26
25
  multi_xml (0.6.0)
27
26
  parallel (1.22.1)
28
27
  parser (3.1.2.1)
data/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  <p align="center">
12
12
  <a href="https://rubygems.org/gems/readme-metrics"><img src="https://img.shields.io/gem/v/readme-metrics.svg?style=for-the-badge" alt="Latest release"></a>
13
- <a href="https://github.com/readmeio/metrics-sdks"><img src="https://img.shields.io/github/workflow/status/readmeio/metrics-sdks/ruby.svg?style=for-the-badge" alt="Build status"></a>
13
+ <a href="https://github.com/readmeio/metrics-sdks"><img src="https://img.shields.io/github/actions/workflow/status/readmeio/metrics-sdks/ruby.yml?branch=main&style=for-the-badge" alt="Build status"></a>
14
14
  </p>
15
15
 
16
16
  With [ReadMe's Metrics API](https://readme.com/metrics) your team can get deep insights into your API's usage. If you're a developer, it takes a few small steps to send your API logs to [ReadMe](http://readme.com). Here's an overview of how the integration works:
@@ -1,8 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
3
 
4
- ruby '3.1.2'
5
-
6
4
  # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
7
5
  gem 'rails', '~> 7.0.3', '>= 7.0.3.1'
8
6
 
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- readme-metrics (2.1.0)
4
+ readme-metrics (2.2.0)
5
5
  httparty (~> 0.18)
6
+ rack (>= 2.2, < 4)
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
@@ -82,8 +83,8 @@ GEM
82
83
  erubi (1.11.0)
83
84
  globalid (1.0.0)
84
85
  activesupport (>= 5.0)
85
- httparty (0.20.0)
86
- mime-types (~> 3.0)
86
+ httparty (0.21.0)
87
+ mini_mime (>= 1.0.0)
87
88
  multi_xml (>= 0.5.2)
88
89
  i18n (1.12.0)
89
90
  concurrent-ruby (~> 1.0)
@@ -97,9 +98,6 @@ GEM
97
98
  mini_mime (>= 0.1.1)
98
99
  marcel (1.0.2)
99
100
  method_source (1.0.0)
100
- mime-types (3.4.1)
101
- mime-types-data (~> 3.2015)
102
- mime-types-data (3.2022.0105)
103
101
  mini_mime (1.1.2)
104
102
  mini_portile2 (2.8.0)
105
103
  minitest (5.16.3)
@@ -119,11 +117,9 @@ GEM
119
117
  net-protocol
120
118
  timeout
121
119
  nio4r (2.5.8)
122
- nokogiri (1.13.8)
120
+ nokogiri (1.13.9)
123
121
  mini_portile2 (~> 2.8.0)
124
122
  racc (~> 1.4)
125
- nokogiri (1.13.8-arm64-darwin)
126
- racc (~> 1.4)
127
123
  puma (5.6.5)
128
124
  nio4r (~> 2.0)
129
125
  racc (1.6.0)
@@ -157,10 +153,12 @@ GEM
157
153
  thor (~> 1.0)
158
154
  zeitwerk (~> 2.5)
159
155
  rake (13.0.6)
160
- reline (0.3.1)
156
+ reline (0.3.2)
161
157
  io-console (~> 0.5)
162
- sqlite3 (1.4.4)
163
- strscan (3.0.4)
158
+ sqlite3 (1.6.1)
159
+ mini_portile2 (~> 2.8.0)
160
+ sqlite3 (1.6.1-arm64-darwin)
161
+ strscan (3.0.6)
164
162
  thor (1.2.1)
165
163
  timeout (0.3.0)
166
164
  tzinfo (2.0.5)
@@ -182,8 +180,5 @@ DEPENDENCIES
182
180
  sqlite3 (~> 1.4)
183
181
  tzinfo-data
184
182
 
185
- RUBY VERSION
186
- ruby 3.1.2p20
187
-
188
183
  BUNDLED WITH
189
184
  2.3.11
@@ -51,7 +51,7 @@ Rails.application.configure do
51
51
  config.active_support.report_deprecations = false
52
52
 
53
53
  # Use default logging formatter so that PID and timestamp are not suppressed.
54
- config.log_formatter = ::Logger::Formatter.new
54
+ config.log_formatter = Logger::Formatter.new
55
55
 
56
56
  # Use a different logger for distributed setups.
57
57
  # require "syslog/logger"
@@ -6,15 +6,29 @@ module Readme
6
6
  class HttpRequest
7
7
  include ContentTypeHelper
8
8
 
9
+ IS_RACK_V3 = Gem.loaded_specs['rack'].version > Gem::Version.create('3.0')
10
+
11
+ # rubocop:disable Style/MutableConstant
9
12
  HTTP_NON_HEADERS = [
10
13
  Rack::HTTP_COOKIE,
11
- Rack::HTTP_VERSION,
12
14
  Rack::HTTP_HOST,
13
15
  Rack::HTTP_PORT
14
- ].freeze
16
+ ]
17
+ # rubocop:enable Style/MutableConstant
18
+
19
+ if IS_RACK_V3
20
+ HTTP_NON_HEADERS.push(Rack::SERVER_PROTOCOL)
21
+ else
22
+ HTTP_NON_HEADERS.push(Rack::HTTP_VERSION)
23
+ end
24
+
25
+ HTTP_NON_HEADERS.freeze
15
26
 
16
27
  def initialize(env)
17
28
  @request = Rack::Request.new(env)
29
+ return unless IS_RACK_V3
30
+
31
+ @input = Rack::RewindableInput.new(@request.body)
18
32
  end
19
33
 
20
34
  def url
@@ -30,7 +44,11 @@ module Readme
30
44
  end
31
45
 
32
46
  def http_version
33
- @request.get_header(Rack::HTTP_VERSION)
47
+ if IS_RACK_V3
48
+ @request.get_header(Rack::SERVER_PROTOCOL)
49
+ else
50
+ @request.get_header(Rack::HTTP_VERSION)
51
+ end
34
52
  end
35
53
 
36
54
  def request_method
@@ -64,11 +82,17 @@ module Readme
64
82
  end
65
83
 
66
84
  def body
67
- @request.body.rewind
68
- content = @request.body.read
69
- @request.body.rewind
70
-
71
- content
85
+ if IS_RACK_V3
86
+ body = @input.read
87
+ @input.rewind
88
+ body
89
+ else
90
+ @request.body.rewind
91
+ content = @request.body.read
92
+ @request.body.rewind
93
+
94
+ content
95
+ end
72
96
  end
73
97
 
74
98
  def parsed_form_data
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Readme
4
4
  class Metrics
5
- VERSION = '2.2.0'
5
+ VERSION = '2.3.0'
6
6
  end
7
7
  end
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.require_paths = ['lib']
28
28
 
29
29
  spec.add_runtime_dependency 'httparty', '~> 0.18'
30
+ spec.add_runtime_dependency 'rack', '>= 2.2', '< 4'
30
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: readme-metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ReadMe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-16 00:00:00.000000000 Z
11
+ date: 2023-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -24,6 +24,26 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.18'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rack
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '2.2'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '4'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '2.2'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '4'
27
47
  description: Middleware for logging requests to Readme's metrics API
28
48
  email:
29
49
  - support@readme.io
@@ -110,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
130
  - !ruby/object:Gem::Version
111
131
  version: '0'
112
132
  requirements: []
113
- rubygems_version: 3.1.4
133
+ rubygems_version: 3.4.6
114
134
  signing_key:
115
135
  specification_version: 4
116
136
  summary: SDK for Readme's metrics API