js_dependency 0.2.1 → 0.2.2

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
  SHA256:
3
- metadata.gz: 5bf7cfb1d29636defe8ab5e05990af5d95e80f5dc383ff1e3bb56233f6458cd6
4
- data.tar.gz: 426a15952e30fe085bfa93c3ab5fbdb1a1f8e19323c01cddc83d3744a41a9269
3
+ metadata.gz: d88ba49b09bf39f743538394281ad7d7956abfd3a3a86e7b34fb88c1ad995f98
4
+ data.tar.gz: 75928de5c657b2af3599606343798f17bfc2839e4967b46a9c9274eef0819218
5
5
  SHA512:
6
- metadata.gz: ea9dd1783d4c7d6ea1c7a205c49fbb55fd73ba947d474c87e700b4e8ad52e93a2ce0816ddfc0f3df78c9bc689c7b7f3037196e7ddd1d73d701616ff5f4234364
7
- data.tar.gz: c2020ea6afcef60232a53b2846f7ba972b15c6600659bc18197f68708187f2d75bd0349011297b3e98201428cbc31f8d617f5999d29010d0293a433fc96a2b47
6
+ metadata.gz: 27bbd73e5ecd0f49ff5c82608abf7f553802fdce21878dd18036e1d675c09f526a92e152c08aab3ec9b9293c4a446d51b27fa8ceb75bd19a074ab097d9e5248d
7
+ data.tar.gz: 5f328e13c00a1a50352c910902a42323caf558cdd22441218cc03048bebc41da85aea3b767948ce951b373037d7404e57ae293d4e85e12d1f930baef21a2d312
@@ -6,3 +6,6 @@ name_level: 1
6
6
  output_path: ./mermaid.txt
7
7
  alias_paths:
8
8
  "@": ./pages
9
+ excludes:
10
+ - excludedWord1
11
+ - excludedWord2
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-19 16:03:39 UTC using RuboCop version 1.31.2.
3
+ # on 2022-07-20 14:57:17 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
@@ -9,32 +9,32 @@
9
9
  # Offense count: 6
10
10
  # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
11
11
  Metrics/AbcSize:
12
- Max: 30
12
+ Max: 37
13
13
 
14
- # Offense count: 3
14
+ # Offense count: 5
15
15
  # Configuration parameters: IgnoredMethods.
16
16
  Metrics/CyclomaticComplexity:
17
- Max: 13
17
+ Max: 15
18
18
 
19
19
  # Offense count: 8
20
20
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
21
21
  Metrics/MethodLength:
22
- Max: 20
22
+ Max: 26
23
23
 
24
24
  # Offense count: 1
25
25
  # Configuration parameters: CountComments, CountAsOne.
26
26
  Metrics/ModuleLength:
27
- Max: 112
27
+ Max: 114
28
28
 
29
- # Offense count: 1
29
+ # Offense count: 3
30
30
  # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
31
31
  Metrics/ParameterLists:
32
- Max: 8
32
+ Max: 9
33
33
 
34
- # Offense count: 3
34
+ # Offense count: 5
35
35
  # Configuration parameters: IgnoredMethods.
36
36
  Metrics/PerceivedComplexity:
37
- Max: 13
37
+ Max: 16
38
38
 
39
39
  # Offense count: 1
40
40
  # This cop supports safe autocorrection (--autocorrect).
@@ -42,9 +42,9 @@ Style/IfUnlessModifier:
42
42
  Exclude:
43
43
  - 'lib/js_dependency/index_creator.rb'
44
44
 
45
- # Offense count: 1
45
+ # Offense count: 2
46
46
  # This cop supports safe autocorrection (--autocorrect).
47
47
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
48
48
  # URISchemes: http, https
49
49
  Layout/LineLength:
50
- Max: 167
50
+ Max: 182
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.2] - 2022-07-21
4
+
5
+ - Add CLI option parameter "exclude".
6
+ - Add yaml configuration option parameter "excludes" that is array of "exclude".
7
+
3
8
  ## [0.2.1] - 2022-07-20
4
9
 
5
10
  - Output parents and children cli with line brake and sort.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- js_dependency (0.2.1)
4
+ js_dependency (0.2.2)
5
5
  pathname
6
6
  thor
7
7
  yaml
data/README.md CHANGED
@@ -30,6 +30,9 @@ name_level: 1 # Output name level
30
30
  output_path: ./mermaid.txt # Output file path
31
31
  alias_paths: # Alias path
32
32
  "@": ./pages # absolute path or relative path of src_path
33
+ excludes: # Exclude words that you want to skip from export.
34
+ - excludeWord1
35
+ - excludeWord2
33
36
  ```
34
37
 
35
38
  Each parameter is overridden by the command line.
@@ -41,6 +44,7 @@ child_analyze_level -> -c
41
44
  parent_analyze_level -> -p
42
45
  name_level -> -n
43
46
  output_path -> -o
47
+ exclude -> -e
44
48
  ```
45
49
 
46
50
  #### Export Mermaid Format
@@ -14,6 +14,8 @@ module JsDependency
14
14
  option :child_analyze_level, type: :numeric, aliases: "-c", desc: "Output level of child dependency"
