js_dependency 0.1.0 → 0.1.1

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: 68994e61c025f75290a28d6d14e1004c54c09ad32d54f3c93fc5626d9621fcd2
4
- data.tar.gz: f8dcb17dc254e873d217ecce20ec2e739d1c53c9935cbc6e163941d53a033f2a
3
+ metadata.gz: 20217229c2c7f845d05b400f356240d4e2db4d46f9b4d1fc6662868bc1bac372
4
+ data.tar.gz: d74ccf10be4764621ff17bc2700c56b8947263b5dc35bccaab49101df90eea59
5
5
  SHA512:
6
- metadata.gz: 46891feebfed8de0c5fe551b3e176e48d38f17359c6322fd68893c6a0b101394981b5e97385079069c20b93df198c5e8abbb211a3d482609101ad5db06a81197
7
- data.tar.gz: ab70ef7054409bc108c68ed0b376feaa110c59543769c91f232940b75cfe81917ca2ca4a7c2c3881b89dd3247fa49d8f03c27bf4b70f7bc14b14e14a8f31b7d1
6
+ metadata.gz: a842902a4bf0331ea00352315682bf4efb8ac6891dfa2fcfedff0d5ecdfada5d8cf1240ebc6e02a5f8b8ac8a6df54d85c47e4140ac581601d43dbb7a16f3fb2d
7
+ data.tar.gz: 919130f6a767b0dc51533cacee935c810da0a8460ab74e86536704fea8614289fa45025c8b3d9edd62a48782bc463e632256b3c9868f849bcb93cf006859c035
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.1] - 2022-07-19
4
+
5
+ - Bug fix of double quotation mark.
6
+
3
7
  ## [0.1.0] - 2022-07-16
4
8
 
5
9
  - Initial release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- js_dependency (0.1.0)
