alba_migration 0.0.4 → 0.0.5
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/CHANGELOG.md +4 -0
- data/lib/alba_migration/cli.rb +21 -3
- data/lib/alba_migration/snippet.rb +6 -1
- data/lib/alba_migration/version.rb +1 -1
- data/sig/generated/alba_migration/cli.rbs +6 -2
- data/sig/generated/alba_migration/snippet.rbs +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df7bbe77cae170bad5af5a2540c34d0a2d168d0c20b1a63878fb8d97cba67f5a
|
4
|
+
data.tar.gz: 2cef8adf32f038d6b9ee4460bf5ee91b079d9a486159689c5c045c3b343202ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d987b4eb4a8e04c09ed01141a3bb4106379723e00bfb6322042a3610e05e5cf7d5a78e6d69a10d2df177634437ef5c5e93c4a56443ea3414c8f5ea3f79b9a6df
|
7
|
+
data.tar.gz: fdbf061dcf55e0cea70e6894681f4bee91fe0c09258f835a60db825b21dd55ea4f8b414ede2fcd3f0281cb2a3d0275bbb2a545d9f53267b64698a1b0c6882b70
|
data/CHANGELOG.md
CHANGED
data/lib/alba_migration/cli.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
# rbs_inline: enabled
|
4
4
|
|
5
5
|
require "fileutils"
|
6
|
+
require "optparse"
|
6
7
|
require "alba_migration/snippet"
|
7
8
|
|
8
9
|
module AlbaMigration
|
@@ -13,9 +14,15 @@ module AlbaMigration
|
|
13
14
|
new.execute(args)
|
14
15
|
end
|
15
16
|
|
16
|
-
# @rbs
|
17
|
+
# @rbs args: Array[String]
|
17
18
|
# @rbs return: void
|
18
|
-
def execute(
|
19
|
+
def execute(args = [])
|
20
|
+
options = {}
|
21
|
+
parser = options_parser(options)
|
22
|
+
|
23
|
+
parser.parse!(args)
|
24
|
+
file_patterns = args
|
25
|
+
|
19
26
|
matched_files = file_patterns.flat_map { |pattern| Dir.glob(pattern) }.uniq
|
20
27
|
if matched_files.empty?
|
21
28
|
puts "Error: No files matched the given pattern(s): #{file_patterns.join(", ")}"
|
@@ -28,7 +35,18 @@ module AlbaMigration
|
|
28
35
|
exit(1)
|
29
36
|
end
|
30
37
|
|
31
|
-
AlbaMigration::Snippet.process_snippets(migrate_file_path: matched_files)
|
38
|
+
AlbaMigration::Snippet.process_snippets(migrate_file_path: matched_files, custom_snippet_path: options[:add_on])
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def options_parser(options)
|
44
|
+
OptionParser.new do |opts|
|
45
|
+
opts.banner = "Usage: alba_migration [options] FILES..."
|
46
|
+
opts.on("--add_on FILE", "Specify a custom snippet Ruby file") do |file|
|
47
|
+
options[:add_on] = file
|
48
|
+
end
|
49
|
+
end
|
32
50
|
end
|
33
51
|
end
|
34
52
|
end
|
@@ -21,9 +21,14 @@ module AlbaMigration
|
|
21
21
|
end
|
22
22
|
|
23
23
|
# @rbs migrate_file_path: String
|
24
|
+
# @rbs custom_snippet_path: String | nil
|
24
25
|
# @rbs return: void
|
25
|
-
def self.process_snippets(migrate_file_path:)
|
26
|
+
def self.process_snippets(migrate_file_path:, custom_snippet_path: nil)
|
26
27
|
snippets = snippets(migrate_file_path:)
|
28
|
+
if custom_snippet_path
|
29
|
+
custom_snippet = eval(File.read(custom_snippet_path)) # rubocop:disable Security/Eval
|
30
|
+
snippets.push(custom_snippet)
|
31
|
+
end
|
27
32
|
snippets.each(&:process)
|
28
33
|
end
|
29
34
|
|
@@ -6,8 +6,12 @@ module AlbaMigration
|
|
6
6
|
# @rbs return: void
|
7
7
|
def self.start: (untyped args) -> void
|
8
8
|
|
9
|
-
# @rbs
|
9
|
+
# @rbs args: Array[String]
|
10
10
|
# @rbs return: void
|
11
|
-
def execute: (?Array[String]
|
11
|
+
def execute: (?Array[String] args) -> void
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def options_parser: (untyped options) -> untyped
|
12
16
|
end
|
13
17
|
end
|
@@ -11,8 +11,9 @@ module AlbaMigration
|
|
11
11
|
def self.snippets: (migrate_file_path: String) -> Array[Synvert::Core::Rewriter]
|
12
12
|
|
13
13
|
# @rbs migrate_file_path: String
|
14
|
+
# @rbs custom_snippet_path: String | nil
|
14
15
|
# @rbs return: void
|
15
|
-
def self.process_snippets: (migrate_file_path: String) -> void
|
16
|
+
def self.process_snippets: (migrate_file_path: String, ?custom_snippet_path: String | nil) -> void
|
16
17
|
|
17
18
|
# @rbs migrate_file_path: String
|
18
19
|
# @rbs return: void
|