ddmetrics-1.1.0/0000755000004100000410000000000014570572607013534 5ustar www-datawww-dataddmetrics-1.1.0/NEWS.md0000644000004100000410000000072514570572607014636 0ustar www-datawww-data# DDMetrics news ## 1.1.0 (2023-10-31) Features: * Added `Stopwatch#run` ## 1.0.1 (2018-07-19) Enhancements: * Improved formatting of labels in tables (#7) ## 1.0.0 (2018-01-07) (identical to 1.0.0rc1) ## 1.0.0rc1 (2018-01-04) Changes: * Renamed to DDMetrics (from DDTelemetry) ## 1.0.0a3 (2017-12-25) Changes: * Made labels be a hash ## 1.0.0a2 (2017-12-18) Changes: * Many API changes to make usage simpler ## 1.0.0a1 (2017-12-02) Initial release. ddmetrics-1.1.0/.gitignore0000644000004100000410000000006314570572607015523 0ustar www-datawww-data.DS_Store *.gem /.vscode/ /coverage/ /Gemfile.lock ddmetrics-1.1.0/scripts/0000755000004100000410000000000014570572607015223 5ustar www-datawww-dataddmetrics-1.1.0/scripts/release0000755000004100000410000000530614570572607016575 0ustar www-datawww-data#!/usr/bin/env ruby # frozen_string_literal: true require 'fileutils' require 'json' require 'netrc' require 'octokit' require 'shellwords' require 'uri' def run(*args) puts(' ' + args.map { |s| Shellwords.escape(s) }.join(' ')) system(*args) end gem_name = 'ddmetrics' version_constant = 'DDMetrics::VERSION' gem_path = 'ddmetrics' puts '=== Logging in to GitHub’s API…' client = Octokit::Client.new(netrc: true) puts puts '=== Deleting old *.gem files…' Dir['*.gem'].each do |fn| puts "deleting #{fn}…" FileUtils.rm_f(fn) end puts puts '=== Verifying presence of release date…' unless File.readlines('NEWS.md').drop(2).first =~ / \(\d{4}-\d{2}-\d{2}\)$/ warn 'No proper release date found!' exit 1 end puts puts '=== Reading version…' require "./lib/#{gem_path}/version" version = eval(version_constant) # rubocop:disable Security/Eval puts "Version = #{version}" puts puts '=== Building new gem…' run('gem', 'build', 'ddmetrics.gemspec') puts puts '=== Verifying that gems were built properly…' gem_filename = "#{gem_name}-#{version}.gem" unless File.file?(gem_filename) warn "Error: Could not find gem: #{gem_filename}" exit 1 end puts puts '=== Verifying that gem version does not yet exist…' url = URI.parse("https://rubygems.org/api/v1/versions/#{gem_name}.json") response = Net::HTTP.get_response(url) existing_versions = case response.code when '404' [] when '200' JSON.parse(response.body).map { |e| e.fetch('number') } else warn "Error: Couldn’t fetch version information for #{gem_name} (status #{response.code})" exit 1 end if existing_versions.include?(version) warn "Error: #{gem_name} v#{version} already exists" exit 1 end puts puts '=== Verifying that release does not yet exist…' releases = client.releases('ddfreyne/ddmetrics') release = releases.find { |r| r.tag_name == DDMetrics::VERSION } if release warn 'Release already exists!' warn 'ABORTED!' exit 1 end puts puts '=== Creating Git tag…' run('git', 'tag', '--sign', '--annotate', DDMetrics::VERSION, '--message', "Version #{DDMetrics::VERSION}") puts puts '=== Pushing Git data…' run('git', 'push', 'origin', '--tags') puts puts '=== Pushing gem…' run('gem', 'push', "ddmetrics-#{DDMetrics::VERSION}.gem") puts puts '=== Reading release notes…' release_notes = File.readlines('NEWS.md') .drop(4) .take_while { |l| l !~ /^## / } .join puts puts '=== Creating release on GitHub…' sleep 3 # Give GitHub some time to detect the new tag is_prerelease = DDMetrics::VERSION =~ /a|b|rc/ || DDMetrics::VERSION =~ /^0/ client.create_release( 'ddfreyne/ddmetrics', DDMetrics::VERSION, prerelease: !is_prerelease.nil?, body: release_notes ) puts puts 'DONE!' ddmetrics-1.1.0/lib/0000755000004100000410000000000014570572607014302 5ustar www-datawww-dataddmetrics-1.1.0/lib/ddmetrics.rb0000644000004100000410000000066414570572607016613 0ustar www-datawww-data# frozen_string_literal: true require_relative 'ddmetrics/version' module DDMetrics end require_relative 'ddmetrics/basic_counter' require_relative 'ddmetrics/basic_summary' require_relative 'ddmetrics/metric' require_relative 'ddmetrics/counter' require_relative 'ddmetrics/summary' require_relative 'ddmetrics/stopwatch' require_relative 'ddmetrics/table' require_relative 'ddmetrics/printer' require_relative 'ddmetrics/stats' ddmetrics-1.1.0/lib/ddmetrics/0000755000004100000410000000000014570572607016260 5ustar www-datawww-dataddmetrics-1.1.0/lib/ddmetrics/counter.rb0000644000004100000410000000056614570572607020273 0ustar www-datawww-data# frozen_string_literal: true module DDMetrics class Counter < Metric def increment(label) validate_label(label) basic_metric_for(label, BasicCounter).increment end def get(label) validate_label(label) basic_metric_for(label, BasicCounter).value end def to_s DDMetrics::Printer.new.counter_to_s(self) end end end ddmetrics-1.1.0/lib/ddmetrics/basic_counter.rb0000644000004100000410000000030014570572607021416 0ustar www-datawww-data# frozen_string_literal: true module DDMetrics class BasicCounter attr_reader :value def initialize @value = 0 end def increment @value += 1 end end end ddmetrics-1.1.0/lib/ddmetrics/summary.rb0000644000004100000410000000065514570572607020310 0ustar www-datawww-data# frozen_string_literal: true module DDMetrics class Summary < Metric def observe(value, label) validate_label(label) basic_metric_for(label, BasicSummary).observe(value) end def get(label) validate_label(label) values = basic_metric_for(label, BasicSummary).values DDMetrics::Stats.new(values) end def to_s DDMetrics::Printer.new.summary_to_s(self) end end end ddmetrics-1.1.0/lib/ddmetrics/stopwatch.rb0000644000004100000410000000230414570572607020620 0ustar www-datawww-data# frozen_string_literal: true module DDMetrics class Stopwatch NANOS_PER_SECOND = 1_000_000_000 class AlreadyRunningError < StandardError def message 'Cannot start, because stopwatch is already running' end end class NotRunningError < StandardError def message 'Cannot stop, because stopwatch is not running' end end class StillRunningError < StandardError def message 'Cannot get duration, because stopwatch is still running' end end def initialize @duration = 0 @last_start = nil end def run start yield ensure stop end def start raise AlreadyRunningError if running? @last_start = nanos_now end def stop raise NotRunningError unless running? @duration += (nanos_now - @last_start) @last_start = nil end def duration raise StillRunningError if running? @duration.to_f / NANOS_PER_SECOND end def running? !@last_start.nil? end def stopped? !running? end private def nanos_now Process.clock_gettime(Process::CLOCK_MONOTONIC, :nanosecond) end end end ddmetrics-1.1.0/lib/ddmetrics/basic_summary.rb0000644000004100000410000000031514570572607021442 0ustar www-datawww-data# frozen_string_literal: true module DDMetrics class BasicSummary attr_reader :values def initialize @values = [] end def observe(value) @values << value end end end ddmetrics-1.1.0/lib/ddmetrics/table.rb0000644000004100000410000000223114570572607017672 0ustar www-datawww-data# frozen_string_literal: true module DDMetrics class Table def initialize(rows, num_headers: 1) @rows = rows @num_headers = num_headers end def to_s columns = @rows.transpose column_lengths = columns.map { |c| c.map(&:size).max } [].tap do |lines| # header lines << row_to_s(@rows[0], column_lengths) # separator lines << separator(column_lengths) # body rows = sort_rows(@rows.drop(1)) lines.concat(rows.map { |r| row_to_s(r, column_lengths) }) end.join("\n") end private def sort_rows(rows) rows.sort_by { |r| r.first.downcase } end def row_to_s(row, column_lengths) values = row.zip(column_lengths).map { |text, length| text.rjust(length) } values.take(@num_headers).join(' ') + ' │ ' + values.drop(@num_headers).join(' ') end def separator(column_lengths) (+'').tap do |s| s << column_lengths.take(@num_headers).map { |l| '─' * l }.join('───') s << '─┼─' s << column_lengths.drop(@num_headers).map { |l| '─' * l }.join('───') end end end end ddmetrics-1.1.0/lib/ddmetrics/version.rb0000644000004100000410000000011014570572607020262 0ustar www-datawww-data# frozen_string_literal: true module DDMetrics VERSION = '1.1.0' end ddmetrics-1.1.0/lib/ddmetrics/printer.rb0000644000004100000410000000252314570572607020272 0ustar www-datawww-data# frozen_string_literal: true module DDMetrics class Printer def summary_to_s(summary) table_for_summary(summary).to_s end def counter_to_s(counter) table_for_counter(counter).to_s end private def table_for_summary(summary) header_labels = nil headers = ['count', 'min', '.50', '.90', '.95', 'max', 'tot'] rows = summary.labels.map do |label| header_labels ||= label.to_a.sort.map(&:first).map(&:to_s) stats = summary.get(label) count = stats.count min = stats.min p50 = stats.quantile(0.50) p90 = stats.quantile(0.90) p95 = stats.quantile(0.95) tot = stats.sum max = stats.max label.to_a.sort.map(&:last).map(&:to_s) + [count.to_s] + [min, p50, p90, p95, max, tot].map { |r| format('%4.2f', r) } end DDMetrics::Table.new([header_labels + headers] + rows, num_headers: header_labels.size) end def table_for_counter(counter) header_labels = nil headers = ['count'] rows = counter.labels.map do |label| header_labels ||= label.to_a.sort.map(&:first).map(&:to_s) label.to_a.sort.map(&:last).map(&:to_s) + [counter.get(label).to_s] end DDMetrics::Table.new([header_labels + headers] + rows, num_headers: header_labels.size) end end end ddmetrics-1.1.0/lib/ddmetrics/stats.rb0000644000004100000410000000161014570572607017741 0ustar www-datawww-data# frozen_string_literal: true module DDMetrics class Stats class EmptyError < StandardError def message 'Not enough data to perform calculation' end end def initialize(values) @values = values end def inspect "<#{self.class} count=#{count}>" end def count @values.size end def sum raise EmptyError if @values.empty? @values.reduce(:+) end def avg sum.to_f / count end def min quantile(0.0) end def max quantile(1.0) end def quantile(fraction) raise EmptyError if @values.empty? target = (@values.size - 1) * fraction.to_f interp = target % 1.0 (sorted_values[target.floor] * (1.0 - interp)) + (sorted_values[target.ceil] * interp) end private def sorted_values @sorted_values ||= @values.sort end end end ddmetrics-1.1.0/lib/ddmetrics/metric.rb0000644000004100000410000000125114570572607020067 0ustar www-datawww-data# frozen_string_literal: true module DDMetrics class Metric include Enumerable def initialize @basic_metrics = {} end def get(label) basic_metric_for(label, BasicCounter) end def labels @basic_metrics.keys end def each @basic_metrics.each_key do |label| yield(label, get(label)) end end # @api private def basic_metric_for(label, basic_class) @basic_metrics.fetch(label) { @basic_metrics[label] = basic_class.new } end # @api private def validate_label(label) return if label.is_a?(Hash) raise ArgumentError, 'label argument must be a hash' end end end ddmetrics-1.1.0/LICENSE.txt0000644000004100000410000000210014570572607015350 0ustar www-datawww-dataThe MIT License (MIT) Copyright (c) 2017–2018 Denis Defreyne Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ddmetrics-1.1.0/spec/0000755000004100000410000000000014570572607014466 5ustar www-datawww-dataddmetrics-1.1.0/spec/spec_helper.rb0000644000004100000410000000036714570572607017312 0ustar www-datawww-data# frozen_string_literal: true require 'simplecov' SimpleCov.start require 'ddmetrics' require 'fuubar' require 'rspec/its' require 'timecop' RSpec.configure do |c| c.fuubar_progress_bar_options = { format: '%c/%C |<%b>%i| %p%%', } end ddmetrics-1.1.0/spec/ddmetrics_spec.rb0000644000004100000410000000021314570572607017777 0ustar www-datawww-data# frozen_string_literal: true describe DDMetrics do it 'has a version number' do expect(DDMetrics::VERSION).not_to be nil end end ddmetrics-1.1.0/spec/ddmetrics/0000755000004100000410000000000014570572607016444 5ustar www-datawww-dataddmetrics-1.1.0/spec/ddmetrics/stopwatch_spec.rb0000644000004100000410000000427114570572607022023 0ustar www-datawww-data# frozen_string_literal: true describe DDMetrics::Stopwatch do subject(:stopwatch) { described_class.new } after { Timecop.return } it 'is zero by default' do expect(stopwatch.duration).to eq(0.0) end it 'records correct duration after start+stop' do stopwatch.start sleep 0.1 stopwatch.stop expect(stopwatch.duration).to be_within(0.01).of(0.1) end it 'records correct duration after start+stop+start+stop' do stopwatch.start sleep 0.1 stopwatch.stop sleep 0.1 stopwatch.start sleep 0.1 stopwatch.stop expect(stopwatch.duration).to be_within(0.02).of(0.2) end it 'records correct duration with single #run call' do stopwatch.run do sleep 0.1 end expect(stopwatch.duration).to be_within(0.01).of(0.1) end it 'records correct duration with multiple #run calls' do stopwatch.run do sleep 0.1 end stopwatch.run do sleep 0.2 end expect(stopwatch.duration).to be_within(0.03).of(0.3) end it 'returns the right value from a #run call' do result = stopwatch.run do sleep 0.1 'donkey' end expect(result).to eq('donkey') end it 'errors when stopping when not started' do expect { stopwatch.stop } .to raise_error( DDMetrics::Stopwatch::NotRunningError, 'Cannot stop, because stopwatch is not running', ) end it 'errors when starting when already started' do stopwatch.start expect { stopwatch.start } .to raise_error( DDMetrics::Stopwatch::AlreadyRunningError, 'Cannot start, because stopwatch is already running', ) end it 'reports running status' do expect(stopwatch).not_to be_running expect(stopwatch).to be_stopped stopwatch.start expect(stopwatch).to be_running expect(stopwatch).not_to be_stopped stopwatch.stop expect(stopwatch).not_to be_running expect(stopwatch).to be_stopped end it 'errors when getting duration while running' do stopwatch.start expect { stopwatch.duration } .to raise_error( DDMetrics::Stopwatch::StillRunningError, 'Cannot get duration, because stopwatch is still running', ) end end ddmetrics-1.1.0/spec/ddmetrics/summary_spec.rb0000644000004100000410000000622714570572607021507 0ustar www-datawww-data# frozen_string_literal: true describe DDMetrics::Summary do subject(:summary) { described_class.new } describe '#observe' do context 'non-hash label' do subject { summary.observe(1.23, 'WRONG UGH') } it 'errors' do expect { subject }.to raise_error(ArgumentError, 'label argument must be a hash') end end end describe '#get' do subject { summary.get(filter: :erb) } before do summary.observe(2.1, filter: :erb) summary.observe(4.1, filter: :erb) summary.observe(5.3, filter: :haml) end it { is_expected.to be_a(DDMetrics::Stats) } its(:sum) { is_expected.to eq(2.1 + 4.1) } its(:count) { is_expected.to eq(2) } end describe '#labels' do subject { summary.labels } before do summary.observe(2.1, filter: :erb) summary.observe(4.1, filter: :erb) summary.observe(5.3, filter: :haml) end it { is_expected.to match_array([{ filter: :haml }, { filter: :erb }]) } end describe '#each' do subject do {}.tap do |res| summary.each { |label, stats| res[label] = stats.avg.round(2) } end end before do summary.observe(2.1, filter: :erb) summary.observe(4.1, filter: :erb) summary.observe(5.3, filter: :haml) end it { is_expected.to eq({ filter: :haml } => 5.3, { filter: :erb } => 3.1) } it 'is enumerable' do expect(summary.map { |_label, stats| stats.sum }.sort) .to eq([5.3, 2.1 + 4.1]) end end describe '#to_s' do subject { summary.to_s } context 'one label' do before do summary.observe(2.1, filter: :erb) summary.observe(4.1, filter: :erb) summary.observe(5.3, filter: :haml) end it 'returns table' do expected = <<~TABLE filter │ count min .50 .90 .95 max tot ───────┼──────────────────────────────────────────────── erb │ 2 2.10 3.10 3.90 4.00 4.10 6.20 haml │ 1 5.30 5.30 5.30 5.30 5.30 5.30 TABLE expect(subject.strip).to eq(expected.strip) end end context 'multiple labels' do before do summary.observe(2.1, filter: :erb, stage: :pre) summary.observe(4.1, filter: :erb, stage: :pre) summary.observe(1.2, filter: :erb, stage: :post) summary.observe(5.3, filter: :haml, stage: :post) end it 'returns table' do expected = <<~TABLE filter stage │ count min .50 .90 .95 max tot ───────────────┼──────────────────────────────────────────────── erb pre │ 2 2.10 3.10 3.90 4.00 4.10 6.20 erb post │ 1 1.20 1.20 1.20 1.20 1.20 1.20 haml post │ 1 5.30 5.30 5.30 5.30 5.30 5.30 TABLE expect(subject.strip).to eq(expected.strip) end end end end ddmetrics-1.1.0/spec/ddmetrics/basic_summary_spec.rb0000644000004100000410000000074514570572607022647 0ustar www-datawww-data# frozen_string_literal: true describe DDMetrics::BasicSummary do subject(:summary) { described_class.new } context 'no observations' do its(:values) { is_expected.to be_empty } end context 'one observation' do before { subject.observe(2.1) } its(:values) { is_expected.to eq([2.1]) } end context 'two observations' do before do subject.observe(2.1) subject.observe(4.1) end its(:values) { is_expected.to eq([2.1, 4.1]) } end end ddmetrics-1.1.0/spec/ddmetrics/table_spec.rb0000644000004100000410000000175314570572607021100 0ustar www-datawww-data# frozen_string_literal: true describe DDMetrics::Table do let(:table) { described_class.new(rows) } let(:rows) do [ %w[name awesomeness], %w[denis high], %w[REDACTED low], ] end example do expect(table.to_s).to eq(<<~TABLE.rstrip) name │ awesomeness ─────────┼──────────── denis │ high REDACTED │ low TABLE end context 'unsorted data' do let(:rows) do [ %w[name awesomeness], %w[ccc highc], %w[bbb highb], %w[ddd highd], %w[eee highe], %w[aaa higha], ] end example do expect(table.to_s).to eq(<<~TABLE.rstrip) name │ awesomeness ─────┼──────────── aaa │ higha bbb │ highb ccc │ highc ddd │ highd eee │ highe TABLE end end end ddmetrics-1.1.0/spec/ddmetrics/counter_spec.rb0000644000004100000410000000471014570572607021464 0ustar www-datawww-data# frozen_string_literal: true describe DDMetrics::Counter do subject(:counter) { described_class.new } describe 'new counter' do it 'starts at 0' do expect(subject.get(filter: :erb)).to eq(0) expect(subject.get(filter: :haml)).to eq(0) end end describe '#increment' do subject { counter.increment(filter: :erb) } it 'increments the matching value' do expect { subject } .to change { counter.get(filter: :erb) } .from(0) .to(1) end it 'does not increment any other value' do expect(counter.get(filter: :haml)).to eq(0) expect { subject } .not_to change { counter.get(filter: :haml) } end context 'non-hash label' do subject { counter.increment('WRONG UGH') } it 'errors' do expect { subject }.to raise_error(ArgumentError, 'label argument must be a hash') end end end describe '#get' do subject { counter.get(filter: :erb) } context 'not incremented' do it { is_expected.to eq(0) } end context 'incremented' do before { counter.increment(filter: :erb) } it { is_expected.to eq(1) } end context 'other incremented' do before { counter.increment(filter: :haml) } it { is_expected.to eq(0) } end end describe '#labels' do subject { counter.labels } before do counter.increment(filter: :erb) counter.increment(filter: :erb) counter.increment(filter: :haml) end it { is_expected.to match_array([{ filter: :haml }, { filter: :erb }]) } end describe '#each' do subject do {}.tap do |res| counter.each { |label, count| res[label] = count } end end before do counter.increment(filter: :erb) counter.increment(filter: :erb) counter.increment(filter: :haml) end it { is_expected.to eq({ filter: :haml } => 1, { filter: :erb } => 2) } it 'is enumerable' do expect(counter.map { |_label, count| count }.sort) .to eq([1, 2]) end end describe '#to_s' do subject { counter.to_s } before do counter.increment(filter: :erb) counter.increment(filter: :erb) counter.increment(filter: :haml) end it 'returns table' do expected = <<~TABLE filter │ count ───────┼────── erb │ 2 haml │ 1 TABLE expect(subject.strip).to eq(expected.strip) end end end ddmetrics-1.1.0/spec/ddmetrics/stats_spec.rb0000644000004100000410000000547614570572607021155 0ustar www-datawww-data# frozen_string_literal: true describe DDMetrics::Stats do subject(:stats) { described_class.new(values) } context 'no values' do let(:values) { [] } it 'errors on #min' do expect { subject.min } .to raise_error(DDMetrics::Stats::EmptyError) end it 'errors on #max' do expect { subject.max } .to raise_error(DDMetrics::Stats::EmptyError) end it 'errors on #avg' do expect { subject.avg } .to raise_error(DDMetrics::Stats::EmptyError) end it 'errors on #sum' do expect { subject.sum } .to raise_error(DDMetrics::Stats::EmptyError) end its(:count) { is_expected.to eq(0) } end context 'one value' do let(:values) { [2.1] } its(:inspect) { is_expected.to eq('') } its(:count) { is_expected.to eq(1) } its(:sum) { is_expected.to eq(2.1) } its(:avg) { is_expected.to eq(2.1) } its(:min) { is_expected.to eq(2.1) } its(:max) { is_expected.to eq(2.1) } it 'has proper quantiles' do expect(subject.quantile(0.00)).to eq(2.1) expect(subject.quantile(0.25)).to eq(2.1) expect(subject.quantile(0.50)).to eq(2.1) expect(subject.quantile(0.90)).to eq(2.1) expect(subject.quantile(0.99)).to eq(2.1) end end context 'two values' do let(:values) { [2.1, 4.1] } its(:inspect) { is_expected.to eq('') } its(:count) { is_expected.to be_within(0.000001).of(2) } its(:sum) { is_expected.to be_within(0.000001).of(6.2) } its(:avg) { is_expected.to be_within(0.000001).of(3.1) } its(:min) { is_expected.to be_within(0.000001).of(2.1) } its(:max) { is_expected.to be_within(0.000001).of(4.1) } it 'has proper quantiles' do expect(subject.quantile(0.00)).to be_within(0.000001).of(2.1) expect(subject.quantile(0.25)).to be_within(0.000001).of(2.6) expect(subject.quantile(0.50)).to be_within(0.000001).of(3.1) expect(subject.quantile(0.90)).to be_within(0.000001).of(3.9) expect(subject.quantile(0.99)).to be_within(0.000001).of(4.08) end end context 'integer values' do let(:values) { [1, 2] } its(:count) { is_expected.to be_within(0.000001).of(2) } its(:sum) { is_expected.to be_within(0.000001).of(3) } its(:avg) { is_expected.to be_within(0.000001).of(1.5) } its(:min) { is_expected.to be_within(0.000001).of(1) } its(:max) { is_expected.to be_within(0.000001).of(2) } it 'has proper quantiles' do expect(subject.quantile(0.00)).to be_within(0.000001).of(1.0) expect(subject.quantile(0.25)).to be_within(0.000001).of(1.25) expect(subject.quantile(0.50)).to be_within(0.000001).of(1.5) expect(subject.quantile(0.90)).to be_within(0.000001).of(1.9) expect(subject.quantile(0.99)).to be_within(0.000001).of(1.99) end end end ddmetrics-1.1.0/spec/ddmetrics/basic_counter_spec.rb0000644000004100000410000000056514570572607022631 0ustar www-datawww-data# frozen_string_literal: true describe DDMetrics::BasicCounter do subject(:counter) { described_class.new } it 'starts at 0' do expect(counter.value).to eq(0) end describe '#increment' do subject { counter.increment } it 'increments' do expect { subject } .to change { counter.value } .from(0) .to(1) end end end ddmetrics-1.1.0/ddmetrics.gemspec0000644000004100000410000000115714570572607017063 0ustar www-datawww-data# frozen_string_literal: true require_relative 'lib/ddmetrics/version' Gem::Specification.new do |spec| spec.name = 'ddmetrics' spec.version = DDMetrics::VERSION spec.authors = ['Denis Defreyne'] spec.email = ['denis+rubygems@denis.ws'] spec.summary = 'Non-timeseries measurements for Ruby programs' spec.homepage = 'https://github.com/ddfreyne/ddmetrics' spec.license = 'MIT' spec.required_ruby_version = '>= 2.3.0' spec.files = `git ls-files -z`.split("\x0") spec.require_paths = ['lib'] spec.metadata['rubygems_mfa_required'] = 'true' end ddmetrics-1.1.0/.rspec0000644000004100000410000000006114570572607014646 0ustar www-datawww-data-r ./spec/spec_helper.rb --format Fuubar --color ddmetrics-1.1.0/Rakefile0000644000004100000410000000051314570572607015200 0ustar www-datawww-data# frozen_string_literal: true require 'rubocop/rake_task' require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) do |t| t.verbose = false end task :test_samples do sh 'bundle exec ruby samples/cache.rb > /dev/null' end RuboCop::RakeTask.new(:rubocop) task default: :test task test: %i[spec rubocop test_samples] ddmetrics-1.1.0/CODE_OF_CONDUCT.md0000644000004100000410000000624414570572607016341 0ustar www-datawww-data# Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at denis.defreyne@stoneship.org. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] [homepage]: http://contributor-covenant.org [version]: http://contributor-covenant.org/version/1/4/ ddmetrics-1.1.0/.rubocop_todo.yml0000644000004100000410000000657714570572607017052 0ustar www-datawww-data# This configuration was generated by # `rubocop --auto-gen-config --exclude-limit 300` # on 2023-10-23 14:11:14 UTC using RuboCop version 1.57.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: be, be_nil RSpec/BeNil: Exclude: - 'spec/ddmetrics_spec.rb' # Offense count: 15 # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: Exclude: - 'spec/ddmetrics/basic_summary_spec.rb' - 'spec/ddmetrics/counter_spec.rb' - 'spec/ddmetrics/stats_spec.rb' - 'spec/ddmetrics/summary_spec.rb' - 'spec/ddmetrics/table_spec.rb' # Offense count: 3 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowConsecutiveOneLiners. RSpec/EmptyLineAfterHook: Exclude: - 'spec/ddmetrics/basic_summary_spec.rb' - 'spec/ddmetrics/counter_spec.rb' # Offense count: 9 # Configuration parameters: CountAsOne. RSpec/ExampleLength: Max: 9 # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: method_call, block RSpec/ExpectChange: Exclude: - 'spec/ddmetrics/basic_counter_spec.rb' # Offense count: 8 # Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. # Include: **/*_spec*rb*, **/spec/**/* RSpec/FilePath: Exclude: - 'spec/ddmetrics/basic_counter_spec.rb' - 'spec/ddmetrics/basic_summary_spec.rb' - 'spec/ddmetrics/counter_spec.rb' - 'spec/ddmetrics/stats_spec.rb' - 'spec/ddmetrics/stopwatch_spec.rb' - 'spec/ddmetrics/summary_spec.rb' - 'spec/ddmetrics/table_spec.rb' - 'spec/ddmetrics_spec.rb' # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). RSpec/MatchArray: Exclude: - 'spec/ddmetrics/counter_spec.rb' - 'spec/ddmetrics/summary_spec.rb' # Offense count: 6 RSpec/MultipleExpectations: Max: 6 # Offense count: 32 # Configuration parameters: EnforcedStyle, IgnoreSharedExamples. # SupportedStyles: always, named_only RSpec/NamedSubject: Exclude: - 'spec/ddmetrics/basic_counter_spec.rb' - 'spec/ddmetrics/basic_summary_spec.rb' - 'spec/ddmetrics/counter_spec.rb' - 'spec/ddmetrics/stats_spec.rb' - 'spec/ddmetrics/summary_spec.rb' # Offense count: 8 # Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata. # Include: **/*_spec.rb RSpec/SpecFilePathFormat: Exclude: - '**/spec/routing/**/*' - 'spec/ddmetrics/basic_counter_spec.rb' - 'spec/ddmetrics/basic_summary_spec.rb' - 'spec/ddmetrics/counter_spec.rb' - 'spec/ddmetrics/stats_spec.rb' - 'spec/ddmetrics/stopwatch_spec.rb' - 'spec/ddmetrics/summary_spec.rb' - 'spec/ddmetrics/table_spec.rb' - 'spec/ddmetrics_spec.rb' # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Rake/Desc: Exclude: - 'Rakefile' # Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Mode. Style/StringConcatenation: Exclude: - 'lib/ddmetrics/table.rb' - 'scripts/release' ddmetrics-1.1.0/Gemfile0000644000004100000410000000046014570572607015027 0ustar www-datawww-data# frozen_string_literal: true source 'https://rubygems.org' gemspec group :devel do gem 'fuubar' gem 'rake' gem 'rspec' gem 'rspec-its' gem 'rubocop', '~> 1.57' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 2.24' gem 'simplecov', require: false gem 'timecop', '~> 0.9' end ddmetrics-1.1.0/samples/0000755000004100000410000000000014570572607015200 5ustar www-datawww-dataddmetrics-1.1.0/samples/cache.rb0000644000004100000410000000127714570572607016577 0ustar www-datawww-data# frozen_string_literal: true require 'ddmetrics' class Cache attr_reader :counter def initialize @map = {} @counter = DDMetrics::Counter.new end def []=(key, value) @counter.increment(type: :set) @map[key] = value end def [](key) if @map.key?(key) @counter.increment(type: :get_hit) else @counter.increment(type: :get_miss) end @map[key] end end cache = Cache.new cache['greeting'] cache['greeting'] cache['greeting'] = 'Hi there!' cache['greeting'] cache['greeting'] cache['greeting'] p cache.counter.get(type: :set) # => 1 p cache.counter.get(type: :get_hit) # => 3 p cache.counter.get(type: :get_miss) # => 2 puts cache.counter ddmetrics-1.1.0/.travis.yml0000644000004100000410000000031714570572607015646 0ustar www-datawww-datalanguage: ruby rvm: - "2.3" - "2.4" - "2.5" branches: only: - "master" before_install: - gem update --system - gem install bundler -v 1.16.0 cache: bundler sudo: false git: depth: 10 ddmetrics-1.1.0/README.md0000644000004100000410000001534314570572607015021 0ustar www-datawww-data[![Gem version](https://img.shields.io/gem/v/ddmetrics.svg)](http://rubygems.org/gems/ddmetrics) [![Gem downloads](https://img.shields.io/gem/dt/ddmetrics.svg)](http://rubygems.org/gems/ddmetrics) [![Build status](https://img.shields.io/travis/ddfreyne/ddmetrics.svg)](https://travis-ci.org/ddfreyne/ddmetrics) [![Code Climate](https://img.shields.io/codeclimate/github/ddfreyne/ddmetrics.svg)](https://codeclimate.com/github/ddfreyne/ddmetrics) # DDMetrics _DDMetrics_ is a Ruby library for recording and analysing measurements in short-running Ruby processes. If you are looking for a full-featured timeseries monitoring system, look no further than [Prometheus](https://prometheus.io/). ## Example Take the following (naïve) cache implementation as a starting point: ```ruby class Cache def initialize @map = {} end def []=(key, value) @map[key] = value end def [](key) @map[key] end end ``` To start instrumenting this code, require `ddmetrics`, create a counter, and record some metrics: ```ruby require 'ddmetrics' class Cache attr_reader :counter def initialize @map = {} @counter = DDMetrics::Counter.new end def []=(key, value) @counter.increment(type: :set) @map[key] = value end def [](key) if @map.key?(key) @counter.increment(type: :get_hit) else @counter.increment(type: :get_miss) end @map[key] end end ``` Let’s construct a cache and exercise it: ```ruby cache = Cache.new cache['greeting'] cache['greeting'] cache['greeting'] = 'Hi there!' cache['greeting'] cache['greeting'] cache['greeting'] ``` Finally, get the recorded values: ```ruby cache.counter.get(type: :set) # => 1 cache.counter.get(type: :get_hit) # => 3 cache.counter.get(type: :get_miss) # => 2 ``` Or even print all stats: ```ruby puts cache.counter ``` ``` type │ count ─────────┼────── get_hit │ 3 get_miss │ 2 set │ 1 ``` ## Scope * No timeseries: Metrics are not recorded over time. If you want to record timeseries data, consider using [Prometheus](https://prometheus.io/). * Not intended for long-running processes: Metrics data (particularly summary metrics) can accumulate in memory and cause memory pressure. This project is not suited for long-running processes, such as servers. For monitoring long-running processes, consider using [Prometheus](https://prometheus.io/). * Not thread-safe: The implementation is not thread-safe. If you require thread safety, consider wrapping the functionality provided. ## Installation Add this line to your application's Gemfile: ```ruby gem 'ddmetrics' ``` And then execute: $ bundle Or install it yourself as: $ gem install ddmetrics ## Usage _DDMetrics_ provides two metric types: * A **counter** is an integer metric that only ever increases. Examples: cache hits, number of files written, … * A **summary** records observations, and provides functionality for describing the distribution of the observations through quantiles. Examples: outgoing request durations, size of written files, … Each metric is recorded with a label, which is a hash that is useful to further refine the kind of data that is being recorded. For example: ```ruby cache_hits_counter.increment(target: :file_cache) request_durations_summary.observe(1.07, api: :weather) ``` ### Counters To create a counter, instantiate `DDMetrics::Counter`: ```ruby counter = DDMetrics::Counter.new ``` To increment a counter, call `#increment` with a label: ```ruby counter.increment(target: :file_cache) ``` To get the value for a certain label, use `#get`: ```ruby counter.get(target: :file_cache) # => 1 ``` ### Summaries To create a summary, instantiate `DDMetrics::Summary`: ```ruby summary = DDMetrics::Summary.new ``` To observe a value, call `#observe` with the value to observe, along with a label: ```ruby summary.observe(0.88, api: :weather) summary.observe(1.07, api: :weather) summary.observe(0.91, api: :weather) ``` To get the list of observations for a certain label, use `#get`, which will return a `DDMetrics::Stats` instance: ```ruby summary.get(api: :weather) # => ``` The following methods are available on `DDMetrics::Stats`: * `#count`: returns the number of values * `#sum`: returns the sum of all values * `#avg`: returns the average of all values * `#min`: returns the minimum value * `#max`: returns the maximum value * `#quantile(fraction)`: returns the quantile at the given fraction (0.0 – 1.0) ### Printing metrics To print a metric, use `#to_s`. For example: ```ruby summary = DDMetrics::Summary.new summary.observe(2.1, filter: :erb) summary.observe(4.1, filter: :erb) summary.observe(5.3, filter: :haml) puts summary ``` Output: ``` filter │ count min .50 .90 .95 max tot ───────┼──────────────────────────────────────────────── erb │ 2 2.10 3.10 3.90 4.00 4.10 6.20 haml │ 1 5.30 5.30 5.30 5.30 5.30 5.30 ``` ### Stopwatch The `DDMetrics::Stopwatch` class can be used to measure durations. Use `#start` and `#stop` to start and stop the stopwatch, respectively, and `#duration` to read the value of the stopwatch: ```ruby stopwatch = DDMetrics::Stopwatch.new stopwatch.start sleep 1 stopwatch.stop puts "That took #{stopwatch.duration}s." # Output: That took 1.006831s. ``` A stopwatch, once created, will never reset its duration. Running the stopwatch again will add to the existing duration: ```ruby stopwatch.start sleep 1 stopwatch.stop puts "That took #{stopwatch.duration}s." # Output: That took 2.012879s. ``` You can use `#run` with a block for convenience: ```ruby stopwatch.run do sleep 1 end ``` `#run` will return the value of the block: ```ruby result = stopwatch.run do sleep 1 'Donkey' end puts result # Output: Donkey ``` You can query whether or not a stopwatch is running using `#running?`; `#stopped?` is the opposite of `#running?`. ## Development Install dependencies: $ bundle Run tests: $ bundle exec rake ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/ddfreyne/ddmetrics. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. ## License The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT). ## Code of Conduct Everyone interacting in the DDMetrics project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ddfreyne/ddmetrics/blob/master/CODE_OF_CONDUCT.md). ddmetrics-1.1.0/.rubocop.yml0000644000004100000410000002105214570572607016006 0ustar www-datawww-datainherit_from: .rubocop_todo.yml require: - rubocop-rake - rubocop-rspec # ----- CONFIGURED ----- AllCops: TargetRubyVersion: 2.3 DisplayCopNames: true Style/TrailingCommaInArguments: EnforcedStyleForMultiline: comma Style/TrailingCommaInArrayLiteral: EnforcedStyleForMultiline: comma Style/TrailingCommaInHashLiteral: EnforcedStyleForMultiline: comma Layout/FirstArrayElementIndentation: EnforcedStyle: consistent # Documentation lives elsewhere, and not everything needs to be documented. Style/Documentation: Enabled: false # This doesn’t work well with RSpec. Lint/AmbiguousBlockAssociation: Exclude: - spec/**/*_spec.rb # ----- DISABLED (metrics) ----- # Cops for metrics are disabled because they should not cause tests to fail. Metrics: Enabled: false Layout/LineLength: Enabled: false # ----- NEW ----- Gemspec/DeprecatedAttributeAssignment: # new in 1.30 Enabled: true Gemspec/DevelopmentDependencies: # new in 1.44 Enabled: true Gemspec/RequireMFA: # new in 1.23 Enabled: true Layout/LineContinuationLeadingSpace: # new in 1.31 Enabled: true Layout/LineContinuationSpacing: # new in 1.31 Enabled: true Layout/LineEndStringConcatenationIndentation: # new in 1.18 Enabled: true Layout/SpaceBeforeBrackets: # new in 1.7 Enabled: true Lint/AmbiguousAssignment: # new in 1.7 Enabled: true Lint/AmbiguousOperatorPrecedence: # new in 1.21 Enabled: true Lint/AmbiguousRange: # new in 1.19 Enabled: true Lint/ConstantOverwrittenInRescue: # new in 1.31 Enabled: true Lint/DeprecatedConstants: # new in 1.8 Enabled: true Lint/DuplicateBranch: # new in 1.3 Enabled: true Lint/DuplicateMagicComment: # new in 1.37 Enabled: true Lint/DuplicateMatchPattern: # new in 1.50 Enabled: true Lint/DuplicateRegexpCharacterClassElement: # new in 1.1 Enabled: true Lint/EmptyBlock: # new in 1.1 Enabled: true Lint/EmptyClass: # new in 1.3 Enabled: true Lint/EmptyInPattern: # new in 1.16 Enabled: true Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21 Enabled: true Lint/LambdaWithoutLiteralBlock: # new in 1.8 Enabled: true Lint/MixedCaseRange: # new in 1.53 Enabled: true Lint/NoReturnInBeginEndBlocks: # new in 1.2 Enabled: true Lint/NonAtomicFileOperation: # new in 1.31 Enabled: true Lint/NumberedParameterAssignment: # new in 1.9 Enabled: true Lint/OrAssignmentToConstant: # new in 1.9 Enabled: true Lint/RedundantDirGlobSort: # new in 1.8 Enabled: true Lint/RedundantRegexpQuantifiers: # new in 1.53 Enabled: true Lint/RefinementImportMethods: # new in 1.27 Enabled: true Lint/RequireRangeParentheses: # new in 1.32 Enabled: true Lint/RequireRelativeSelfPath: # new in 1.22 Enabled: true Lint/SymbolConversion: # new in 1.9 Enabled: true Lint/ToEnumArguments: # new in 1.1 Enabled: true Lint/TripleQuotes: # new in 1.9 Enabled: true Lint/UnexpectedBlockArity: # new in 1.5 Enabled: true Lint/UnmodifiedReduceAccumulator: # new in 1.1 Enabled: true Lint/UselessRescue: # new in 1.43 Enabled: true Lint/UselessRuby2Keywords: # new in 1.23 Enabled: true Naming/BlockForwarding: # new in 1.24 Enabled: true Security/CompoundHash: # new in 1.28 Enabled: true Security/IoMethods: # new in 1.22 Enabled: true Style/ArgumentsForwarding: # new in 1.1 Enabled: true Style/ArrayIntersect: # new in 1.40 Enabled: true Style/CollectionCompact: # new in 1.2 Enabled: true Style/ComparableClamp: # new in 1.44 Enabled: true Style/ConcatArrayLiterals: # new in 1.41 Enabled: true Style/DataInheritance: # new in 1.49 Enabled: true Style/DirEmpty: # new in 1.48 Enabled: true Style/DocumentDynamicEvalDefinition: # new in 1.1 Enabled: true Style/EmptyHeredoc: # new in 1.32 Enabled: true Style/EndlessMethod: # new in 1.8 Enabled: true Style/EnvHome: # new in 1.29 Enabled: true Style/ExactRegexpMatch: # new in 1.51 Enabled: true Style/FetchEnvVar: # new in 1.28 Enabled: true Style/FileEmpty: # new in 1.48 Enabled: true Style/FileRead: # new in 1.24 Enabled: true Style/FileWrite: # new in 1.24 Enabled: true Style/HashConversion: # new in 1.10 Enabled: true Style/HashExcept: # new in 1.7 Enabled: true Style/IfWithBooleanLiteralBranches: # new in 1.9 Enabled: true Style/InPatternThen: # new in 1.16 Enabled: true Style/MagicCommentFormat: # new in 1.35 Enabled: true Style/MapCompactWithConditionalBlock: # new in 1.30 Enabled: true Style/MapToHash: # new in 1.24 Enabled: true Style/MapToSet: # new in 1.42 Enabled: true Style/MinMaxComparison: # new in 1.42 Enabled: true Style/MultilineInPatternThen: # new in 1.16 Enabled: true Style/NegatedIfElseCondition: # new in 1.2 Enabled: true Style/NestedFileDirname: # new in 1.26 Enabled: true Style/NilLambda: # new in 1.3 Enabled: true Style/NumberedParameters: # new in 1.22 Enabled: true Style/NumberedParametersLimit: # new in 1.22 Enabled: true Style/ObjectThen: # new in 1.28 Enabled: true Style/OpenStructUse: # new in 1.23 Enabled: true Style/OperatorMethodCall: # new in 1.37 Enabled: true Style/QuotedSymbols: # new in 1.16 Enabled: true Style/RedundantArgument: # new in 1.4 Enabled: true Style/RedundantArrayConstructor: # new in 1.52 Enabled: true Style/RedundantConstantBase: # new in 1.40 Enabled: true Style/RedundantCurrentDirectoryInPath: # new in 1.53 Enabled: true Style/RedundantDoubleSplatHashBraces: # new in 1.41 Enabled: true Style/RedundantEach: # new in 1.38 Enabled: true Style/RedundantFilterChain: # new in 1.52 Enabled: true Style/RedundantHeredocDelimiterQuotes: # new in 1.45 Enabled: true Style/RedundantInitialize: # new in 1.27 Enabled: true Style/RedundantLineContinuation: # new in 1.49 Enabled: true Style/RedundantRegexpArgument: # new in 1.53 Enabled: true Style/RedundantRegexpConstructor: # new in 1.52 Enabled: true Style/RedundantSelfAssignmentBranch: # new in 1.19 Enabled: true Style/RedundantStringEscape: # new in 1.37 Enabled: true Style/ReturnNilInPredicateMethodDefinition: # new in 1.53 Enabled: true Style/SelectByRegexp: # new in 1.22 Enabled: true Style/SingleLineDoEndBlock: # new in 1.57 Enabled: true Style/StringChars: # new in 1.12 Enabled: true Style/SwapValues: # new in 1.1 Enabled: true Style/YAMLFileRead: # new in 1.53 Enabled: true Capybara/ClickLinkOrButtonStyle: # new in 2.19 Enabled: true Capybara/MatchStyle: # new in 2.17 Enabled: true Capybara/NegationMatcher: # new in 2.14 Enabled: true Capybara/SpecificActions: # new in 2.14 Enabled: true Capybara/SpecificFinders: # new in 2.13 Enabled: true Capybara/SpecificMatcher: # new in 2.12 Enabled: true Capybara/RSpec/HaveSelector: # new in 2.19 Enabled: true Capybara/RSpec/PredicateMatcher: # new in 2.19 Enabled: true FactoryBot/AssociationStyle: # new in 2.23 Enabled: true FactoryBot/ConsistentParenthesesStyle: # new in 2.14 Enabled: true FactoryBot/FactoryAssociationWithStrategy: # new in 2.23 Enabled: true FactoryBot/FactoryNameStyle: # new in 2.16 Enabled: true FactoryBot/IdSequence: # new in <> Enabled: true FactoryBot/RedundantFactoryOption: # new in 2.23 Enabled: true FactoryBot/SyntaxMethods: # new in 2.7 Enabled: true RSpec/BeEmpty: # new in 2.20 Enabled: true RSpec/BeEq: # new in 2.9.0 Enabled: true RSpec/BeNil: # new in 2.9.0 Enabled: true RSpec/ChangeByZero: # new in 2.11 Enabled: true RSpec/ContainExactly: # new in 2.19 Enabled: true RSpec/DuplicatedMetadata: # new in 2.16 Enabled: true RSpec/EmptyMetadata: # new in 2.24 Enabled: true RSpec/Eq: # new in 2.24 Enabled: true RSpec/ExcessiveDocstringSpacing: # new in 2.5 Enabled: true RSpec/IdenticalEqualityAssertion: # new in 2.4 Enabled: true RSpec/IndexedLet: # new in 2.20 Enabled: true RSpec/MatchArray: # new in 2.19 Enabled: true RSpec/MetadataStyle: # new in 2.24 Enabled: true RSpec/NoExpectationExample: # new in 2.13 Enabled: true RSpec/PendingWithoutReason: # new in 2.16 Enabled: true RSpec/ReceiveMessages: # new in 2.23 Enabled: true RSpec/RedundantAround: # new in 2.19 Enabled: true RSpec/SkipBlockInsideExample: # new in 2.19 Enabled: true RSpec/SortMetadata: # new in 2.14 Enabled: true RSpec/SpecFilePathFormat: # new in 2.24 Enabled: true RSpec/SpecFilePathSuffix: # new in 2.24 Enabled: true RSpec/SubjectDeclaration: # new in 2.5 Enabled: true RSpec/VerifiedDoubleReference: # new in 2.10.0 Enabled: true RSpec/Rails/AvoidSetupHook: # new in 2.4 Enabled: true RSpec/Rails/HaveHttpStatus: # new in 2.12 Enabled: true RSpec/Rails/InferredSpecType: # new in 2.14 Enabled: true RSpec/Rails/MinitestAssertions: # new in 2.17 Enabled: true RSpec/Rails/NegationBeValid: # new in 2.23 Enabled: true RSpec/Rails/TravelAround: # new in 2.19 Enabled: true