4
+ js_dependency (0.1.1)
5
5
  pathname
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/js_dependency`. To experiment with that code, run `bin/console` for an interactive prompt.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ Analyze import dependency of JavaScript code and export mermaid format.
6
6
 
7
7
  ## Installation
8
8
 
@@ -15,8 +15,30 @@ If bundler is not being used to manage dependencies, install the gem by executin
15
15
  $ gem install js_dependency
16
16
 
17
17
  ## Usage
18
+ If your javascript code is in `./src` and `./src/App.vue` is in the directory, you can analyze `./src/App.vue` dependency like this:
18
19
 
19
- TODO: Write usage instructions here
20
+ ```ruby
21
+ require 'js_dependency'
22
+
23
+
24
+ src_path = './src' # Root folder.
25
+ target_path = './src/App.vue' # Target file that you want to analyze.
26
+ child_analyze_level = 2 # Output level of child dependency.
27
+ parent_analyze_level = 2 # Output level of parent dependency.
28
+ output_path = './mermaid.txt' # Optional. Output file path
29
+ alias_paths = {'@' => '/src' } # Optional. Alias path.
30
+
31
+ # mermaid出力実行
32
+ JsDependency.export_mermaid(
33
+ src_path,
34
+ target_path,
35
+ child_analyze_level: child_analyze_level,
36
+ parent_analyze_level: parent_analyze_level,
37
+ output_path: output_path,
38
+ alias_paths: alias_paths)
39
+ ```
40
+
41
+ See `./mermaid.txt` of `output_path` for the result.
20
42
 
21
43
  ## Development
22
44
 
@@ -26,7 +48,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
26
48
 
27
49
  ## Contributing
28
50
 
29
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/js_dependency. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/js_dependency/blob/main/CODE_OF_CONDUCT.md).
51
+ Bug reports and pull requests are welcome on GitHub at https://github.com/junara/js_dependency. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/js_dependency/blob/main/CODE_OF_CONDUCT.md).
30
52
 
31
53
  ## License
32
54
 
@@ -12,11 +12,11 @@ module JsDependency
12
12
  def call
13
13
  str = @str
14
14
  # import defaultExport from 'module-name';
15
- paths = str.gsub(/import\s+\S+\s+from\s+"([^']+)"/).with_object([]) { |_, list| list << Regexp.last_match(1) }
15
+ paths = str.gsub(/import\s+\S+\s+from\s+"([^"]+)"/).with_object([]) { |_, list| list << Regexp.last_match(1) }
16
16
  paths += str.gsub(/import\s+\S+\s+from\s+'([^']+)'/).with_object([]) { |_, list| list << Regexp.last_match(1) }
17
17
 
18
18
  # import * as name from \"module-name\";
19
- paths += str.gsub(/import\s+\S+\s+as\s+\S+\s+from\s+"([^']+)"/).with_object([]) do |_, list|
19
+ paths += str.gsub(/import\s+\S+\s+as\s+\S+\s+from\s+"([^"]+)"/).with_object([]) do |_, list|
20
20
  list << Regexp.last_match(1)
21
21
  end
22
22
  paths += str.gsub(/import\s+\S+\s+as\s+\S+\s+from\s+'([^']+)'/).with_object([]) do |_, list|
@@ -28,7 +28,7 @@ module JsDependency
28
28
  # import { export1 , export2 } from "module-name";
29
29
  # import { foo , bar } from "module-name/path/to/specific/un-exported/file";
30
30
  # import { export1 , export2 as alias2 , [...] } from "module-name";
31
- paths += str.gsub(/import\s+\{\s+.+\s+\}\s+from\s+"([^']+)"/).with_object([]) do |_, list|
31
+ paths += str.gsub(/import\s+\{\s+.+\s+\}\s+from\s+"([^"]+)"/).with_object([]) do |_, list|
32
32
  list << Regexp.last_match(1)
33
33
  end
34
34
  paths += str.gsub(/import\s+\{\s+.+\s+\}\s+from\s+'([^']+)'/).with_object([]) do |_, list|
@@ -36,7 +36,7 @@ module JsDependency
36
36
  end
37
37
 
38
38
  # import defaultExport, { export1 [ , [...] ] } from "module-name";
39
- paths += str.gsub(/import\s+\S+,\s+\{\s+.+\s+\}\s+from\s+"([^']+)"/).with_object([]) do |_, list|
39
+ paths += str.gsub(/import\s+\S+,\s+\{\s+.+\s+\}\s+from\s+"([^"]+)"/).with_object([]) do |_, list|
40
40
  list << Regexp.last_match(1)
41
41
  end
42
42
  paths += str.gsub(/import\s+\S+,\s+\{\s+.+\s+\}\s+from\s+'([^']+)'/).with_object([]) do |_, list|
@@ -44,7 +44,7 @@ module JsDependency
44
44
  end
45
45
 
46
46
  # import defaultExport, * as name from "module-name";
47
- paths += str.gsub(/import\s+\S+,\s+.+\s+as\s+\S+\s+from\s+"([^']+)"/).with_object([]) do |_, list|
47
+ paths += str.gsub(/import\s+\S+,\s+.+\s+as\s+\S+\s+from\s+"([^"]+)"/).with_object([]) do |_, list|
48
48
  list << Regexp.last_match(1)
49
49
  end
50
50
  paths += str.gsub(/import\s+\S+,\s+.+\s+as\s+\S+\s+from\s+'([^']+)'/).with_object([]) do |_, list|
@@ -52,7 +52,7 @@ module JsDependency
52
52
  end
53
53
 
54
54
  # import "module-name";
55
- paths += str.gsub(/import\s+"([^']+)"/).with_object([]) do |_, list|
55
+ paths += str.gsub(/import\s+"([^"]+)"/).with_object([]) do |_, list|
56
56
  list << Regexp.last_match(1)
57
57
  end
58
58
  paths += str.gsub(/import\s+'([^']+)'/).with_object([]) do |_, list|
@@ -60,7 +60,7 @@ module JsDependency
60
60
  end
61
61
 
62
62
  # var promise = import("module-name");
63
- paths += str.gsub(/import\("([^']+)"\)/).with_object([]) do |_, list|
63
+ paths += str.gsub(/import\("([^"]+)"\)/).with_object([]) do |_, list|
64
64
  list << Regexp.last_match(1)
65
65
  end
66
66
  paths += str.gsub(/import\('([^']+)'\)/).with_object([]) do |_, list|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JsDependency
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
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.1.0
4
+ version: 0.1.1
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-18 00:00:00.000000000 Z
11
+ date: 2022-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pathname