defra_ruby_alert 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8f09fce943f839d0387a09b7ecff2427a91fdd53
4
+ data.tar.gz: e27a093cbcdd52f1622cfb9fa6a2c7c1ac5682f5
5
+ SHA512:
6
+ metadata.gz: d59ec1dcb55d2812d4b878cbaad24e41943a73709e644de6c69d5bf941b91f0687ce38a46b2e3638db796e3d5943620b4c161924e22414a70a7f0e89805c83f2
7
+ data.tar.gz: aae0d7151f78f725693b0c3c1f7f3bbdda90147a40e664f1a7b06e43f60620eaf43e435452ee450c55e2f7e1be46e700a1aa40ebd6009ebde3d2b9a8b76a108a
data/LICENSE ADDED
@@ -0,0 +1,8 @@
1
+ The Open Government Licence (OGL) Version 3
2
+
3
+ Copyright (c) 2019 Defra
4
+
5
+ This source code is licensed under the Open Government Licence v3.0. To view this
6
+ licence, visit www.nationalarchives.gov.uk/doc/open-government-licence/version/3
7
+ or write to the Information Policy Team, The National Archives, Kew, Richmond,
8
+ Surrey, TW9 4DU.
@@ -0,0 +1,117 @@
1
+ # Defra Ruby Alert
2
+
3
+ [![Build Status](https://travis-ci.com/DEFRA/defra-ruby-alert.svg?branch=master)](https://travis-ci.com/DEFRA/defra-ruby-alert)
4
+ [![security](https://hakiri.io/github/DEFRA/defra-ruby-alert/master.svg)](https://hakiri.io/github/DEFRA/defra-ruby-alert/master)
5
+ [![Maintainability](https://api.codeclimate.com/v1/badges/071265a0d6f45606290f/maintainability)](https://codeclimate.com/github/DEFRA/defra-ruby-alert/maintainability)
6
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/071265a0d6f45606290f/test_coverage)](https://codeclimate.com/github/DEFRA/defra-ruby-alert/test_coverage)
7
+ [![Gem Version](https://badge.fury.io/rb/defra_ruby_alert.svg)](https://badge.fury.io/rb/defra_ruby_alert)
8
+ [![Licence](https://img.shields.io/badge/Licence-OGLv3-blue.svg)](http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3)
9
+
10
+ Currently there are a number of Rails based digital services in Defra, all of which use [Airbrake](https://github.com/airbrake/airbrake) to report exceptions to instances of [Errbit](https://github.com/errbit/errbit) we have running.
11
+
12
+ This means we are often duplicating the code to configure and manage Airbrake across them. So we created this gem 😁!
13
+
14
+ It's aim is to help us
15
+
16
+ - start to reduce the duplication across projects
17
+ - be consistent in how we configure and manage Airbrake
18
+
19
+ ## Installation
20
+
21
+ Add this line to your application's Gemfile
22
+
23
+ ```ruby
24
+ gem "defra_ruby_alert"
25
+ ```
26
+
27
+ And then update your dependencies by calling
28
+
29
+ ```bash
30
+ bundle install
31
+ ```
32
+
33
+ ## Configuration
34
+
35
+ There is a bunch of stuff that can be [configured](https://github.com/airbrake/airbrake-ruby#configuration) for Airbrake. But as part of trying to keep things consistent we only expose the stuff we expect to change across services.
36
+
37
+ ### Mandatory config
38
+
39
+ As a minimum you need to let the gem know the host uri for the Errbit instance, and the project key to log exceptions against. You also need to enable it.
40
+
41
+ This is because Airbrake errors if `project_key` is not set. The problem is that the initializer is fired in scenarios where we are not actually using the app, for example when running a rake task. A common case is during deployment when generating assets. As such the gem disables Airbrake unless you tell it to enable it.
42
+
43
+ ```ruby
44
+ # config/initializers/defra_ruby_alert.rb
45
+ require "defra_ruby/alert"
46
+
47
+ DefraRuby::Alert.configure do |config|
48
+ config.enabled = true
49
+ config.host = "http://errbit.mydomain.com"
50
+ config.project_key = "SomeScaryLookingLongStringMadeUpOfLettersAndNumbers"
51
+ end
52
+ ```
53
+
54
+ ### Rails config
55
+
56
+ The gem has been designed to be used by our Rails apps, so we would also expect the following to be set (though its not required)
57
+
58
+ ```ruby
59
+ config.root_directory = Rails.root
60
+ config.logger = Rails.logger
61
+ config.environment = Rails.env
62
+ ```
63
+
64
+ ### blacklist
65
+
66
+ > Specifies which keys in the payload (parameters, session data, environment data, etc) should be filtered. Before sending an error, filtered keys will be substituted with the [Filtered] label.
67
+
68
+ Not every project uses this, but some do hence we provide the ability to specify a blacklist.
69
+
70
+ ```ruby
71
+ config.blacklist = [/password/i, /postcode/i, :name]
72
+ ```
73
+
74
+ See Airbrake's [blacklist_keys](https://github.com/airbrake/airbrake-ruby#blacklist_keys) for more details.
75
+
76
+ ## Usage
77
+
78
+ Having configured the gem, you simply need to tell it to `start` Airbrake.
79
+
80
+ ```ruby
81
+ # config/initializers/defra_ruby_alert.rb
82
+ require "defra_ruby/alert"
83
+
84
+ DefraRuby::Alert.configure do |config|
85
+ # ...
86
+ end
87
+
88
+ DefraRuby::Alert.start
89
+ ```
90
+
91
+ ## Alert?
92
+
93
+ It probably would have made more sense to name this gem `defra_ruby_airbrake` as that's all it's really dealing with. However we encountered numerous namespace issues in our first attempts. So rather than run the risk of always encountering those kind of issues, we just picked a different name.
94
+
95
+ [Naming things is hard!](https://martinfowler.com/bliki/TwoHardThings.html)
96
+
97
+ ## Contributing to this project
98
+
99
+ If you have an idea you'd like to contribute please log an issue.
100
+
101
+ All contributions should be submitted via a pull request.
102
+
103
+ ## License
104
+
105
+ THIS INFORMATION IS LICENSED UNDER THE CONDITIONS OF THE OPEN GOVERNMENT LICENCE found at:
106
+
107
+ <http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3>
108
+
109
+ The following attribution statement MUST be cited in your products and applications when using this information.
110
+
111
+ > Contains public sector information licensed under the Open Government license v3
112
+
113
+ ### About the license
114
+
115
+ The Open Government Licence (OGL) was developed by the Controller of Her Majesty's Stationery Office (HMSO) to enable information providers in the public sector to license the use and re-use of their information under a common open licence.
116
+
117
+ It is designed to encourage use and re-use of information freely and flexibly, with only a few conditions.
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require "bundler/setup"
5
+ rescue LoadError
6
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
7
+ end
8
+
9
+ Bundler::GemHelper.install_tasks
10
+
11
+ # This is wrapped to prevent an error when rake is called in environments where
12
+ # rspec may not be available, e.g. production. As such we don't need to handle
13
+ # the error.
14
+ # rubocop:disable Lint/HandleExceptions
15
+ begin
16
+ require "rspec/core/rake_task"
17
+
18
+ RSpec::Core::RakeTask.new(:spec)
19
+
20
+ task default: :spec
21
+ rescue LoadError
22
+ # no rspec available
23
+ end
24
+
25
+ begin
26
+ require "github_changelog_generator/task"
27
+
28
+ GitHubChangelogGenerator::RakeTask.new :changelog do |config|
29
+ config.user = "defra"
30
+ config.project = "defra-ruby-alert"
31
+ end
32
+ rescue LoadError
33
+ # no changelog available
34
+ end
35
+ # rubocop:enable Lint/HandleExceptions
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "defra_ruby/alert"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "defra_ruby/alert"
4
+
5
+ module DefraRuby
6
+ # The Defra Ruby packages namespace
7
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "alert/airbrake_runner"
4
+ require_relative "alert/configuration"
5
+
6
+ module DefraRuby
7
+ module Alert
8
+ class << self
9
+
10
+ def configure
11
+ yield(configuration)
12
+ end
13
+
14
+ def configuration
15
+ @configuration ||= Configuration.new
16
+ @configuration
17
+ end
18
+
19
+ def start
20
+ AirbrakeRunner.invoke
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "airbrake"
4
+
5
+ module DefraRuby
6
+ module Alert
7
+ class AirbrakeRunner
8
+
9
+ def self.invoke
10
+ configure
11
+
12
+ if DefraRuby::Alert.configuration.enabled
13
+ # Register an `at_exit` hook that runs when the host app shuts down
14
+ at_exit { perform_at_exit }
15
+
16
+ return
17
+ end
18
+
19
+ # Unfortunately the airbrake initializer errors if project_key is not set. The
20
+ # problem is that the initializer is fired in scenarios where we are not
21
+ # actually using the app, for example when running a rake task.
22
+ #
23
+ # In production when we run rake tasks it's in an environment where environment
24
+ # variables have not been set. As such we need a way to disable using Airbrake
25
+ # unless we actually need it.
26
+ Airbrake.add_filter(&:ignore!)
27
+ end
28
+
29
+ private_class_method def self.perform_at_exit
30
+ Airbrake.close
31
+ rescue StandardError => e
32
+ puts "Airbrake reported an error when closing. \
33
+ Its probaly fine and just because there were no errors to report: #{e.message}"
34
+ end
35
+
36
+ private_class_method def self.configure
37
+ Airbrake.configure do |c|
38
+ # You must set both project_id & project_key. To find your project_id and
39
+ # project_key navigate to your project's General Settings and copy the values
40
+ # from the right sidebar.
41
+ # https://github.com/airbrake/airbrake-ruby#project_id--project_key
42
+ c.host = DefraRuby::Alert.configuration.host
43
+ c.project_key = DefraRuby::Alert.configuration.project_key
44
+ c.project_id = 1
45
+
46
+ # Configures the root directory of your project. Expects a String or a
47
+ # Pathname, which represents the path to your project. Providing this option
48
+ # helps us to filter out repetitive data from backtrace frames and link to
49
+ # GitHub files from our dashboard.
50
+ # https://github.com/airbrake/airbrake-ruby#root_directory
51
+ c.root_directory = DefraRuby::Alert.configuration.root_directory
52
+
53
+ # By default, Airbrake Ruby outputs to STDOUT. In Rails apps it makes sense to
54
+ # use the Rails' logger.
55
+ # https://github.com/airbrake/airbrake-ruby#logger
56
+ c.logger = DefraRuby::Alert.configuration.logger
57
+
58
+ # Configures the environment the application is running in. Helps the Airbrake
59
+ # dashboard to distinguish between exceptions occurring in different
60
+ # environments. By default, it's not set.
61
+ # NOTE: This option must be set in order to make the 'ignore_environments'
62
+ # option work.
63
+ # https://github.com/airbrake/airbrake-ruby#environment
64
+ c.environment = DefraRuby::Alert.configuration.environment
65
+
66
+ # Setting this option allows Airbrake to filter exceptions occurring in
67
+ # unwanted environments such as :test. By default, it is equal to an empty
68
+ # Array, which means Airbrake Ruby sends exceptions occurring in all
69
+ # environments.
70
+ # NOTE: This option *does not* work if you don't set the 'environment' option.
71
+ # https://github.com/airbrake/airbrake-ruby#ignore_environments
72
+ c.ignore_environments = %w[test]
73
+
74
+ # A list of parameters that should be filtered out of what is sent to
75
+ # Airbrake. By default, all "password" attributes will have their contents
76
+ # replaced.
77
+ # https://github.com/airbrake/airbrake-ruby#blacklist_keys
78
+ c.blacklist_keys = DefraRuby::Alert.configuration.blacklist
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DefraRuby
4
+ module Alert
5
+ class Configuration
6
+ attr_accessor :root_directory, :logger, :environment
7
+ attr_accessor :host, :project_key, :blacklist, :enabled
8
+
9
+ def initialize
10
+ @blacklist = []
11
+ @enabled = false
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DefraRuby
4
+ module Alert
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ module DefraRuby
6
+ module Alert
7
+ RSpec.describe AirbrakeRunner do
8
+ before do
9
+ DefraRuby::Alert.configure do |c|
10
+ c.enabled = enabled
11
+ c.host = host
12
+ c.project_key = project_key
13
+ end
14
+
15
+ allow(configuration).to receive_messages(
16
+ :host= => nil,
17
+ :project_key= => nil,
18
+ :project_id= => nil,
19
+ :root_directory= => nil,
20
+ :logger= => nil,
21
+ :environment= => nil,
22
+ :ignore_environments= => nil,
23
+ :blacklist_keys= => nil
24
+ )
25
+
26
+ allow(Airbrake).to receive(:configure).and_yield(configuration)
27
+ end
28
+
29
+ let(:configuration) { double("Configuration") }
30
+
31
+ let(:enabled) { true }
32
+ let(:host) { "http://localhost:8005" }
33
+ let(:project_key) { "ABC123456789" }
34
+
35
+ describe ".invoke" do
36
+ it "configures Airbrake" do
37
+ expect(configuration).to receive(:host=).with(host)
38
+ expect(configuration).to receive(:project_key=).with(project_key)
39
+
40
+ described_class.invoke
41
+ end
42
+
43
+ context "when airbrake is enabled" do
44
+ it "registers an 'at_exit' hook" do
45
+ expect(described_class).to receive(:at_exit)
46
+
47
+ described_class.invoke
48
+ end
49
+
50
+ it "does not tell Airbrake to ignore everything" do
51
+ expect(Airbrake).not_to receive(:add_filter)
52
+
53
+ described_class.invoke
54
+ end
55
+ end
56
+
57
+ context "when airbrake is not enabled" do
58
+ let(:enabled) { false }
59
+
60
+ it "does not register an 'at_exit' hook" do
61
+ expect(described_class).to receive(:at_exit).never
62
+
63
+ described_class.invoke
64
+ end
65
+
66
+ it "tells Airbrake to ignore everything" do
67
+ expect(Airbrake).to receive(:add_filter) { |&block| expect(block).to be(&:ignore!) }
68
+
69
+ described_class.invoke
70
+ end
71
+ end
72
+ end
73
+
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ module DefraRuby
6
+ module Alert
7
+ RSpec.describe Configuration do
8
+ it "sets the appropriate default config settings" do
9
+ fresh_config = described_class.new
10
+
11
+ expect(fresh_config.root_directory).to be_nil
12
+ expect(fresh_config.logger).to be_nil
13
+ expect(fresh_config.environment).to be_nil
14
+
15
+ expect(fresh_config.host).to be_nil
16
+ expect(fresh_config.project_key).to be_nil
17
+ expect(fresh_config.blacklist).to eq([])
18
+ expect(fresh_config.enabled).to eq(false)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ RSpec.describe DefraRuby::Alert do
6
+ describe "VERSION" do
7
+ it "is a version string in the correct format" do
8
+ expect(DefraRuby::Alert::VERSION).to be_a(String)
9
+ expect(DefraRuby::Alert::VERSION).to match(/\d+\.\d+\.\d+/)
10
+ end
11
+ end
12
+
13
+ describe ".configuration" do
14
+ context "when the host app has not provided configuration" do
15
+ it "returns a DefraRuby::Alert::Configuration instance" do
16
+ expect(described_class.configuration).to be_an_instance_of(DefraRuby::Alert::Configuration)
17
+ end
18
+ end
19
+
20
+ context "when the host app has provided configuration" do
21
+ let(:host) { "http://localhost:9012" }
22
+
23
+ it "returns an DefraRuby::Alert::Configuration instance with a matching host" do
24
+ described_class.configure { |config| config.host = host }
25
+
26
+ expect(described_class.configuration.host).to eq(host)
27
+ end
28
+ end
29
+ end
30
+
31
+ describe ".start" do
32
+ before do
33
+ DefraRuby::Alert.configure do |c|
34
+ c.enabled = false
35
+ c.host = "http://localhost:8005"
36
+ c.project_key = "ABC123456789"
37
+ end
38
+ end
39
+ it "invokes 'AirbrakeRunner'" do
40
+ expect(DefraRuby::Alert::AirbrakeRunner).to receive(:invoke)
41
+
42
+ described_class.start
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,12 @@
1
+ example_id | status | run_time |
2
+ -------------------------------------------------------- | ------ | --------------- |
3
+ ./spec/defra_ruby/alert/airbrake_runner_spec.rb[1:1:1] | passed | 0.01923 seconds |
4
+ ./spec/defra_ruby/alert/airbrake_runner_spec.rb[1:1:2:1] | passed | 0.00407 seconds |
5
+ ./spec/defra_ruby/alert/airbrake_runner_spec.rb[1:1:2:2] | passed | 0.00105 seconds |
6
+ ./spec/defra_ruby/alert/airbrake_runner_spec.rb[1:1:3:1] | passed | 0.00114 seconds |
7
+ ./spec/defra_ruby/alert/airbrake_runner_spec.rb[1:1:3:2] | passed | 0.00183 seconds |
8
+ ./spec/defra_ruby/alert/configuration_spec.rb[1:1] | passed | 0.00394 seconds |
9
+ ./spec/defra_ruby/alert_spec.rb[1:1:1] | passed | 0.00465 seconds |
10
+ ./spec/defra_ruby/alert_spec.rb[1:2:1:1] | passed | 0.00216 seconds |
11
+ ./spec/defra_ruby/alert_spec.rb[1:2:2:1] | passed | 0.00013 seconds |
12
+ ./spec/defra_ruby/alert_spec.rb[1:3:1] | passed | 0.00051 seconds |
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/setup"
4
+
5
+ # Require and run our simplecov initializer as the very first thing we do.
6
+ # This is as per its docs https://github.com/colszowka/simplecov#getting-started
7
+ require "./spec/support/simplecov"
8
+
9
+ # Requires supporting ruby files with custom matchers and macros, etc, in
10
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
11
+ # run as spec files by default. This means that files in spec/support that end
12
+ # in _spec.rb will both be required and run as specs, causing the specs to be
13
+ # run twice. It is recommended that you do not name files matching this glob to
14
+ # end with _spec.rb. You can configure this pattern with the --pattern
15
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
16
+ #
17
+ # We make an exception for simplecov because that will already have been
18
+ # required and run at the very top of spec_helper.rb
19
+ support_files = Dir["./spec/support/**/*.rb"].reject { |file| file == "./spec/support/simplecov.rb" }
20
+ support_files.each { |f| require f }
21
+
22
+ RSpec.configure do |config|
23
+ # rspec-expectations config goes here. You can use an alternate
24
+ # assertion/expectation library such as wrong or the stdlib/minitest
25
+ # assertions if you prefer.
26
+ config.expect_with :rspec do |expectations|
27
+ # This option will default to `true` in RSpec 4. It makes the `description`
28
+ # and `failure_message` of custom matchers include text for helper methods
29
+ # defined using `chain`, e.g.:
30
+ # be_bigger_than(2).and_smaller_than(4).description
31
+ # # => "be bigger than 2 and smaller than 4"
32
+ # ...rather than:
33
+ # # => "be bigger than 2"
34
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
35
+ end
36
+
37
+ # rspec-mocks config goes here. You can use an alternate test double
38
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
39
+ config.mock_with :rspec do |mocks|
40
+ # Prevents you from mocking or stubbing a method that does not exist on
41
+ # a real object. This is generally recommended, and will default to
42
+ # `true` in RSpec 4.
43
+ mocks.verify_partial_doubles = true
44
+ end
45
+
46
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
47
+ # have no way to turn it off -- the option exists only for backwards
48
+ # compatibility in RSpec 3). It causes shared context metadata to be
49
+ # inherited by the metadata hash of host groups and examples, rather than
50
+ # triggering implicit auto-inclusion in groups with matching metadata.
51
+ config.shared_context_metadata_behavior = :apply_to_host_groups
52
+
53
+ # This allows you to limit a spec run to individual examples or groups
54
+ # you care about by tagging them with `:focus` metadata. When nothing
55
+ # is tagged with `:focus`, all examples get run. RSpec also provides
56
+ # aliases for `it`, `describe`, and `context` that include `:focus`
57
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
58
+ config.filter_run_when_matching :focus
59
+
60
+ # Allows RSpec to persist some state between runs in order to support
61
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
62
+ # you configure your source control system to ignore this file.
63
+ config.example_status_persistence_file_path = "spec/examples.txt"
64
+
65
+ # Limits the available syntax to the non-monkey patched syntax that is
66
+ # recommended. For more details, see:
67
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
68
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
69
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
70
+ config.disable_monkey_patching!
71
+
72
+ # Run specs in random order to surface order dependencies. If you find an
73
+ # order dependency and want to debug it, you can fix the order by providing
74
+ # the seed, which is printed after each run.
75
+ # --seed 1234
76
+ config.order = :random
77
+
78
+ # Seed global randomization in this process using the `--seed` CLI option.
79
+ # Setting this allows you to use `--seed` to deterministically reproduce
80
+ # test failures related to randomization by passing the same `--seed` value
81
+ # as the one that triggered the failure.
82
+ Kernel.srand config.seed
83
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Need to require our actual code files.
4
+ require "defra_ruby/alert"
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Load env vars from a text file
4
+ require "dotenv/load"
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Support debugging in the tests. Add `binding.pry` wherever you want execution
4
+ # to stop and the debugger to kick in.
5
+ # Details on the debugging commands can be found here
6
+ # https://github.com/deivid-rodriguez/pry-byebug#commands
7
+ require "pry-byebug"
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "simplecov"
4
+
5
+ # We start it with the rails param to ensure it includes coverage for all code
6
+ # started by the rails app, and not just the files touched by our unit tests.
7
+ # This gives us the most accurate assessment of our unit test coverage
8
+ # https://github.com/colszowka/simplecov#getting-started
9
+ SimpleCov.start do
10
+ # We filter the spec folder, mainly to ensure that any dummy apps don't get
11
+ # included in the coverage report. However our intent is that nothing in the
12
+ # spec folder should be included
13
+ add_filter "/spec/"
14
+ # The version file is simply just that, so we do not feel the need to ensure
15
+ # we have a test for it
16
+ add_filter "lib/defra_ruby/alert/version"
17
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Stubbing HTTP requests
4
+ require "webmock/rspec"
metadata ADDED
@@ -0,0 +1,216 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: defra_ruby_alert
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Defra
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-11-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: airbrake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 5.3.0
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.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: defra_ruby_style
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: dotenv
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
+ - !ruby/object:Gem::Dependency
56
+ name: github_changelog_generator
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry-byebug
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: simplecov
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: webmock
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '3.4'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '3.4'
153
+ description: Provides a single source of functionality for initialising and managing
154
+ Alert in our apps.
155
+ email:
156
+ - alan.cruikshanks@environment-agency.gov.uk
157
+ executables: []
158
+ extensions: []
159
+ extra_rdoc_files: []
160
+ files:
161
+ - LICENSE
162
+ - README.md
163
+ - Rakefile
164
+ - bin/console
165
+ - bin/setup
166
+ - lib/defra_ruby.rb
167
+ - lib/defra_ruby/alert.rb
168
+ - lib/defra_ruby/alert/airbrake_runner.rb
169
+ - lib/defra_ruby/alert/configuration.rb
170
+ - lib/defra_ruby/alert/version.rb
171
+ - spec/defra_ruby/alert/airbrake_runner_spec.rb
172
+ - spec/defra_ruby/alert/configuration_spec.rb
173
+ - spec/defra_ruby/alert_spec.rb
174
+ - spec/examples.txt
175
+ - spec/spec_helper.rb
176
+ - spec/support/defra_ruby_alert.rb
177
+ - spec/support/dotenv.rb
178
+ - spec/support/pry.rb
179
+ - spec/support/simplecov.rb
180
+ - spec/support/webmock.rb
181
+ homepage: https://github.com/DEFRA/defra-ruby-alert
182
+ licenses:
183
+ - The Open Government Licence (OGL) Version 3
184
+ metadata:
185
+ allowed_push_host: https://rubygems.org
186
+ post_install_message:
187
+ rdoc_options: []
188
+ require_paths:
189
+ - lib
190
+ required_ruby_version: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ required_rubygems_version: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - ">="
198
+ - !ruby/object:Gem::Version
199
+ version: '0'
200
+ requirements: []
201
+ rubyforge_project:
202
+ rubygems_version: 2.6.13
203
+ signing_key:
204
+ specification_version: 4
205
+ summary: Defra ruby on rails Alert gem
206
+ test_files:
207
+ - spec/spec_helper.rb
208
+ - spec/defra_ruby/alert_spec.rb
209
+ - spec/defra_ruby/alert/configuration_spec.rb
210
+ - spec/defra_ruby/alert/airbrake_runner_spec.rb
211
+ - spec/examples.txt
212
+ - spec/support/defra_ruby_alert.rb
213
+ - spec/support/simplecov.rb
214
+ - spec/support/webmock.rb
215
+ - spec/support/pry.rb
216
+ - spec/support/dotenv.rb