-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Switch to using Packwerk’s root package constant * Add method to list deprecated references for a package * Move deprecated reference loading out into service * Move specs across for DeprecatedReferencesLoader * Add logic to draw deprecated references * Update README with deprecated_references_color option
- Loading branch information
1 parent
290c763
commit 1a72433
Showing
10 changed files
with
160 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
Unreleased | ||
|
||
* Deprecated references are now drawn on the output graph. | ||
|
||
1.1.0 | ||
|
||
* Default layout switched to Dot | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# typed: strict | ||
# frozen_string_literal: true | ||
|
||
module Graphwerk | ||
class DeprecatedReferencesLoader | ||
extend T::Sig | ||
|
||
sig { params(package: Packwerk::Package, root_path: Pathname).void } | ||
def initialize(package, root_path) | ||
@package = package | ||
@root_path = root_path | ||
end | ||
|
||
sig { returns(T::Array[String]) } | ||
def load | ||
return [] if !deprecated_references_file.exist? | ||
|
||
(YAML.load_file(deprecated_references_file) || {}).keys | ||
end | ||
|
||
private | ||
|
||
DEPRECATED_REFERENCES_FILENAME = 'deprecated_references.yml' | ||
|
||
sig { returns(Pathname) } | ||
def deprecated_references_file | ||
@deprecated_references_file = T.let(@deprecated_references_file, T.nilable(Pathname)) | ||
@deprecated_references_file ||= @root_path.join(@package.name, DEPRECATED_REFERENCES_FILENAME) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# typed: false | ||
# frozen_string_literal: true | ||
|
||
module Graphwerk | ||
describe DeprecatedReferencesLoader do | ||
let(:service) { described_class.new(package, root_path) } | ||
|
||
let(:package) do | ||
Packwerk::Package.new( | ||
name: 'components/admin', | ||
config: { 'dependencies' => ['components/security', 'components/orders'] } | ||
) | ||
end | ||
let(:root_path) { Pathname.new('.') } | ||
|
||
describe '#load' do | ||
subject { service.load } | ||
|
||
let(:deprecated_references_file) { instance_double(Pathname) } | ||
|
||
before do | ||
expect(root_path) | ||
.to receive(:join) | ||
.with('components/admin', 'deprecated_references.yml') | ||
.and_return(deprecated_references_file) | ||
expect(deprecated_references_file) | ||
.to receive(:exist?) | ||
.and_return(deprecated_dependency_file_is_present) | ||
end | ||
|
||
context 'when no deprecated dependency file is present' do | ||
let(:deprecated_dependency_file_is_present) { false } | ||
|
||
it { is_expected.to be_empty } | ||
end | ||
|
||
context 'when a deprecated dependency file is present' do | ||
let(:deprecated_dependency_file_is_present) { true } | ||
|
||
before do | ||
expect(YAML) | ||
.to receive(:load_file) | ||
.with(deprecated_references_file) | ||
.and_return( | ||
'.' => { | ||
"::Order" => { | ||
"violations" => ["dependency"], | ||
"files" => ["components/admin/interfaces/gateway.rb"] | ||
} | ||
} | ||
) | ||
end | ||
|
||
it { is_expected.to contain_exactly('.') } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters