js_dependency 0.3.2 → 0.3.3
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 +4 -4
- data/.rubocop_todo.yml +2 -2
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/js_dependency/index_creator.rb +4 -1
- data/lib/js_dependency/mermaid/nodes_link.rb +3 -1
- data/lib/js_dependency/mermaid/root.rb +1 -1
- data/lib/js_dependency/pathname_utility.rb +6 -0
- data/lib/js_dependency/target_pathname.rb +23 -5
- data/lib/js_dependency/version.rb +1 -1
- data/lib/js_dependency.rb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d117ec8b831e67223b243ed652261885f1bbffc4734f93ed2d386166d16d31e2
|
4
|
+
data.tar.gz: '008fe6a337a677fa62348ca4d76766f02d72affc2b851126f7f22cba45c32c4f'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 891fdc5a595134a7724a4f9bdf061ac6290025e3e624d1f33d362ba74ef22d696a1dd3355f6befdd8a11661a07b531eef7877ff9271b4f4bb1ca01dd83f3c31e
|
7
|
+
data.tar.gz: 574b0b04401c6b3d4b7a510cb0dbbe972a0539d8e052bed48395cc4c7c1f3ec656bf314f57229e6ac79a2524fbacadf89825d8b30fc410e8e6acb3efd50b438e
|
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2022-07-
|
3
|
+
# on 2022-07-26 00:36:01 UTC using RuboCop version 1.31.2.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -36,7 +36,7 @@ Style/MultilineBlockChain:
|
|
36
36
|
Exclude:
|
37
37
|
- 'lib/js_dependency/mermaid/root.rb'
|
38
38
|
|
39
|
-
# Offense count:
|
39
|
+
# Offense count: 6
|
40
40
|
# This cop supports safe autocorrection (--autocorrect).
|
41
41
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
|
42
42
|
# URISchemes: http, https
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -47,7 +47,10 @@ module JsDependency
|
|
47
47
|
import_pathnames = import_pathnames_from(component_pathname, alias_paths)
|
48
48
|
|
49
49
|
obj[component_pathname.to_s] = import_pathnames.map(&:to_s)
|
50
|
-
|
50
|
+
if component_pathname.basename.to_s == "index.js"
|
51
|
+
obj[component_pathname.dirname.to_s] =
|
52
|
+
import_pathnames.map(&:to_s)
|
53
|
+
end
|
51
54
|
end
|
52
55
|
end
|
53
56
|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative "../pathname_utility"
|
4
|
+
|
3
5
|
module JsDependency
|
4
6
|
module Mermaid
|
5
7
|
class NodesLink
|
@@ -35,7 +37,7 @@ module JsDependency
|
|
35
37
|
# @param [Pathname] pathname
|
36
38
|
# @param [Integer] level
|
37
39
|
def parse(pathname, level = -1)
|
38
|
-
|
40
|
+
JsDependency::PathnameUtility.parse(pathname, level)
|
39
41
|
end
|
40
42
|
end
|
41
43
|
end
|
@@ -32,7 +32,7 @@ module JsDependency
|
|
32
32
|
|
33
33
|
# @param [Integer] name_level
|
34
34
|
# @param [nil, String] src_path
|
35
|
-
# @return [Array]
|
35
|
+
# @return [Array<String>]
|
36
36
|
def export_nodes(name_level: 1, src_path: nil)
|
37
37
|
nodes_links = if src_path
|
38
38
|
src_pathname = Pathname.new(src_path).realpath
|
@@ -25,5 +25,11 @@ module JsDependency
|
|
25
25
|
Pathname.new(target_path)
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
# @param [Pathname] pathname
|
30
|
+
# @param [Integer] level
|
31
|
+
def self.parse(pathname, level = -1)
|
32
|
+
pathname.each_filename.with_object([]) { |filename, array| array << filename }.reverse[0..level].reverse
|
33
|
+
end
|
28
34
|
end
|
29
35
|
end
|
@@ -1,7 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative "pathname_utility"
|
3
4
|
module JsDependency
|
4
5
|
class TargetPathname
|
6
|
+
attr_accessor :color_css, :font_size_css
|
7
|
+
|
5
8
|
# @param [String] target_path
|
6
9
|
def initialize(target_path)
|
7
10
|
@pathname = if Pathname.new(target_path).relative? && Pathname.new(target_path).exist?
|
@@ -9,6 +12,8 @@ module JsDependency
|
|
9
12
|
else
|
10
13
|
Pathname.new(target_path)
|
11
14
|
end
|
15
|
+
@color_css = "#f9f"
|
16
|
+
@font_size_css = "4px"
|
12
17
|
end
|
13
18
|
|
14
19
|
# @param [Integer] analyze_level
|
@@ -45,8 +50,19 @@ module JsDependency
|
|
45
50
|
end
|
46
51
|
end
|
47
52
|
|
53
|
+
def mermaid_style(src_path)
|
54
|
+
src_pathname = Pathname.new(src_path).realpath
|
55
|
+
export_style(parse(@pathname.exist? ? @pathname.relative_path_from(src_pathname) : @pathname).join("_"))
|
56
|
+
end
|
57
|
+
|
48
58
|
private
|
49
59
|
|
60
|
+
# @param [String] path
|
61
|
+
# @return [String]
|
62
|
+
def export_style(path)
|
63
|
+
"style #{path} stroke:#{@color_css},stroke-width:#{@font_size_css}"
|
64
|
+
end
|
65
|
+
|
50
66
|
# @param [String] target_path
|
51
67
|
# @param [Hash] index
|
52
68
|
# @return [Array]
|
@@ -66,11 +82,13 @@ module JsDependency
|
|
66
82
|
# @param [String] target_path
|
67
83
|
# @return [Pathname]
|
68
84
|
def to_target_pathname(target_path)
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
85
|
+
JsDependency::PathnameUtility.to_target_pathname(target_path)
|
86
|
+
end
|
87
|
+
|
88
|
+
# @param [Pathname] pathname
|
89
|
+
# @param [Integer] level
|
90
|
+
def parse(pathname, level = -1)
|
91
|
+
JsDependency::PathnameUtility.parse(pathname, level)
|
74
92
|
end
|
75
93
|
end
|
76
94
|
end
|
data/lib/js_dependency.rb
CHANGED
@@ -33,9 +33,10 @@ module JsDependency
|
|
33
33
|
index = JsDependency::IndexCreator.call(src_path, alias_paths: alias_paths, excludes: excludes)
|
34
34
|
|
35
35
|
nodes = []
|
36
|
+
styles = []
|
36
37
|
target_paths.each do |target_path|
|
37
38
|
target_pathname = JsDependency::TargetPathname.new(target_path)
|
38
|
-
|
39
|
+
styles += [target_pathname.mermaid_style(src_path)]
|
39
40
|
mermaid_root = JsDependency::Mermaid::Root.new(orientation)
|
40
41
|
|
41
42
|
target_pathname.each_parent_path(parent_analyze_level, index) do |parent_path, child_path|
|
@@ -48,7 +49,7 @@ module JsDependency
|
|
48
49
|
nodes += mermaid_root.export_nodes(name_level: name_level, src_path: src_path)
|
49
50
|
end
|
50
51
|
|
51
|
-
output = (["flowchart LR"] + nodes.uniq).join("\n")
|
52
|
+
output = (["flowchart LR"] + nodes.uniq + styles.uniq).join("\n")
|
52
53
|
output_pathname&.write(output)
|
53
54
|
output
|
54
55
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: js_dependency
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- junara
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pathname
|