graphwerk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/workflows/rspec.yml +23 -0
- data/.gitignore +22 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +14 -0
- data/LICENSE.txt +21 -0
- data/README.md +49 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +6 -0
- data/graphwerk.gemspec +36 -0
- data/lib/graphwerk.rb +21 -0
- data/lib/graphwerk/builders/graph.rb +112 -0
- data/lib/graphwerk/constants.rb +8 -0
- data/lib/graphwerk/layout.rb +15 -0
- data/lib/graphwerk/presenters/package.rb +56 -0
- data/lib/graphwerk/railtie.rb +10 -0
- data/lib/graphwerk/tasks/rails.rake +9 -0
- data/lib/graphwerk/version.rb +6 -0
- metadata +204 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA256:
         | 
| 3 | 
            +
              metadata.gz: 5d3fb33710355e47f3bbfaa7c9f78e01547cad92a379d0d449e9f9e4b9f2be5a
         | 
| 4 | 
            +
              data.tar.gz: 16c12353022a3b87bc1aae310fddbb176b0d4718ac7a85a33b17672d3ed1edab
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: ca38ee1799a0c4bb6fc08ed41836c6773d80c2ffbb86333baedbcd390ac390866a9d4bb416282a06dba7d8e3520ac33d5089c6aa6814159479995c74c4fb12b1
         | 
| 7 | 
            +
              data.tar.gz: ca18e12ca29229fd82aaa316bd24bf40053fac581e3c25be1a71649c58498ecab3b131087183d54aa125f7348e03916c2352d71712fd2d374073eb616628983e
         | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            name: RSpec Test Suite
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            on: [push]
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            jobs:
         | 
| 6 | 
            +
              build:
         | 
| 7 | 
            +
                runs-on: ubuntu-latest
         | 
| 8 | 
            +
                steps:
         | 
| 9 | 
            +
                - name: Checkout branch
         | 
| 10 | 
            +
                  uses: actions/checkout@v1
         | 
| 11 | 
            +
                - name: Set up Ruby
         | 
| 12 | 
            +
                  uses: actions/setup-ruby@v1
         | 
| 13 | 
            +
                  with:
         | 
| 14 | 
            +
                    ruby-version: 2.6.6
         | 
| 15 | 
            +
                - name: Install latest bundler
         | 
| 16 | 
            +
                  run: |
         | 
| 17 | 
            +
                    command -v bundler || gem install bundler
         | 
| 18 | 
            +
                - name: Install gems
         | 
| 19 | 
            +
                  run: bundle install --jobs $(nproc) --retry 3
         | 
| 20 | 
            +
                - name: Typecheck with Sorbet
         | 
| 21 | 
            +
                  run: bundle exec srb tc . --ignore=/vendor
         | 
| 22 | 
            +
                - name: Run RSpec test suite
         | 
| 23 | 
            +
                  run: bundle exec rspec spec
         | 
    
        data/.gitignore
    ADDED
    
    | @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            /Gemfile.lock
         | 
| 2 | 
            +
            /.bundle/
         | 
| 3 | 
            +
            /.yardoc
         | 
| 4 | 
            +
            /_yardoc/
         | 
| 5 | 
            +
            /coverage/
         | 
| 6 | 
            +
            /doc/
         | 
| 7 | 
            +
            /pkg/
         | 
| 8 | 
            +
            /spec/reports/
         | 
| 9 | 
            +
            /tmp/
         | 
| 10 | 
            +
            /vendor
         | 
| 11 | 
            +
            /node_modules
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            # rspec failure tracking
         | 
| 14 | 
            +
            .rspec_status
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            /shell.nix
         | 
| 17 | 
            +
            /tags
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            *.log
         | 
| 20 | 
            +
            .DS_Store
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            .ruby-gemset
         | 
    
        data/.rspec
    ADDED
    
    
    
        data/.ruby-version
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            2.6.6
         | 
    
        data/CHANGELOG.md
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    | @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            source 'https://rubygems.org'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # Specify your gem's dependencies in graphwerk.gemspec
         | 
| 4 | 
            +
            gemspec
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            group :development, :test do
         | 
| 7 | 
            +
              gem 'guard-livereload', require: false
         | 
| 8 | 
            +
              gem 'guard-rspec'
         | 
| 9 | 
            +
              gem 'pry-byebug'
         | 
| 10 | 
            +
              gem 'rb-fsevent', require: false
         | 