15
15
  option :parent_analyze_level, type: :numeric, aliases: "-p", desc: "Output level of parent dependency"
16
16
  option :name_level, type: :numeric, aliases: "-n", desc: "Output name level"
17
+ option :exclude, type: :string, aliases: "-e", desc: "Exclude the word that is included in the path"
18
+
17
19
  def export_mermaid
18
20
  pathname = Pathname.new(".js_dependency.yml")
19
21
  args = {}
@@ -26,6 +28,11 @@ module JsDependency
26
28
  output_path = options[:output_path] || args["output_path"] || nil
27
29
  alias_paths = args["alias_paths"] || nil
28
30
  name_level = options[:name_level] || args["name_level"] || 1
31
+ excludes = if options[:exclude]
32
+ [options[:exclude]]
33
+ elsif args["excludes"]
34
+ args["excludes"]
35
+ end
29
36
 
30
37
  str = JsDependency.export_mermaid(
31
38
  src_path,
@@ -34,7 +41,8 @@ module JsDependency
34
41
  parent_analyze_level: parent_analyze_level,
35
42
  output_path: output_path,
36
43
  alias_paths: alias_paths,
37
- name_level: name_level
44
+ name_level: name_level,
45
+ excludes: excludes
38
46
  )
39
47
 
40
48
  puts str
@@ -45,6 +53,8 @@ module JsDependency
45
53
  option :target_path, type: :string, aliases: "-t", desc: "Target file that you want to analyze."
46
54
  option :output_path, type: :string, aliases: "-o", desc: "Output file path"
47
55
  option :parent_analyze_level, type: :numeric, aliases: "-p", desc: "Output level of parent dependency"
56
+ option :exclude, type: :string, aliases: "-e", desc: "Exclude the word that is included in the path"
57
+
48
58
  def parents
49
59
  pathname = Pathname.new(".js_dependency.yml")
50
60
  args = {}
@@ -55,13 +65,19 @@ module JsDependency
55
65
  parent_analyze_level = options[:parent_analyze_level] || args["parent_analyze_level"] || 1
56
66
  output_path = options[:output_path] || args["output_path"] || nil
57
67
  alias_paths = args["alias_paths"] || nil
68
+ excludes = if options[:exclude]
69
+ [options[:exclude]]
70
+ elsif args["excludes"]
71
+ args["excludes"]
72
+ end
58
73
 
59
74
  str = JsDependency.parents(
60
75
  src_path,
61
76
  target_path,
62
77
  parent_analyze_level: parent_analyze_level,
63
78
  output_path: output_path,
64
- alias_paths: alias_paths
79
+ alias_paths: alias_paths,
80
+ excludes: excludes
65
81
  ).sort.uniq.join("\n")
66
82
 
67
83
  puts str
@@ -72,6 +88,8 @@ module JsDependency
72
88
  option :target_path, type: :string, aliases: "-t", desc: "Target file that you want to analyze."
73
89
  option :output_path, type: :string, aliases: "-o", desc: "Output file path"
74
90
  option :child_analyze_level, type: :numeric, aliases: "-c", desc: "Output level of child dependency"
91
+ option :exclude, type: :string, aliases: "-e", desc: "Exclude the word that is included in the path"
92
+
75
93
  def children
76
94
  pathname = Pathname.new(".js_dependency.yml")
77
95
  args = {}
@@ -82,13 +100,19 @@ module JsDependency
82
100
  child_analyze_level = options[:child_analyze_level] || args["child_analyze_level"] || 1
83
101
  output_path = options[:output_path] || args["output_path"] || nil
84
102
  alias_paths = args["alias_paths"] || nil
103
+ excludes = if options[:exclude]
104
+ [options[:exclude]]
105
+ elsif args["excludes"]
106
+ args["excludes"]
107
+ end
85
108
 
86
109
  str = JsDependency.children(
87
110
  src_path,
88
111
  target_path,
89
112
  child_analyze_level: child_analyze_level,
90
113
  output_path: output_path,
91
- alias_paths: alias_paths
114
+ alias_paths: alias_paths,
115
+ excludes: excludes
92
116
  ).sort.uniq.join("\n")
93
117
 
94
118
  puts str
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JsDependency
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
  end
data/lib/js_dependency.rb CHANGED
@@ -17,8 +17,9 @@ module JsDependency
17
17
  # @param [Integer] parent_analyze_level
18
18
  # @param [Integer] name_level
19
19
  # @param [String, nil] output_path
20
+ # @param [Array, nil] excludes
20
21
  # @return [String]
21
- def self.export_mermaid(src_path, target_path, orientation: "LR", alias_paths: nil, child_analyze_level: 1, parent_analyze_level: 1, name_level: 1, output_path: nil)
22
+ def self.export_mermaid(src_path, target_path, orientation: "LR", alias_paths: nil, child_analyze_level: 1, parent_analyze_level: 1, name_level: 1, output_path: nil, excludes: nil)
22
23
  output_pathname = Pathname.new(output_path) if output_path
23
24
  index = JsDependency::IndexCreator.call(src_path, alias_paths: alias_paths)
