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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d8b22bb77ee9707b3787fbef95b63722b8303ccc02044e905174b673b024517
4
- data.tar.gz: f9f5d8c943160355a7fbd9e38308347929df48afc6062751cd8a5f38ae0f1984
3
+ metadata.gz: df7bbe77cae170bad5af5a2540c34d0a2d168d0c20b1a63878fb8d97cba67f5a
4
+ data.tar.gz: 2cef8adf32f038d6b9ee4460bf5ee91b079d9a486159689c5c045c3b343202ff
5
5
  SHA512:
6
- metadata.gz: 61967197eadc4abb078a2563d0cf8b118872f61373ef964e35267e2d819d6e7a94ab3fbf720a32bb8c75f94ff943cee2c01f7d8a38bb971c9c25062f6da70887
7
- data.tar.gz: 732ffb30e8a855349c4a7d8602deec121ee51ce4d0dc864d877da6ef62eb3444a5fcab14c8818b1219a8391192dcb0df290cbd47537c7f0668da8bc9454cc2a5
6
+ metadata.gz: d987b4eb4a8e04c09ed01141a3bb4106379723e00bfb6322042a3610e05e5cf7d5a78e6d69a10d2df177634437ef5c5e93c4a56443ea3414c8f5ea3f79b9a6df
7
+ data.tar.gz: fdbf061dcf55e0cea70e6894681f4bee91fe0c09258f835a60db825b21dd55ea4f8b414ede2fcd3f0281cb2a3d0275bbb2a545d9f53267b64698a1b0c6882b70
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # GHANGELOG
2
2
 
3
+ ## 0.0.5 (2024-06-08)
4
+
5
+ - --add_on option to CLI for custom snippet support
6
+
3
7
  ## 0.0.4 (2024-06-08)
4
8
 
5
9
  - Extend support for attribute rewriting
@@ -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 file_patterns: Array[String]
17
+ # @rbs args: Array[String]
17
18
  # @rbs return: void
18
- def execute(file_patterns = [])
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
 
@@ -3,5 +3,5 @@
3
3
  # rbs_inline: enabled
4
4
 
5
5
  module AlbaMigration
6
- VERSION = "0.0.4"
6
+ VERSION = "0.0.5"
7
7
  end
@@ -6,8 +6,12 @@ module AlbaMigration
6
6
  # @rbs return: void
7
7
  def self.start: (untyped args) -> void
8
8
 
9
- # @rbs file_patterns: Array[String]
9
+ # @rbs args: Array[String]
10
10
  # @rbs return: void
11
- def execute: (?Array[String] file_patterns) -> void
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alba_migration
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - ShoheiMitani