| 11 | 
            +
              gem 'rb-readline'
         | 
| 12 | 
            +
              gem 'rspec'
         | 
| 13 | 
            +
              gem 'shoulda-matchers', require: false
         | 
| 14 | 
            +
            end
         | 
    
        data/LICENSE.txt
    ADDED
    
    | @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            The MIT License (MIT)
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Copyright (c) 2020 Samuel Giles
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining a copy
         | 
| 6 | 
            +
            of this software and associated documentation files (the "Software"), to deal
         | 
| 7 | 
            +
            in the Software without restriction, including without limitation the rights
         | 
| 8 | 
            +
            to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         | 
| 9 | 
            +
            copies of the Software, and to permit persons to whom the Software is
         | 
| 10 | 
            +
            furnished to do so, subject to the following conditions:
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            The above copyright notice and this permission notice shall be included in
         | 
| 13 | 
            +
            all copies or substantial portions of the Software.
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         | 
| 16 | 
            +
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         | 
| 17 | 
            +
            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         | 
| 18 | 
            +
            AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         | 
| 19 | 
            +
            LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         | 
| 20 | 
            +
            OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
         | 
| 21 | 
            +
            THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,49 @@ | |
| 1 | 
            +
            
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # Graphwerk [](https://badge.fury.io/rb/graphwerk) 
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Graphwerk is a small Ruby gem that can generate a diagram of dependencies between packages within an application that's using Packwerk to enforce boundaries.
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            The gem builds on top of [Packwerk](https://github.com/Shopify/packwerk) and [Graphviz](https://github.com/glejeune/Ruby-Graphviz).
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            Here's an example application package dependency diagram:
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            ## Install
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            Add this line to your application's Gemfile and run `bundle install`:
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            `gem 'graphwerk'`
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            ## Usage
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            For Rails applications a Railtie automatically loads a rake task that makes it easy to generate a diagram for your root package and its dependencies. The diagram will be placed at the root of your application as `packwerk.png`.
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            ```bash
         | 
| 24 | 
            +
            bundle exec rake graphwerk:update
         | 
| 25 | 
            +
            ```
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            More advance usage is possible by passing a `Packwerk::PackageSet` directly to `Graphwerk::Builders::Graph` and calling `#build` returning a `Graphviz` instance:
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            ```ruby
         | 
| 30 | 
            +
            graph = Graphwerk::Builders::Graph.new(
         | 
| 31 | 
            +
               Packwerk::PackageSet.load_all_from(".")
         | 
| 32 | 
            +
            ).build
         | 
| 33 | 
            +
            graph.output(svg: 'packwerk.svg')
         | 
| 34 | 
            +
            ```
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            All Graphviz layouts are supported and options for the graph, nodes and edges can be set via an optional `options` argument:
         | 
| 37 | 
            +
             | 
| 38 | 
            +
            ```ruby
         | 
| 39 | 
            +
            graph = Graphwerk::Builders::Graph.new(
         | 
| 40 | 
            +
               Packwerk::PackageSet.load_all_from("."),
         | 
| 41 | 
            +
               options: {
         | 
| 42 | 
            +
                 layout: Graphwerk::Layout::Twopi,
         | 
| 43 | 
            +
                 graph: { overlap: true },
         | 
| 44 | 
            +
                 node: { fillcolor: '#000000' },
         | 
| 45 | 
            +
                 edges: { len: '3.0' }
         | 
| 46 | 
            +
                }
         | 
| 47 | 
            +
            ).build
         | 
| 48 | 
            +
            graph.output(svg: 'packwerk.svg')
         | 
| 49 | 
            +
            ```
         | 
    
        data/Rakefile
    ADDED
    
    
    
        data/bin/console
    ADDED
    
    | @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'bundler/setup'
         | 
| 4 | 
            +
            require 'graphwerk'
         | 
| 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__)
         | 
    
        data/bin/setup
    ADDED
    
    
    
        data/graphwerk.gemspec
    ADDED
    
    | @@ -0,0 +1,36 @@ | |
| 1 | 
            +
            lib = File.expand_path('lib', __dir__)
         | 
| 2 | 
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            require 'graphwerk/version'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |spec|
         | 
| 7 | 
            +
              spec.name          = 'graphwerk'
         | 
| 8 | 
            +
              spec.version       = Graphwerk::VERSION
         | 
| 9 | 
            +
              spec.authors       = ['Samuel Giles']
         | 
