pocky 1.1.0 → 1.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de85a86834e761f86f7bedb1752ff4f535386a8820b20f1e0efddaf82e9293f5
4
- data.tar.gz: ab7fdbefec3d36ead1139ded153db6980f77590a93678d791c0ee4a0e84ae1e6
3
+ metadata.gz: 85bd82c4180bd9152f53dcf8dcfa2e0cdb54f93211f926823c62572b9c98c7bf
4
+ data.tar.gz: 759e6fe70c7981b6342957da759754833c275d086bf4c2b7caab6e4406cf6bf5
5
5
  SHA512:
6
- metadata.gz: b789643c86e4953f8eca4edb1040c89200aa3441304ae4509e081678a4f85b7924f4027155f575b39cd1cd4d43c16c40b556e8c2160f07dbb8bc7f4aa226388b
7
- data.tar.gz: 02dc8b3e3ae974b5917f6081300196d95aedbc8d0ba27eff7a7f0f550c3fc518f1b8f6edc8e82de3fa9825ad48fdea3e42fafc4e1b2e10a108943da5896d5ca8
6
+ metadata.gz: d7db906a22cfd1c05fca50101bc0f5c896c6d3ade27cb998a7ab0e6218094a420577a0bd59a67bc41c851007bd73590735b4251e6ed60cff79ef41532572e8c8
7
+ data.tar.gz: 2a8078b50d6d0f0fd46ae1269b18f2602d5f69487ac431400d122b4bcddf4415457cd2b695483eda803c3117f80a4b52d5c2c78221406fdbc156bae6b1530dcd
data/README.md CHANGED
@@ -1,20 +1,31 @@
1
1
  # Pocky
2
2
 
3
- Pocky is used to generate dependency graphs for your packwerk packages. The gem is named after pocky, a beloved Japanese snack that comes in small packages.
3
+ Pocky generates dependency graphs for your packwerk packages. The gem is named after pocky, a beloved Japanese snack that comes in small packages.
4
4
 
