faraday-cdn-metrics 0.1.0 → 0.2.0

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
- SHA1:
3
- metadata.gz: 3c86baef6a57498196107f84d5238eb3f82e0b64
4
- data.tar.gz: 25826f2b5283099093116ec87b02f61cdbc47335
2
+ SHA256:
3
+ metadata.gz: e26a4774da98a6ac466a57081dac0fefff7eb886083b8c30273dc93f4ecf276c
4
+ data.tar.gz: 9b89c3c6128a8ddf9fd34f5657465f34cdf2d0af000beb970706eae90d598101
5
5
  SHA512:
6
- metadata.gz: 3082622a60a1bc7578b05b5d164f1f2f38947b8c1c9999885eb7838944b5a35263524c64ca30e7f259cdd968dd5aadc0cd235263ff07436df8c223bbedee62c0
7
- data.tar.gz: cdd357e460e675d5a1ef8e74338396a5806a4256802955adf815b8a681750e832f1b5eff2c3be78afca95dc8fac946a2d7e0bd41434a108f80ee0a7667029eb6
6
+ metadata.gz: 60c6bebc2b6f14ed7851354035bee1e6fbb8a3fee9e52aece407fb42b6e112039a5dfd709c80fdfb7a6069bebb2e6fe500e2058b0e20536f7b3a1fbf80510731
7
+ data.tar.gz: 6a86e8a07585d3e3a223544283b73f5a68072cca7576dcaae36bad55cae3644503da8392a88544a595ba96553c77b9b4c3b8e2600bbe280d8d77d33e9cb6b4c9
@@ -1,29 +1,28 @@
1
- # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "faraday_cdn_metrics/version"
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/faraday_cdn_metrics/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "faraday-cdn-metrics"
6
+ spec.name = 'faraday-cdn-metrics'
8
7
  spec.version = FaradayCdnMetrics::VERSION
9
- spec.authors = ["Anson Kelly"]
10
- spec.email = ["anson.kelly@carwow.co.uk"]
8
+ spec.authors = ['Anson Kelly']
9
+ spec.email = ['anson.kelly@carwow.co.uk']
11
10
 
12
- spec.summary = %q{Metrics requests to a CDN like Fastly}
13
- spec.description = %q{Metrics requests to a CDN like Fastly}
14
- spec.homepage = "https://github.com/carwow/faraday-cdn-metrics"
15
- spec.license = "MIT"
11
+ spec.summary = 'Metrics requests to a CDN like Fastly'
12
+ spec.description = 'Metrics requests to a CDN like Fastly'
13
+ spec.homepage = 'https://github.com/carwow/faraday-cdn-metrics'
14
+ spec.license = 'MIT'
16
15
 
17
16
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
17
  f.match(%r{^(test|spec|features)/})
19
18
  end
20
- spec.bindir = "exe"
19
+ spec.bindir = 'exe'
21
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
- spec.require_paths = ["lib"]
21
+ spec.require_paths = ['lib']
23
22
 
24
- spec.add_dependency "faraday", '~> 0.11'
23
+ spec.add_dependency 'faraday', '~> 1'
25
24
 
26
- spec.add_development_dependency "bundler", "~> 1.15"
27
- spec.add_development_dependency "rake", "~> 10.0"
28
- spec.add_development_dependency "rspec", "~> 3.0"
25
+ spec.add_development_dependency 'bundler'
26
+ spec.add_development_dependency 'rake'
27
+ spec.add_development_dependency 'rspec', '~> 3.0'
29
28
  end
@@ -1,10 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'faraday'
2
4
  require 'faraday_cdn_metrics/version'
3
5
  require 'faraday_cdn_metrics/server_caches/fastly'
4
6
 
5
7
  module FaradayCdnMetrics
6
8
  class CdnMetrics < Faraday::Middleware
7
-
8
9
  # Cache status' shamelessly copied from faraday-http-cache
9
10
  CACHE_STATUSES = [
10
11
  # The request was not cacheable.
@@ -29,9 +30,12 @@ module FaradayCdnMetrics
29
30
  :bypass
30
31
  ].freeze
31
32
 
32
- EVENT_NAME = 'cdn_metrics.http_cache'.freeze
33
+ EVENT_NAME = 'cdn_metrics.http_cache'
33
34
 
34
- def initialize(app, instrumenter: nil, instrument_name: EVENT_NAME, server_cache: FaradayCdnMetrics::ServerCaches::Fastly)
35
+ def initialize(app,
36
+ instrumenter: nil,
37
+ instrument_name: EVENT_NAME,
38
+ server_cache: FaradayCdnMetrics::ServerCaches::Fastly)
35
39
  super(app)
36
40
 
37
41
  @instrumenter = instrumenter
@@ -44,7 +48,11 @@ module FaradayCdnMetrics
44
48
  client_cache_status = find_client_cache_status(response_env)
45
49
  server_cache_status = find_server_cache_status(response_env)
46
50
 
47
- @instrumenter.instrument(@instrument_name, { env: response_env, client_cache_status: client_cache_status, server_cache_status: server_cache_status })
51
+ @instrumenter.instrument(@instrument_name, {
52
+ env: response_env,
53
+ client_cache_status: client_cache_status,
54
+ server_cache_status: server_cache_status
55
+ })
48
56
  end
49
57
  end
50
58
 
@@ -62,13 +70,10 @@ module FaradayCdnMetrics
62
70
  return :valid if server_cache.hit_while_revalidate?
63
71
  return :fresh if server_cache.hit?
64
72
  return :miss if server_cache.miss?
73
+
65
74
  :unknown
66
75
  end
67
76
  end
68
77
  end
69
78
 
70
- if Faraday.respond_to?(:register_middleware)
71
- Faraday.register_middleware cdn_metrics: FaradayCdnMetrics::CdnMetrics
72
- elsif Faraday::Middleware.respond_to?(:register_middleware)
73
- Faraday::Middleware.register_middleware cdn_metrics: FaradayCdnMetrics::CdnMetrics
74
- end
79
+ Faraday::Middleware.register_middleware cdn_metrics: FaradayCdnMetrics::CdnMetrics
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FaradayCdnMetrics
2
4
  module ServerCaches
3
5
  class Fastly
4
-
5
6
  def initialize(response_headers = {})
6
7
  @response_headers = response_headers
7
8
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FaradayCdnMetrics
2
- VERSION = "0.1.0"
4
+ VERSION = '0.2.0'
3
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faraday-cdn-metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anson Kelly
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-26 00:00:00.000000000 Z
11
+ date: 2020-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.11'
19
+ version: '1'
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: '0.11'
26
+ version: '1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.15'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.15'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '0'
48
48
  type: :development
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: '10.0'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -104,8 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0'
106
106
  requirements: []
107
- rubyforge_project:
108
- rubygems_version: 2.5.2
107
+ rubygems_version: 3.1.2
109
108
  signing_key:
110
109
  specification_version: 4
111
110
  summary: Metrics requests to a CDN like Fastly