| 10 | 
            +
              spec.email         = ['samuel.giles@bellroy.com']
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              spec.summary       = "Visualise dependencies between your application and it's Packwerk packages using Graphviz."
         | 
| 13 | 
            +
              spec.homepage      = 'https://github.com/tricycle/graphwerk'
         | 
| 14 | 
            +
              spec.license       = 'MIT'
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              # Specify which files should be added to the gem when it is released.
         | 
| 17 | 
            +
              # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
         | 
| 18 | 
            +
              spec.files = `git ls-files -z`.split("\x0").reject do |f|
         | 
| 19 | 
            +
                f.match(%r{^(spec|sorbet)/}) && !f.match(%r{^spec/support/factories/})
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
              spec.bindir        = 'exe'
         | 
| 22 | 
            +
              spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
         | 
| 23 | 
            +
              spec.require_paths = ['lib']
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              spec.add_dependency 'activesupport'
         | 
| 26 | 
            +
              spec.add_dependency 'packwerk'
         | 
| 27 | 
            +
              spec.add_dependency 'ruby-graphviz'
         | 
| 28 | 
            +
              spec.add_dependency 'sorbet-runtime'
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              spec.add_development_dependency 'bundler'
         | 
| 31 | 
            +
              spec.add_development_dependency 'pry'
         | 
| 32 | 
            +
              spec.add_development_dependency 'rake', '>= 12.3.3'
         | 
| 33 | 
            +
              spec.add_development_dependency 'rspec', '~> 3.0'
         | 
| 34 | 
            +
              spec.add_development_dependency 'sorbet'
         | 
| 35 | 
            +
              spec.add_development_dependency 'rspec-sorbet'
         | 
| 36 | 
            +
            end
         | 
    
        data/lib/graphwerk.rb
    ADDED
    
    | @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            # typed: true
         | 
| 2 | 
            +
            # frozen_string_literal: true
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            require 'sorbet-runtime'
         | 
| 5 | 
            +
            require 'packwerk'
         | 
| 6 | 
            +
            require 'ruby-graphviz'
         | 
| 7 | 
            +
            require 'active_support/core_ext/hash/deep_merge'
         | 
| 8 | 
            +
            require 'graphwerk/version'
         | 
| 9 | 
            +
            require 'graphwerk/constants'
         | 
| 10 | 
            +
            require 'graphwerk/layout'
         | 
| 11 | 
            +
            require 'graphwerk/presenters/package'
         | 
| 12 | 
            +
            require 'graphwerk/builders/graph'
         | 
| 13 | 
            +
            require 'graphwerk/railtie' if defined?(Rails)
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            module Graphwerk
         | 
| 16 | 
            +
              def self.for_application(**args)
         | 
| 17 | 
            +
                Graphwerk::Builders::Graph.new(
         | 
| 18 | 
            +
                  Packwerk::PackageSet.load_all_from(".")
         | 
| 19 | 
            +
                ).build.output(args)
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
            end
         | 
| @@ -0,0 +1,112 @@ | |
| 1 | 
            +
            # typed: strict
         | 
| 2 | 
            +
            # frozen_string_literal: true
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module Graphwerk
         | 
| 5 | 
            +
              module Builders
         | 
| 6 | 
            +
                class Graph
         | 
| 7 | 
            +
                  extend T::Sig
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                  OptionsShape = T.type_alias {
         | 
| 10 | 
            +
                    {
         | 
| 11 | 
            +
                      layout: Graphwerk::Layout,
         | 
| 12 | 
            +
                      application: T::Hash[Symbol, Object],
         | 
| 13 | 
            +
                      graph: T::Hash[Symbol, Object],
         | 
| 14 | 
            +
                      node: T::Hash[Symbol, Object],
         | 
| 15 | 
            +
                      edge: T::Hash[Symbol, Object]
         | 
| 16 | 
            +
                    }
         | 
| 17 | 
            +
                  }
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                  DEFAULT_OPTIONS = T.let({
         | 
| 20 | 
            +
                    layout: Graphwerk::Layout::Fdp,
         | 
| 21 | 
            +
                    application: {
         | 
| 22 | 
            +
                      style: 'filled',
         | 
| 23 | 
            +
                      fillcolor: '#333333',
         | 
| 24 | 
            +
                      fontcolor: 'white'
         | 
| 25 | 
            +
                    },
         | 
| 26 | 
            +
                    graph: {
         | 
| 27 | 
            +
                      root: Constants::ROOT_PACKAGE_NAME,
         | 
| 28 | 
            +
                      overlap: false,
         | 
| 29 | 
            +
                      splines: true
         | 
| 30 | 
            +
                    },
         | 
| 31 | 
            +
                    node: {
         | 
| 32 | 
            +
                      shape: 'box',
         | 
| 33 | 
            +
                      style: 'rounded, filled',
         | 
| 34 | 
            +
                      fontcolor: 'white',
         | 
| 35 | 
            +
                      fillcolor: '#EF673E',
         | 
| 36 | 
            +
                      color: '#EF673E',
         | 
| 37 | 
            +
                      fontname: 'Lato'
         | 
| 38 | 
            +
                    },
         | 
| 39 | 
            +
                    edge: {
         | 
| 40 | 
            +
                      len: '0.4'
         | 
| 41 | 
            +
                    }
         | 
| 42 | 
            +
                  }, OptionsShape)
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                  sig { params(package_set: Packwerk::PackageSet, options: T::Hash[Symbol, Object]).void }
         | 