5
5
  ![Pocky](https://user-images.githubusercontent.com/138784/103248942-c141de80-4921-11eb-99bd-3744816abc37.png)
6
6
 
7
7
  ## Usage
8
8
 
9
+ Invoke from irb or code
9
10
  ```ruby
10
- Pocky::Graph.generate(
11
+ Pocky::Packwerk.generate(
11
12
  root_path: 'path/to/app/packages',
12
- default_package: 'The Monolith', # The default package listed as "." in deprecated_references.yml
13
- package_prefix: 'app/packages', # this is for matching package names listed in deprecated_references.yml
14
- output_filename: 'pocky-graph.png'
13
+ default_package: 'Default', # The default package listed as "." in deprecated_references.yml
14
+ package_prefix: 'app/packages', # this is for matching package names listed in deprecated_references.yml
15
+ filename: 'packwerk-viz.png', # Name of output file
16
+ dpi: 150 # Output file resolution
15
17
  )
16
18
  ```
17
19
 
20
+ ![pocky-graph](https://user-images.githubusercontent.com/138784/103251690-a6299b80-492e-11eb-92f1-205752d850d8.png)
21
+
22
+ Note that the the bold edges indicate heavier dependencies.
23
+
24
+ Invoke as a rake task
25
+
26
+ ```
27
+ rake pocky:generate[path/to/app/packages,Default,app/packages,packwerk-viz.png,150]
28
+ ```
18
29
 
19
30
  ## Installation
20
31
 
data/Rakefile CHANGED
@@ -3,6 +3,6 @@
3
3
  require "bundler/gem_tasks"
4
4
  require "rspec/core/rake_task"
5
5
 
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- task default: :spec
6
+ spec = Gem::Specification.find_by_name 'pocky'
7
+ rakefile = "#{spec.gem_dir}/lib/pocky/Rakefile"
8
+ load rakefile
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'pocky/version'
4
- require_relative 'pocky/graph'
4
+ require_relative 'pocky/packwerk'
5
5
 
6
6
  module Pocky
7
+ require 'pocky/railtie' if defined?(Rails)
7
8
  end
@@ -0,0 +1,4 @@
1
+ require 'pocky'
2
+
3
+ path = File.expand_path(__dir__)
4
+ Dir.glob("#{path}/tasks/**/*.rake").each { |f| import f }
@@ -4,7 +4,9 @@ require 'yaml'
4
4
  require 'ruby-graphviz'
5
5
 
6
6
  module Pocky
7
- class Graph
7
+ class Packwerk
8
+ MAX_EDGE_WIDTH = 5
9
+
8
10
  def self.generate(params)
9
11
  new(**params).generate
10
12
  end
@@ -14,13 +16,14 @@ module Pocky
14
16
  root_path:,
15
17
  default_package: 'Default',
16
18
  package_prefix: '',
17
- output_filename: 'pocky-graph.png'
19
+ filename: 'packwerk-viz.png',
20
+ dpi: 150
18
21
  )
19
22
  @root_path = root_path
20
23
  @default_package = default_package
21
24
  @package_prefix = package_prefix
22
- @output_filename = output_filename
23
-
25
+ @filename = filename
26
+ @dpi = dpi.to_i
24
27
  @deprecated_references = {}
25
28
  @nodes = {}
26
29
  end
@@ -33,7 +36,7 @@ module Pocky
33
36
  private
34
37
 
35
38
  def build_directed_graph
36
- graph = GraphViz.new(:G, type: :digraph, dpi: 300)
39
+ graph = GraphViz.new(:G, type: :digraph, dpi: @dpi)
37
40
  @deprecated_references.each do |package, references|
38
41
  @nodes[package] ||= graph.add_nodes(package)
39
42
  references.each do |provider, dependencies|
@@ -41,24 +44,24 @@ module Pocky
41
44
  @nodes[provider_package] ||= graph.add_nodes(provider_package)
42
45
 
43
46
  graph.add_edges(
44
- @nodes[package],
45
47
  @nodes[provider_package],
48
+ @nodes[package],
46
49
  penwidth: edge_width(dependencies.length)
47
50
  )
48
51
  end
49
52
  end
50
53
 
51
- graph.output(png: @output_filename)
54
+ graph.output(png: @filename)
52
55
  end
53
56
 
54
57
  def edge_width(count)
55
58
  [
56
59
  [(count / 5).to_i, 1].max,
57
- 5
60
+ MAX_EDGE_WIDTH
58
61
  ].min
59
62
  end
60
63
 
61
- def load_dependencies
64
+ def load_package_dependencies
62
65
  Dir.each_child(@root_path) do |elem|
63
66
  if Dir.exist?(File.join(@root_path, elem))
64
67
  load_deprecated_references_for_package(elem)
@@ -0,0 +1,13 @@
1
+ require 'pocky'
2
+ require 'rails'
3
+
4
+ module Pocky
5
+ class Railtie < Rails::Railtie
6
+ railtie_name :pocky
7
+
8
+ rake_tasks do
9
+ path = File.expand_path(__dir__)
10
+ Dir.glob("#{path}/tasks/**/*.rake").each { |f| load f }
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ require 'pocky'
2
+
3
+ namespace :pocky do
4
+ desc 'Generate dependency graph for packwerk packages'
5
+ task :generate, [:root_path, :default_package, :package_prefix, :filename, :dpi] do |_task, args|
6
+ Pocky::Packwerk.generate(args)
7
+ end
8
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pocky
4
- VERSION = "1.1.0"
4
+ VERSION = "1.6.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pocky
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Quan Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-28 00:00:00.000000000 Z
11
+ date: 2020-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-graphviz
@@ -41,7 +41,10 @@ files:
41
41
  - bin/console
42
42
  - bin/setup
43
43
  - lib/pocky.rb
44
- - lib/pocky/graph.rb
44
+ - lib/pocky/Rakefile
45
+ - lib/pocky/packwerk.rb
46
+ - lib/pocky/railtie.rb
47
+ - lib/pocky/tasks/generate.rake
45
48
  - lib/pocky/version.rb
46
49
  - pocky.gemspec
47
50
  homepage: https://github.com/mquan/pocky