js_dependency 0.3.9 → 0.3.10

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: e6ac19bdd54aa746f7e5f40bb7cf8c92660eb8384c074347734f8e484d60d878
4
- data.tar.gz: a5f4a090fec3d3a4af1c8a8b5747efc830f8f92c4f29dce852e91348c0d867c6
3
+ metadata.gz: 153a609f4227a43182ed6e6a469bcfe466ffe130c5f6d8033771545ca13b4198
4
+ data.tar.gz: 32cd8dd2ec33e8906b0bad39c8a4a6378e4909285486f52b6c93915891bed8bb
5
5
  SHA512:
6
- metadata.gz: '0902a104039ef853937b3d1739ec0f1fe249d17f7428d23457124e66b16003a8f7a3136ceefb14a6f3122c99bfcbeeeec0f77d589066f6e0956d95e11b36b963'
7
- data.tar.gz: 746f673194445bf43f180a2ec650bd2530795e9966e8cc6a35f5bb55d37ff8688187ceaff41475117bd166d6a788624a3bbb63555b52901231a5d46dace1f4dd
6
+ metadata.gz: 63e3437906da40a60ed9e129dc8b2a3157221a61d34982bce433dfb8f8b3c7ee198cba9c85b6f230079db5a3a08fe9bb1c103d38763ce139a5aed81ecf5c9e10
7
+ data.tar.gz: cf47aa344e700868b2dd76c67ad4323acc2a47e9f0e4d9736d0ae30a981715bb639c52b4d9322b243122879abaf892b314479d39a3c29e4dba56df848cfbe0a0
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-08-11 15:14:43 UTC using RuboCop version 1.34.1.
3
+ # on 2022-08-13 03:35:35 UTC using RuboCop version 1.34.1.
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: 8
39
+ # Offense count: 9
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
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.10] - 2022-08-13
4
+
5
+ - Add file_config options to specify configuration yaml which user like.
6
+
3
7
  ## [0.3.9] - 2022-08-12
4
8
 
5
9
  - Add alias_paths options of hash.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- js_dependency (0.3.9)
4
+ js_dependency (0.3.10)
5
5
  pathname
6
6
  thor
7
7
  yaml
data/README.md CHANGED
@@ -46,6 +46,12 @@ excludes: # Exclude words that you want to skip from export.
46
46
  - excludeWord2
47
47
  ```
48
48
 
49
+ If you want to specify .js_dependency.yml as another path, you can add option path by `-f` option.
50
+
51
+ ```shell
52
+ js_dependency -f path/to/yourfilename.yml
53
+ ```
54
+
49
55
  Each parameter is overridden by the command line.
50
56
 
51
57
  ```
@@ -16,9 +16,10 @@ module JsDependency
16
16
  method_option :name_level, type: :numeric, aliases: "-n", desc: "Output name level"
17
17
  method_option :excludes, type: :array, aliases: "-e", desc: "Exclude the word that is included in the path"
18
18
  method_option :alias_paths, type: :hash, aliases: "-a", desc: "Alias paths by hash format."
19
+ method_option :file_config, type: :string, aliases: "-f", desc: "Configuration file path."
19
20
 
20
21
  def export_mermaid
21
- args = JsDependency::CliUtils::Yaml.new.args
22
+ args = JsDependency::CliUtils::Yaml.new(path: options[:file_config]).args
22
23
  config = JsDependency::CliUtils::Config.new(options, args)