| 45 | 
            +
                  def initialize(package_set, options: {})
         | 
| 46 | 
            +
                    @package_set = package_set
         | 
| 47 | 
            +
                    @options = T.let(DEFAULT_OPTIONS.deep_merge(options), OptionsShape)
         | 
| 48 | 
            +
                    @graph = T.let(build_empty_graph, GraphViz)
         | 
| 49 | 
            +
                    @nodes = T.let(build_empty_nodes, T::Hash[String, GraphViz::Node])
         | 
| 50 | 
            +
                  end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                  sig { returns(GraphViz) }
         | 
| 53 | 
            +
                  def build
         | 
| 54 | 
            +
                    setup_graph
         | 
| 55 | 
            +
                    add_packages_to_graph
         | 
| 56 | 
            +
                    add_package_dependencies_to_graph
         | 
| 57 | 
            +
                    @graph
         | 
| 58 | 
            +
                  end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                  private
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                  sig { returns(GraphViz) }
         | 
| 63 | 
            +
                  def build_empty_graph
         | 
| 64 | 
            +
                    GraphViz.new(:strict, type: :digraph, use: @options[:layout].serialize)
         | 
| 65 | 
            +
                  end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                  sig { returns(T::Hash[String, GraphViz::Node]) }
         | 
| 68 | 
            +
                  def build_empty_nodes
         | 
| 69 | 
            +
                    {
         | 
| 70 | 
            +
                      application: @graph.add_nodes(
         | 
| 71 | 
            +
                        Constants::ROOT_PACKAGE_NAME,
         | 
| 72 | 
            +
                        **@options[:application]
         | 
| 73 | 
            +
                      )
         | 
| 74 | 
            +
                    }
         | 
| 75 | 
            +
                  end
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                  sig { void }
         | 
| 78 | 
            +
                  def setup_graph
         | 
| 79 | 
            +
                    @graph = build_empty_graph
         | 
| 80 | 
            +
                    @nodes = build_empty_nodes
         | 
| 81 | 
            +
                    @options[:graph].each_pair { |k,v| @graph.graph[k] =v }
         | 
| 82 | 
            +
                    @options[:node].each_pair { |k,v| @graph.node[k] =v }
         | 
| 83 | 
            +
                    @options[:edge].each_pair { |k,v| @graph.edge[k] =v }
         | 
| 84 | 
            +
                  end
         | 
| 85 | 
            +
             | 
| 86 | 
            +
                  sig { void }
         | 
| 87 | 
            +
                  def add_package_dependencies_to_graph
         | 
| 88 | 
            +
                    packages.each { |package| draw_dependencies(package) }
         | 
| 89 | 
            +
                  end
         | 
| 90 | 
            +
             | 
| 91 | 
            +
                  sig { void }
         | 
| 92 | 
            +
                  def add_packages_to_graph
         | 
| 93 | 
            +
                    packages.each do |package|
         | 
| 94 | 
            +
                      @nodes[package.name] = @graph.add_nodes(package.name, color: package.color)
         | 
| 95 | 
            +
                    end
         | 
| 96 | 
            +
                  end
         | 
| 97 | 
            +
             | 
| 98 | 
            +
                  sig { params(package: Presenters::Package).void }
         | 
| 99 | 
            +
                  def draw_dependencies(package)
         | 