24
25
 
@@ -30,11 +31,11 @@ module JsDependency
30
31
 
31
32
  root = JsDependency::Mermaid::Root.new(orientation)
32
33
 
33
- parents_paths(target_pathname, parent_analyze_level, index) do |parent_path, child_path|
34
+ parents_paths(target_pathname, parent_analyze_level, index, excludes: excludes) do |parent_path, child_path|
34
35
  root.add(parent_path, child_path)
35
36
  end
36
37
 
37
- children_paths(target_pathname, child_analyze_level, index) do |parent_path, child_path|
38
+ children_paths(target_pathname, child_analyze_level, index, excludes: excludes) do |parent_path, child_path|
38
39
  root.add(parent_path, child_path)
39
40
  end
40
41
 
@@ -43,7 +44,7 @@ module JsDependency
43
44
  output
44
45
  end
45
46
 
46
- def self.parents(src_path, target_path, alias_paths: nil, parent_analyze_level: 1, output_path: nil)
47
+ def self.parents(src_path, target_path, alias_paths: nil, parent_analyze_level: 1, output_path: nil, excludes: nil)
47
48
  output_pathname = Pathname.new(output_path) if output_path
48
49
  index = JsDependency::IndexCreator.call(src_path, alias_paths: alias_paths)
49
50
 
@@ -53,7 +54,7 @@ module JsDependency
53
54
  Pathname.new(target_path)
54
55
  end
55
56
  list = []
56
- parents_paths(target_pathname, parent_analyze_level, index) do |parent_path, _child_path|
57
+ parents_paths(target_pathname, parent_analyze_level, index, excludes: excludes) do |parent_path, _child_path|
57
58
  list << parent_path
58
59
  end
59
60
  output = list.uniq
@@ -61,7 +62,7 @@ module JsDependency
61
62
  output
62
63
  end
63
64
 
64
- def self.children(src_path, target_path, alias_paths: nil, child_analyze_level: 1, output_path: nil)
65
+ def self.children(src_path, target_path, alias_paths: nil, child_analyze_level: 1, output_path: nil, excludes: nil)
65
66
  output_pathname = Pathname.new(output_path) if output_path
66
67
  index = JsDependency::IndexCreator.call(src_path, alias_paths: alias_paths)
67
68
 
@@ -71,7 +72,7 @@ module JsDependency
71
72
  Pathname.new(target_path)
72
73
  end
73
74
  list = []
74
- children_paths(target_pathname, child_analyze_level, index) do |_parent_path, child_path|
75
+ children_paths(target_pathname, child_analyze_level, index, excludes: excludes) do |_parent_path, child_path|
75
76
  list << child_path
76
77
  end
77
78
  output = list.uniq
@@ -92,6 +93,7 @@ module JsDependency
92
93
  list << parent if children.any?(target_pathname.to_s)
93
94
  end
94
95
  end
96
+
95
97
  private_class_method :extract_parent_paths
96
98
 
97
99
  # @param [String] target_path
@@ -105,6 +107,7 @@ module JsDependency
105
107
  end
106
108
  index[target_pathname.to_s] || []
107
109
  end
110
+
108
111
  private_class_method :extract_children_paths
109
112
 
110
113
  # @param [String] src
@@ -112,9 +115,10 @@ module JsDependency
112
115
  def self.create_index(src_path, alias_paths: nil)
113
116
  JsDependency::IndexCreator.call(src_path, alias_paths: alias_paths)
114
117
  end
118
+
115
119
  private_class_method :create_index
116
120
 
117
- def self.parents_paths(target_pathname, analyze_level, index)
121
+ def self.parents_paths(target_pathname, analyze_level, index, excludes: nil)
118
122
  temp_paths = [target_pathname.to_s]
119
123
  analyze_level.times do
120
124
  list = []
@@ -126,15 +130,18 @@ module JsDependency
126
130
  end
127
131
 
128
132
  list += extract_parent_paths(temp_pathname.to_s, index).each do |parent_path|
133
+ next if excludes&.any? { |ignore| parent_path.to_s.include?(ignore) }
134
+
129
135
  yield parent_path, temp_pathname.to_s
130
136
  end
131
137
  end
132
138
  temp_paths = list
133
139
  end
134
140
  end
141
+
135
142
  private_class_method :parents_paths
136
143
 
137
- def self.children_paths(target_pathname, analyze_level, index)
144
+ def self.children_paths(target_pathname, analyze_level, index, excludes: nil)
138
145
  temp_paths = [target_pathname.to_s]
139
146
  analyze_level.times do
140
147
  list = []
@@ -146,11 +153,14 @@ module JsDependency
146
153
  end
147
154
 
148
155
  list += extract_children_paths(temp_pathname.to_s, index).each do |child_path|
156
+ next if excludes&.any? { |ignore| child_path.to_s.include?(ignore) }
157
+
149
158
  yield temp_pathname.to_s, child_path
150
159
  end
151
160
  end
152
161
  temp_paths = list
153
162
  end
154
163
  end
164
+
155
165
  private_class_method :children_paths
156
166
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: js_dependency
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - junara