Skip to content

Commit

Permalink
Rename gem to pack_stats (#25)
Browse files Browse the repository at this point in the history
* Reset version

* modularization_statistics => pack_stats

* modularization_statistics => pack_stats in filenames

* ModularizationStatistics => PackStats
  • Loading branch information
Alex Evanczuk committed Dec 12, 2022
1 parent 7e3e12c commit c27d3f3
Show file tree
Hide file tree
Showing 24 changed files with 64 additions and 64 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
See https://github.com/rubyatscale/modularization_statistics/releases
See https://github.com/rubyatscale/pack_stats/releases
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in modularization_statistics.gemspec
# Specify your gem's dependencies in pack_stats.gemspec
gemspec

gem 'code_ownership'
Expand Down
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
modularization_statistics (2.0.2)
pack_stats (0.0.1)
code_ownership
code_teams
dogapi
Expand Down Expand Up @@ -31,7 +31,7 @@ GEM
multi_json
i18n (1.12.0)
concurrent-ruby (~> 1.0)
json (2.6.2)
json (2.6.3)
method_source (1.0.0)
minitest (5.16.3)
multi_json (1.15.0)
Expand All @@ -50,7 +50,7 @@ GEM
parser (>= 2.6.4.0)
sorbet-runtime (>= 0.5.9204)
unparser
regexp_parser (2.6.0)
regexp_parser (2.6.1)
rexml (3.2.5)
rspec (3.11.0)
rspec-core (~> 3.11.0)
Expand All @@ -75,9 +75,9 @@ GEM
rubocop-ast (>= 1.19.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.23.0)
rubocop-ast (1.24.0)
parser (>= 3.1.1.0)
rubocop-packs (0.0.22)
rubocop-packs (0.0.30)
activesupport
parse_packwerk
rubocop
Expand Down Expand Up @@ -133,7 +133,7 @@ PLATFORMS

DEPENDENCIES
code_ownership
modularization_statistics!
pack_stats!
parse_packwerk
pry
rake
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ModularizationStatistics
# PackStats

This gem is used to report opinionated statistics about modularization to DataDog and other observability systems.

Expand All @@ -8,12 +8,12 @@ The gem reports metrics per-team, where each team is configured based on metadat
Define your teams as described in the [Code Team - Package Based Ownership](https://github.com/rubyatscale/code_ownership#package-based-ownership) documentation.

# Usage
The main method to this gem is `ModularizationStatistics#report_to_datadog!`. Refer to the Sorbet signature for this method for the exact types to be passed in.
The main method to this gem is `PackStats#report_to_datadog!`. Refer to the Sorbet signature for this method for the exact types to be passed in.

This is an example of how to use this API:

```ruby
ModularizationStatistics.report_to_datadog!(
PackStats.report_to_datadog!(
#
# A properly initialized `Dogapi::Client`
# Example: Dogapi::Client.new(ENV.fetch('DATADOG_API_KEY')
Expand Down Expand Up @@ -54,7 +54,7 @@ It's recommended to run this in CI on the main/development branch so each new co
With [`packwerk`](https://github.com/Shopify/packwerk), privacy and dependency violations do not show up until a package has set `enforce_privacy` and `enforce_dependency` (respectively) to `true`. As such, when you're first starting off, you'll see no violations, and then periodic large increases as teams start using these protections. If you're interested in looking at privacy and dependency violations over time as if all packages were enforcing dependencies and privacy the whole time, we recommend setting these values to be true before running modularization statistics in your CI.

```ruby
require 'modularization_statistics'
require 'pack_stats'

namespace(:modularization) do
desc(
Expand Down Expand Up @@ -93,7 +93,7 @@ namespace(:modularization) do
ParsePackwerk.write_package_yml!(new_package)
end

ModularizationStatistics.report_to_datadog!(
PackStats.report_to_datadog!(
datadog_client: Dogapi::Client.new(ENV.fetch('DATADOG_API_KEY')),
app_name: Rails.application.class.module_parent_name,
source_code_pathnames: source_code_pathnames,
Expand All @@ -105,7 +105,7 @@ end

# Using Other Observability Tools

Right now this tool sends metrics to DataDog early. However, if you want to use this with other tools, you can call `ModularizationStatistics.get_metrics(...)` to get generic metrics that you can then send to whatever observability provider you use.
Right now this tool sends metrics to DataDog early. However, if you want to use this with other tools, you can call `PackStats.get_metrics(...)` to get generic metrics that you can then send to whatever observability provider you use.

# Setting Up Your Dashboards

Expand Down
14 changes: 7 additions & 7 deletions lib/modularization_statistics.rb → lib/pack_stats.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
require 'code_teams'
require 'code_ownership'
require 'pathname'
require 'modularization_statistics/private'
require 'modularization_statistics/private/source_code_file'
require 'modularization_statistics/private/datadog_reporter'
require 'pack_stats/private'
require 'pack_stats/private/source_code_file'
require 'pack_stats/private/datadog_reporter'
require 'parse_packwerk'
require 'modularization_statistics/tag'
require 'modularization_statistics/tags'
require 'modularization_statistics/gauge_metric'
require 'pack_stats/tag'
require 'pack_stats/tags'
require 'pack_stats/gauge_metric'

module ModularizationStatistics
module PackStats
extend T::Sig

ROOT_PACKAGE_NAME = T.let('root'.freeze, String)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# typed: strict

module ModularizationStatistics
module PackStats
class GaugeMetric < T::Struct
extend T::Sig

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# typed: strict

module ModularizationStatistics
module PackStats
module Private
extend T::Sig

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
# frozen_string_literal: true

require 'dogapi'
require 'modularization_statistics/private/metrics'
require 'modularization_statistics/private/metrics/files'
require 'modularization_statistics/private/metrics/public_usage'
require 'modularization_statistics/private/metrics/packwerk_checker_usage'
require 'modularization_statistics/private/metrics/rubocop_usage'
require 'modularization_statistics/private/metrics/packages'
require 'modularization_statistics/private/metrics/packages_by_team'
require 'modularization_statistics/private/metrics/nested_packs'
require 'pack_stats/private/metrics'
require 'pack_stats/private/metrics/files'
require 'pack_stats/private/metrics/public_usage'
require 'pack_stats/private/metrics/packwerk_checker_usage'
require 'pack_stats/private/metrics/rubocop_usage'
require 'pack_stats/private/metrics/packages'
require 'pack_stats/private/metrics/packages_by_team'
require 'pack_stats/private/metrics/nested_packs'

module ModularizationStatistics
module PackStats
module Private
class DatadogReporter
extend T::Sig
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# typed: strict
# frozen_string_literal: true

module ModularizationStatistics
module PackStats
module Private
module Metrics
extend T::Sig
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# typed: strict
# frozen_string_literal: true

module ModularizationStatistics
module PackStats
module Private
module Metrics
class Files
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# typed: strict
# frozen_string_literal: true

module ModularizationStatistics
module PackStats
module Private
module Metrics
class NestedPacks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# typed: strict
# frozen_string_literal: true

module ModularizationStatistics
module PackStats
module Private
module Metrics
class Packages
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# typed: strict
# frozen_string_literal: true

module ModularizationStatistics
module PackStats
module Private
module Metrics
class PackagesByTeam
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

require 'rubocop-packs'

module ModularizationStatistics
module PackStats
module Private
module Metrics
class PackwerkCheckerUsage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# typed: strict
# frozen_string_literal: true

module ModularizationStatistics
module PackStats
module Private
module Metrics
class PublicUsage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# typed: strict
# frozen_string_literal: true

module ModularizationStatistics
module PackStats
module Private
module Metrics
class RubocopUsage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# typed: strict

module ModularizationStatistics
module PackStats
module Private
class SourceCodeFile < T::Struct
extend T::Sig
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# typed: strict

module ModularizationStatistics
module PackStats
class Tag < T::Struct
extend T::Sig
const :key, String
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# typed: strict

module ModularizationStatistics
module PackStats
module Tags
extend T::Sig

Expand Down
10 changes: 5 additions & 5 deletions modularization_statistics.gemspec → pack_stats.gemspec
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
Gem::Specification.new do |spec|
spec.name = 'modularization_statistics'
spec.version = '2.0.2'
spec.name = 'pack_stats'
spec.version = '0.0.1'
spec.authors = ['Gusto Engineers']
spec.email = ['dev@gusto.com']

spec.summary = 'A gem to collect statistics about modularization progress in a Rails application using packwerk.'
spec.description = 'A gem to collect statistics about modularization progress in a Rails application using packwerk.'
spec.homepage = 'https://github.com/rubyatscale/modularization_statistics'
spec.homepage = 'https://github.com/rubyatscale/pack_stats'
spec.license = 'MIT'

if spec.respond_to?(:metadata)
spec.metadata['homepage_uri'] = spec.homepage
spec.metadata['source_code_uri'] = 'https://github.com/rubyatscale/modularization_statistics'
spec.metadata['changelog_uri'] = 'https://github.com/rubyatscale/modularization_statistics/releases'
spec.metadata['source_code_uri'] = 'https://github.com/rubyatscale/pack_stats'
spec.metadata['changelog_uri'] = 'https://github.com/rubyatscale/pack_stats/releases'
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
else
raise 'RubyGems 2.0 or newer is required to protect against ' \
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/gauge_metric_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module ModularizationStatistics
module PackStats
RSpec.describe GaugeMetric do
it 'errors when metric length is greater than 200' do
expect { GaugeMetric.for('a' * 250, 0, []) }.to raise_error do |e|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
#
# This test exists to ensure that Gusto metrics continue to work as expected
#
module ModularizationStatistics # rubocop:disable RSpec/DescribedClassModuleWrapping
RSpec.describe ModularizationStatistics do
module PackStats # rubocop:disable RSpec/DescribedClassModuleWrapping
RSpec.describe PackStats do
before do
ParsePackwerk.bust_cache!
end

describe 'ModularizationStatistics.report_to_datadog!' do
describe 'PackStats.report_to_datadog!' do
let(:report_to_datadog) do
ModularizationStatistics.report_to_datadog!(
PackStats.report_to_datadog!(
app_name: 'MyApp',
source_code_pathnames: Pathname.glob('**/**.rb'),
datadog_client: datadog_client,
Expand All @@ -28,7 +28,7 @@ module ModularizationStatistics # rubocop:disable RSpec/DescribedClassModuleWrap
end

before do
allow(ModularizationStatistics).to receive(:get_metrics).and_return([expected_metric])
allow(PackStats).to receive(:get_metrics).and_return([expected_metric])
end

it 'emits to datadog' do
Expand All @@ -43,9 +43,9 @@ module ModularizationStatistics # rubocop:disable RSpec/DescribedClassModuleWrap
end
end

describe 'ModularizationStatistics.get_metrics' do
describe 'PackStats.get_metrics' do
let(:subject) do
ModularizationStatistics.get_metrics(
PackStats.get_metrics(
app_name: 'MyApp',
source_code_pathnames: Pathname.glob('**/**.rb'),
componentized_source_code_locations: [Pathname.new('components')],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# frozen_string_literal: true

module ModularizationStatistics # rubocop:disable RSpec/DescribedClassModuleWrapping
RSpec.describe ModularizationStatistics do
module PackStats # rubocop:disable RSpec/DescribedClassModuleWrapping
RSpec.describe PackStats do
before do
ParsePackwerk.bust_cache!
end

describe 'ModularizationStatistics.report_to_datadog!' do
describe 'PackStats.report_to_datadog!' do
let(:report_to_datadog) do
ModularizationStatistics.report_to_datadog!(
PackStats.report_to_datadog!(
app_name: 'MyApp',
source_code_pathnames: Pathname.glob('**/**.rb'),
datadog_client: datadog_client,
Expand All @@ -24,7 +24,7 @@ module ModularizationStatistics # rubocop:disable RSpec/DescribedClassModuleWrap
end

before do
allow(ModularizationStatistics).to receive(:get_metrics).and_return([expected_metric])
allow(PackStats).to receive(:get_metrics).and_return([expected_metric])
end

it 'emits to datadog' do
Expand All @@ -39,9 +39,9 @@ module ModularizationStatistics # rubocop:disable RSpec/DescribedClassModuleWrap
end
end

describe 'ModularizationStatistics.get_metrics' do
describe 'PackStats.get_metrics' do
let(:subject) do
ModularizationStatistics.get_metrics(
PackStats.get_metrics(
app_name: 'MyApp',
source_code_pathnames: Pathname.glob('**/**.rb'),
componentized_source_code_locations: [Pathname.new('components')],
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require 'bundler/setup'
require 'modularization_statistics'
require 'pack_stats'
require 'pry'

RSpec.configure do |config|
Expand Down

0 comments on commit c27d3f3

Please sign in to comment.