| 100 | 
            +
                    package.dependencies.each do |dependency|
         | 
| 101 | 
            +
                      @graph.add_edges(@nodes[package.name], @nodes[dependency], color: package.color)
         | 
| 102 | 
            +
                    end
         | 
| 103 | 
            +
                  end
         | 
| 104 | 
            +
             | 
| 105 | 
            +
                  sig { returns(T::Array[Presenters::Package]) }
         | 
| 106 | 
            +
                  def packages
         | 
| 107 | 
            +
                    @packages = T.let(@packages, T.nilable(T::Array[Presenters::Package]))
         | 
| 108 | 
            +
                    @packages ||= @package_set.map { |package| Presenters::Package.new(package) }
         | 
| 109 | 
            +
                  end
         | 
| 110 | 
            +
                end
         | 
| 111 | 
            +
              end
         | 
| 112 | 
            +
            end
         | 
| @@ -0,0 +1,56 @@ | |
| 1 | 
            +
            # typed: strict
         | 
| 2 | 
            +
            # frozen_string_literal: true
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module Graphwerk
         | 
| 5 | 
            +
              module Presenters
         | 
| 6 | 
            +
                class Package
         | 
| 7 | 
            +
                  extend T::Sig
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                  sig { params(package: Packwerk::Package).void }
         | 
| 10 | 
            +
                  def initialize(package)
         | 
| 11 | 
            +
                    @package = package
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  WITHOUT_ROOT_FOLDER = T.let(
         | 
| 15 | 
            +
                    ->(package_name) { package_name.split('/', 2).last },
         | 
| 16 | 
            +
                    T.proc.params(package_name: String).returns(String)
         | 
| 17 | 
            +
                  )
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                  sig { returns(String) }
         | 
| 20 | 
            +
                  def name
         | 
| 21 | 
            +
                    return WITHOUT_ROOT_FOLDER.call(@package.name) unless root?
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                    Constants::ROOT_PACKAGE_NAME
         | 
| 24 | 
            +
                  end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                  sig { returns(T::Array[String]) }
         | 
| 27 | 
            +
                  def dependencies
         | 
| 28 | 
            +
                    @package.dependencies.map { |dependency| WITHOUT_ROOT_FOLDER.call(dependency) }
         | 
| 29 | 
            +
                  end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                  ROOT_COLOR = 'black'
         | 
| 32 | 
            +
                  COMPONENT_COLOR = 'azure4'
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                  sig { returns(String) }
         | 
| 35 | 
            +
                  def color
         | 
| 36 | 
            +
                    return ROOT_COLOR if root?
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                    COMPONENT_COLOR
         | 
| 39 | 
            +
                  end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                  private
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                  ROOT_PACKAGE = '.'
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                  sig { returns(T::Boolean) }
         | 
| 46 | 
            +
                  def root?
         | 
| 47 | 
            +
                    @package.name == ROOT_PACKAGE
         | 
| 48 | 
            +
                  end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                  private_constant :ROOT_PACKAGE,
         | 
| 51 | 
            +
                                   :ROOT_COLOR,
         | 
| 52 | 
            +
                                   :COMPONENT_COLOR,
         | 
| 53 | 
            +
                                   :WITHOUT_ROOT_FOLDER
         | 
| 54 | 
            +
                end
         | 
| 55 | 
            +
              end
         | 
| 56 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,204 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: graphwerk
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 1.0.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Samuel Giles
         | 
| 8 | 
            +
            autorequire:
         | 
| 9 | 
            +
            bindir: exe
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2020-10-08 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: activesupport
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - ">="
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '0'
         | 
| 20 | 
            +
              type: :runtime
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - ">="
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '0'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: packwerk
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - ">="
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '0'
         | 
| 34 | 
            +
              type: :runtime
         | 
| 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: ruby-graphviz
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - ">="
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: '0'
         | 
| 48 | 
            +
              type: :runtime
         | 
| 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: sorbet-runtime
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - ">="
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '0'
         | 
| 62 | 
            +
              type: :runtime
         | 
| 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: bundler
         | 
| 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: pry
         | 
| 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: rake
         | 
| 99 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 100 | 
            +
                requirements:
         | 
| 101 | 
            +
                - - ">="
         | 
| 102 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 103 | 
            +
                    version: 12.3.3
         | 
| 104 | 
            +
              type: :development
         | 
| 105 | 
            +
              prerelease: false
         | 
| 106 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 107 | 
            +
                requirements:
         | 
