publishing_platform_app_config 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/main.yml +27 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +3 -0
- data/Gemfile +10 -0
- data/LICENSE +22 -0
- data/README.md +2 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/publishing_platform_app_config/publishing_platform_error/configuration.rb +59 -0
- data/lib/publishing_platform_app_config/publishing_platform_error.rb +45 -0
- data/lib/publishing_platform_app_config/railtie.rb +7 -0
- data/lib/publishing_platform_app_config/version.rb +5 -0
- data/lib/publishing_platform_app_config.rb +6 -0
- data/publishing_platform_app_config.gemspec +24 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 11e94f7bba1b501b8bff7c62ad70627dfa8b963ddba0a57ce9c308713556c065
|
4
|
+
data.tar.gz: 0f4081a9a9aafdf33f303bc6b514805aaaf113b1717769d100437f6ba3d220fc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a87d39eeceeb4cc6dc18553d09d602d7e53665ceb5bdbc91c2ec25682316f174635a195e986ff92f4ea5d60d4aebadb665a4b9f747ec85e2e0fcc62fd2d355d1
|
7
|
+
data.tar.gz: 41a93c4372595ec6a7d6404dc2cd0503567a1ba592024c78e7ce4baef0a0af72ae8f747184aa9f00ea1f3f585ab4a171185f4c3004a02e3d4fc7d3f2b65c8c43
|
@@ -0,0 +1,27 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
|
8
|
+
pull_request:
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
build:
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
name: Ruby ${{ matrix.ruby }}
|
14
|
+
strategy:
|
15
|
+
matrix:
|
16
|
+
ruby:
|
17
|
+
- '3.1.2'
|
18
|
+
|
19
|
+
steps:
|
20
|
+
- uses: actions/checkout@v3
|
21
|
+
- name: Set up Ruby
|
22
|
+
uses: ruby/setup-ruby@v1
|
23
|
+
with:
|
24
|
+
ruby-version: ${{ matrix.ruby }}
|
25
|
+
bundler-cache: true
|
26
|
+
- name: Run the default task
|
27
|
+
run: bundle exec rake
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 Publishing Platform
|
4
|
+
Copyright (c) 2017 Crown Copyright (Government Digital Service)
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
14
|
+
copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "publishing_platform_app_config"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require "delegate"
|
2
|
+
|
3
|
+
module PublishingPlatformError
|
4
|
+
class Configuration < SimpleDelegator
|
5
|
+
def initialize(_sentry_configuration)
|
6
|
+
super
|
7
|
+
set_up_defaults
|
8
|
+
end
|
9
|
+
|
10
|
+
def set_up_defaults
|
11
|
+
self.excluded_exceptions = [
|
12
|
+
# Default ActionDispatch rescue responses
|
13
|
+
"ActionController::RoutingError",
|
14
|
+
"AbstractController::ActionNotFound",
|
15
|
+
"ActionController::MethodNotAllowed",
|
16
|
+
"ActionController::UnknownHttpMethod",
|
17
|
+
"ActionController::NotImplemented",
|
18
|
+
"ActionController::UnknownFormat",
|
19
|
+
"Mime::Type::InvalidMimeType",
|
20
|
+
"ActionController::MissingExactTemplate",
|
21
|
+
"ActionController::InvalidAuthenticityToken",
|
22
|
+
"ActionController::InvalidCrossOriginRequest",
|
23
|
+
"ActionDispatch::Http::Parameters::ParseError",
|
24
|
+
"ActionController::BadRequest",
|
25
|
+
"ActionController::ParameterMissing",
|
26
|
+
"Rack::QueryParser::ParameterTypeError",
|
27
|
+
"Rack::QueryParser::InvalidParameterError",
|
28
|
+
# Default ActiveRecord rescue responses
|
29
|
+
"ActiveRecord::RecordNotFound",
|
30
|
+
"ActiveRecord::StaleObjectError",
|
31
|
+
"ActiveRecord::RecordInvalid",
|
32
|
+
"ActiveRecord::RecordNotSaved",
|
33
|
+
# Additional items
|
34
|
+
"ActiveJob::DeserializationError",
|
35
|
+
"CGI::Session::CookieStore::TamperedWithCookie",
|
36
|
+
# TODO
|
37
|
+
# "GdsApi::HTTPIntermittentServerError",
|
38
|
+
# "GdsApi::TimedOutException",
|
39
|
+
"PublishingPlatform::SSO::PermissionDeniedError",
|
40
|
+
"Mongoid::Errors::DocumentNotFound",
|
41
|
+
"Puma::HttpParserError",
|
42
|
+
"Sinatra::NotFound",
|
43
|
+
"Slimmer::IntermittentRetrievalError",
|
44
|
+
"Slimmer::SourceWrapperNotFoundError",
|
45
|
+
"Sidekiq::JobRetry::Skip",
|
46
|
+
"SignalException",
|
47
|
+
]
|
48
|
+
|
49
|
+
# This will exclude exceptions that are triggered by one of the ignored
|
50
|
+
# exceptions. For example, when any exception occurs in a template,
|
51
|
+
# Rails will raise a ActionView::Template::Error, instead of the original error.
|
52
|
+
self.inspect_exception_causes_for_exclusion = true
|
53
|
+
|
54
|
+
# Avoid "Sending envelope with items ... to Sentry" logspew, since we
|
55
|
+
# don't use Sentry's automatic session tracking.
|
56
|
+
self.auto_session_tracking = false
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "sentry-ruby"
|
2
|
+
require "sentry-rails" if defined?(Rails)
|
3
|
+
require "publishing_platform_app_config/publishing_platform_error/configuration"
|
4
|
+
require "publishing_platform_app_config/version"
|
5
|
+
|
6
|
+
module PublishingPlatformError
|
7
|
+
class AlreadyInitialised < StandardError
|
8
|
+
def initialize(msg = "You can only call PublishingPlatformError.configure once!")
|
9
|
+
super
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.notify(exception_or_message, args = {})
|
14
|
+
# Allow users to use `parameters` as a key like the Airbrake
|
15
|
+
# client, allowing easy upgrades.
|
16
|
+
args[:extra] ||= {}
|
17
|
+
args[:extra].merge!(parameters: args.delete(:parameters))
|
18
|
+
|
19
|
+
args[:tags] ||= {}
|
20
|
+
args[:tags][:publishing_platform_app_config_version] = PublishingPlatformAppConfig::VERSION
|
21
|
+
|
22
|
+
if exception_or_message.is_a?(String)
|
23
|
+
Sentry.capture_message(exception_or_message, **args)
|
24
|
+
else
|
25
|
+
Sentry.capture_exception(exception_or_message, **args)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.is_configured?
|
30
|
+
Sentry.get_current_client != nil
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.configure
|
34
|
+
raise PublishingPlatformError::AlreadyInitialised if is_configured?
|
35
|
+
|
36
|
+
if defined?(Sidekiq) && !defined?(Sentry::Sidekiq)
|
37
|
+
warn "Warning: PublishingPlatformAppConfig is not configured to track Sidekiq errors, install the sentry-sidekiq gem to track them."
|
38
|
+
end
|
39
|
+
|
40
|
+
Sentry.init do |sentry_config|
|
41
|
+
config = Configuration.new(sentry_config)
|
42
|
+
yield config if block_given?
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/publishing_platform_app_config/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "publishing_platform_app_config"
|
7
|
+
spec.version = PublishingPlatformAppConfig::VERSION
|
8
|
+
spec.authors = ["Publishing Platform"]
|
9
|
+
|
10
|
+
spec.summary = "Base configuration for Publishing Platform applications"
|
11
|
+
spec.description = "Base configuration for Publishing Platform applications"
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = ">= 3.0"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = "exe"
|
17
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = %w[lib]
|
19
|
+
|
20
|
+
spec.add_dependency "sentry-rails", "~> 5.3"
|
21
|
+
spec.add_dependency "sentry-ruby", "~> 5.3"
|
22
|
+
|
23
|
+
spec.add_development_dependency "publishing_platform_rubocop"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: publishing_platform_app_config
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Publishing Platform
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-07-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sentry-rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sentry-ruby
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: publishing_platform_rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Base configuration for Publishing Platform applications
|
56
|
+
email:
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- ".github/workflows/main.yml"
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".rubocop.yml"
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- lib/publishing_platform_app_config.rb
|
72
|
+
- lib/publishing_platform_app_config/publishing_platform_error.rb
|
73
|
+
- lib/publishing_platform_app_config/publishing_platform_error/configuration.rb
|
74
|
+
- lib/publishing_platform_app_config/railtie.rb
|
75
|
+
- lib/publishing_platform_app_config/version.rb
|
76
|
+
- publishing_platform_app_config.gemspec
|
77
|
+
homepage:
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubygems_version: 3.3.7
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: Base configuration for Publishing Platform applications
|
100
|
+
test_files: []
|