pocky 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec4633fc47cd55e4bb54ea0378567ebaa792ed20
4
- data.tar.gz: 0ff1ee4a69d65d586440ed2287958370ff2edc7f
3
+ metadata.gz: 608e94e135cd12c4340c3b9b1987a0c8af537784
4
+ data.tar.gz: b2a786abb2378189cfd332d9a751c019c7efe5bd
5
5
  SHA512:
6
- metadata.gz: 17398615fbe7d3b8ac88ac5fd3a36844b417f998d7aea02a6d8f361f5af8402dac03284e091d1a8e2a2776f48a89b1e5f1c8fbef7fefe51681034ebfa82e1331
7
- data.tar.gz: 94517f49a5813913ecc8d29dcdbf8f6e6a1847a741dcb622d4b7ae10c6d14565a8da62ff8b16072de3f6018be13a57c7794cd23ed8c5f920bfc1dd6b82d52604
6
+ metadata.gz: dacdbddb1d69b2920202123a43768b87329740b2a82758f84a44cdce37d613a4f102ca440754bffce504198cf40b6976bf5807046047286152b956952211c9ff
7
+ data.tar.gz: dfc30c35e7a3ba4223f76c55e4466ccf1172e3631affa7a9a0e67375194289d08f1416218541147265fde427078da3580becd1a52ec5f201eff0daa7184ce8ba
data/README.md CHANGED
@@ -23,8 +23,9 @@ Invoke as a rake task:
23
23
  ```ruby
24
24
  Pocky::Packwerk.generate(
25
25
  package_path: 'app/packages', # Relative path to packages directory
26
- default_package: 'app', # The default package listed as "." in package.yml and deprecated_references.yml
26
+ default_package: 'root', # The default package listed as "." in package.yml and deprecated_references.yml
27
27
  filename: 'packwerk.png', # Name of output file
28
+ analyze_sizes: false, # Calculate and display package according to the size of ruby source code
28
29
  dpi: 100, # Output file resolution
29
30
  package_color: '#5CC8FF', # color name or hex color, see https://graphviz.org/doc/info/colors.html for more details
30
31
  dependency_edge: 'darkgreen',
data/lib/pocky.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'pocky/version'
4
+ require_relative 'pocky/ruby_file_size'
4
5
  require_relative 'pocky/packwerk'
5
6
 
6
7
  module Pocky
@@ -8,19 +8,6 @@ module Pocky
8
8
  class InvalidRootPathError < StandardError
9
9
  end
10
10
 
11
- class RubyFileSize
12
- def self.compute(directory)
13
- # Sum up all ruby source except for specs
14
- package_size = Dir[File.join(directory, '**', '*.rb').to_s].reduce(0) do |size, filename|
15
- size += File.size(filename) unless filename.match(/spec\.rb$/)
16
- size
17
- end
18
-
19
- # to kB
20
- (package_size / 1024).ceil
21
- end
22
- end
23
-
24
11
  class Packwerk
25
12
  DEPENDENCIES_FILENAME = 'package.yml'
26
13
  DEPRECATED_REFERENCES_FILENAME = 'deprecated_references.yml'
@@ -35,6 +22,7 @@ module Pocky
35
22
  package_path: nil,
36
23
  default_package: 'root',
37
24
  filename: 'packwerk.png',
25
+ analyze_sizes: false,
38
26
  dpi: 100,
39
27
  package_color: '#5CC8FF',
40
28
  dependency_edge: 'darkgreen',
@@ -46,6 +34,8 @@ module Pocky
46
34
 
47
35
  @default_package = default_package
48
36
  @filename = filename
37
+ @analyze_sizes = analyze_sizes
38
+
49
39
  @dpi = dpi.to_i
50
40
  @deprecated_references = {}
51
41
  @package_dependencies = {}
@@ -96,7 +86,7 @@ module Pocky
96
86
  def draw_node(package)
97
87
  package_name = package_name_for_dependency(package)
98
88
  path = package == '.' ? @root_path : @root_path.join(package)
99
- file_size = RubyFileSize.compute(path.to_s)
89
+ file_size = @analyze_sizes ? RubyFileSize.compute(path.to_s) : 1
100
90
  @graph.add_nodes(package_name, **@node_options.merge(node_overrides(file_size)))
101
91
  end
102
92
 
@@ -0,0 +1,15 @@
1
+
2
+ module Pocky
3
+ class RubyFileSize
4
+ def self.compute(directory)
5
+ # Sum up all ruby source except for specs
6
+ package_size = Dir[File.join(directory, '**', '*.rb').to_s].reduce(0) do |size, filename|
7
+ size += File.size(filename) unless filename.match(/spec\.rb$/)
8
+ size
9
+ end
10
+
11
+ # to kB
12
+ (package_size / 1024).ceil
13
+ end
14
+ end
15
+ end
@@ -2,7 +2,7 @@ require 'pocky'
2
2
 
3
3
  namespace :pocky do
4
4
  desc 'Generate dependency graph for packwerk packages'
5
- task :generate, [:package_path, :default_package, :filename, :dpi, :package_color, :dependency_edge, :deprecated_reference_edge, :deprecated_reference_ranking] do |_task, args|
5
+ task :generate, [:package_path, :default_package, :filename, :analyze_sizes, :dpi, :package_color, :dependency_edge, :deprecated_reference_edge, :deprecated_reference_ranking] do |_task, args|
6
6
  params = args.to_h
7
7
  params.merge!(package_path: args[:package_path].split(/\s+/)) if args[:package_path]
8
8
  Pocky::Packwerk.generate(params)
data/lib/pocky/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pocky
4
- VERSION = "2.4.0"
4
+ VERSION = "2.5.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: 2.4.0
4
+ version: 2.5.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: 2021-02-01 00:00:00.000000000 Z
11
+ date: 2021-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-graphviz
@@ -44,6 +44,7 @@ files:
44
44
  - lib/pocky/Rakefile
45
45
  - lib/pocky/packwerk.rb
46
46
  - lib/pocky/railtie.rb
47
+ - lib/pocky/ruby_file_size.rb
47
48
  - lib/pocky/tasks/generate.rake
48
49
  - lib/pocky/version.rb
49
50
  - pocky.gemspec