| 108 | 
            +
                - - ">="
         | 
| 109 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 110 | 
            +
                    version: 12.3.3
         | 
| 111 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 112 | 
            +
              name: rspec
         | 
| 113 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 114 | 
            +
                requirements:
         | 
| 115 | 
            +
                - - "~>"
         | 
| 116 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 117 | 
            +
                    version: '3.0'
         | 
| 118 | 
            +
              type: :development
         | 
| 119 | 
            +
              prerelease: false
         | 
| 120 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 121 | 
            +
                requirements:
         | 
| 122 | 
            +
                - - "~>"
         | 
| 123 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 124 | 
            +
                    version: '3.0'
         | 
| 125 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 126 | 
            +
              name: sorbet
         | 
| 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: rspec-sorbet
         | 
| 141 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 142 | 
            +
                requirements:
         | 
| 143 | 
            +
                - - ">="
         | 
| 144 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 145 | 
            +
                    version: '0'
         | 
| 146 | 
            +
              type: :development
         | 
| 147 | 
            +
              prerelease: false
         | 
| 148 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 149 | 
            +
                requirements:
         | 
| 150 | 
            +
                - - ">="
         | 
| 151 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 152 | 
            +
                    version: '0'
         | 
| 153 | 
            +
            description:
         | 
| 154 | 
            +
            email:
         | 
| 155 | 
            +
            - samuel.giles@bellroy.com
         | 
| 156 | 
            +
            executables: []
         | 
| 157 | 
            +
            extensions: []
         | 
| 158 | 
            +
            extra_rdoc_files: []
         | 
| 159 | 
            +
            files:
         | 
| 160 | 
            +
            - ".github/workflows/rspec.yml"
         | 
| 161 | 
            +
            - ".gitignore"
         | 
| 162 | 
            +
            - ".rspec"
         | 
| 163 | 
            +
            - ".ruby-version"
         | 
| 164 | 
            +
            - CHANGELOG.md
         | 
| 165 | 
            +
            - Gemfile
         | 
| 166 | 
            +
            - LICENSE.txt
         | 
| 167 | 
            +
            - README.md
         | 
| 168 | 
            +
            - Rakefile
         | 
| 169 | 
            +
            - bin/console
         | 
| 170 | 
            +
            - bin/setup
         | 
| 171 | 
            +
            - graphwerk.gemspec
         | 
| 172 | 
            +
            - lib/graphwerk.rb
         | 
| 173 | 
            +
            - lib/graphwerk/builders/graph.rb
         | 
| 174 | 
            +
            - lib/graphwerk/constants.rb
         | 
| 175 | 
            +
            - lib/graphwerk/layout.rb
         | 
| 176 | 
            +
            - lib/graphwerk/presenters/package.rb
         | 
| 177 | 
            +
            - lib/graphwerk/railtie.rb
         | 
| 178 | 
            +
            - lib/graphwerk/tasks/rails.rake
         | 
| 179 | 
            +
            - lib/graphwerk/version.rb
         | 
| 180 | 
            +
            homepage: https://github.com/tricycle/graphwerk
         | 
| 181 | 
            +
            licenses:
         | 
| 182 | 
            +
            - MIT
         | 
| 183 | 
            +
            metadata: {}
         | 
| 184 | 
            +
            post_install_message:
         | 
| 185 | 
            +
            rdoc_options: []
         | 
| 186 | 
            +
            require_paths:
         | 
| 187 | 
            +
            - lib
         | 
| 188 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 189 | 
            +
              requirements:
         | 
| 190 | 
            +
              - - ">="
         | 
| 191 | 
            +
                - !ruby/object:Gem::Version
         | 
| 192 | 
            +
                  version: '0'
         | 
| 193 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 194 | 
            +
              requirements:
         | 
| 195 | 
            +
              - - ">="
         | 
| 196 | 
            +
                - !ruby/object:Gem::Version
         | 
| 197 | 
            +
                  version: '0'
         | 
| 198 | 
            +
            requirements: []
         | 
| 199 | 
            +
            rubygems_version: 3.0.3
         | 
| 200 | 
            +
            signing_key:
         | 
| 201 | 
            +
            specification_version: 4
         | 
| 202 | 
            +
            summary: Visualise dependencies between your application and it's Packwerk packages
         | 
| 203 | 
            +
              using Graphviz.
         | 
| 204 | 
            +
            test_files: []
         |