23
24
  puts JsDependency.export_mermaid(
24
25
  config.src_path,
@@ -39,9 +40,10 @@ module JsDependency
39
40
  method_option :parent_analyze_level, type: :numeric, aliases: "-p", desc: "Output level of parent dependency"
40
41
  method_option :excludes, type: :array, aliases: "-e", desc: "Exclude the word that is included in the path"
41
42
  method_option :alias_paths, type: :hash, aliases: "-a", desc: "Alias paths by hash format."
43
+ method_option :file_config, type: :string, aliases: "-f", desc: "Configuration file path."
42
44
 
43
45
  def parents
44
- args = JsDependency::CliUtils::Yaml.new.args
46
+ args = JsDependency::CliUtils::Yaml.new(path: options[:file_config]).args
45
47
  config = JsDependency::CliUtils::Config.new(options, args)
46
48
  puts JsDependency.parents(
47
49
  config.src_path,
@@ -60,9 +62,10 @@ module JsDependency
60
62
  method_option :child_analyze_level, type: :numeric, aliases: "-c", desc: "Output level of child dependency"
61
63
  method_option :excludes, type: :array, aliases: "-e", desc: "Exclude the word that is included in the path"
62
64
  method_option :alias_paths, type: :hash, aliases: "-a", desc: "Alias paths by hash format."
65
+ method_option :file_config, type: :string, aliases: "-f", desc: "Configuration file path."
63
66
 
64
67
  def children
65
- args = JsDependency::CliUtils::Yaml.new.args
68
+ args = JsDependency::CliUtils::Yaml.new(path: options[:file_config]).args
66
69
  config = JsDependency::CliUtils::Config.new(options, args)
67
70
  puts JsDependency.children(
68
71
  config.src_path,
@@ -77,9 +80,10 @@ module JsDependency
77
80
  desc "orphan", "export components than is not depended by others"
78
81
  method_option :src_path, type: :string, aliases: "-s", desc: "Root folder."
79
82
  method_option :alias_paths, type: :hash, aliases: "-a", desc: "Alias paths by hash format."
83
+ method_option :file_config, type: :string, aliases: "-f", desc: "Configuration file path."
80
84
 
81
85
  def orphan
82
- args = JsDependency::CliUtils::Yaml.new.args
86
+ args = JsDependency::CliUtils::Yaml.new(path: options[:file_config]).args
83
87
  config = JsDependency::CliUtils::Config.new(options, args)
84
88
  puts JsDependency.orphan(
85
89
  config.src_path,
@@ -90,9 +94,10 @@ module JsDependency
90
94
  desc "leave", "export components than is not depended by others"
91
95
  method_option :src_path, type: :string, aliases: "-s", desc: "Root folder."
92
96
  method_option :alias_paths, type: :hash, aliases: "-a", desc: "Alias paths by hash format."
97
+ method_option :file_config, type: :string, aliases: "-f", desc: "Configuration file path."
93
98
 
94
99
  def leave
95
- args = JsDependency::CliUtils::Yaml.new.args
100
+ args = JsDependency::CliUtils::Yaml.new(path: options[:file_config]).args
96
101
  config = JsDependency::CliUtils::Config.new(options, args)
97
102
  puts JsDependency.leave(
98
103
  config.src_path,
@@ -3,22 +3,42 @@
3
3
  module JsDependency
4
4
  module CliUtils
5
5
  class Yaml
6
- attr_reader :args,
7
- :dir_path
6
+ attr_reader :dir_path,
7
+ :path
8
8
 
9
9
  # @param [String, nil] dir_path
10
- def initialize(dir_path: nil)
11
- @dir_path = dir_path || Dir.pwd
12
- pathname = config_pathname
13
- @args = if pathname.nil?
14
- {}
15
- else
16
- symbolize_keys(YAML.safe_load(pathname.read))
17
- end
10
+ # @param [String, nil] path
11
+ def initialize(dir_path: nil, path: nil)
12
+ @dir_path = present?(dir_path) ? dir_path : Dir.pwd
13
+ @path = path
14
+ end
15
+
16
+ # @return [Hash]
17
+ def args
18
+ pathname = if present?(@path)
19
+ Pathname.new(@path)
20
+ else
21
+ config_pathname
22
+ end
23
+
24
+ if pathname.nil?
25
+ {}
26
+ else
27
+ symbolize_keys(YAML.safe_load(pathname.read))
28
+ end
18
29
  end
19
30
 
20
31
  private
21
32
 
33
+ # @param [String] str
34
+ # @return [TrueClass, FalseClass]
35
+ def present?(str)
36
+ return false if str.nil?
37
+ return false if str.empty?
38
+
39
+ true
40
+ end
41
+
22
42
  # @return [Pathname, nil]
23
43
  def config_pathname
24
44
  dir_pathname = Pathname.new(@dir_path)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JsDependency
4
- VERSION = "0.3.9"
4
+ VERSION = "0.3.10"
5
5
  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.9
4
+ version: 0.3.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - junara
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-11 00:00:00.000000000 Z
11
+ date: 2022-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pathname