bash-merge 1.0.0 → 1.0.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: '082e2a501629dd515735c6646806e83b26d4c7a549f74b4061233b3666a0aac1'
4
- data.tar.gz: ab004d8813d572afdfee29a9b91a5e7ec7c46955ffb1ff995a321cc648e3a555
3
+ metadata.gz: 97b443df140b5c7b84dd22c38b7bb7b541d63303f1e8be31628be7eefa7a02e2
4
+ data.tar.gz: cdca3bca6ac55a7bd1ea8585bf6241bbabc804d306668cdd24d7d54a8decc088
5
5
  SHA512:
6
- metadata.gz: f2ce2ce4d992613708468896d13382434e6331703df6e11b4affb9da9f7c056403f28be182954ad696665fa473c354c9c52065aaa659b4a0eebf2a3ea217db82
7
- data.tar.gz: f5c0b4d01200b16e73d4318fe30c4107f7525db12663534735336bbe81616e84fc5cdb36d36a292bd6b53343a2f948036d2919f4d2f4c2883803ad65530c69da
6
+ metadata.gz: 847eb54d16c33e45b3e574569b437e6b12c9fc6f304395c2ef627cf7a8e4718ce9c71f2be1d8ee22eeb054b62dc59ce1fb4663a16ff6d9101b5166d8491c458a
7
+ data.tar.gz: 3fb3ee4730f717bc8d5bd3a65d5702b661bb73c342c08c9b0156ae2b8c0d64545df44eef7ec1a9e7312a8185d691864e59e71c5f206ee1aad1a34d2f588dcb59
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -30,6 +30,24 @@ Please file a bug if you notice a violation of semantic versioning.
30
30
 
31
31
  ### Security
32
32
 
33
+ ## [1.0.1] - 2026-01-01
34
+
35
+ - TAG: [v1.0.1][1.0.1t]
36
+ - COVERAGE: 100.00% -- 109/109 lines in 2 files
37
+ - BRANCH COVERAGE: 100.00% -- 28/28 branches in 2 files
38
+ - 96.46% documented
39
+
40
+ ### Changed
41
+
42
+ - **NodeWrapper**: Now inherits from `Ast::Merge::NodeWrapperBase`
43
+ - Removes ~100 lines of duplicated code (initialization, line extraction, basic methods)
44
+ - Keeps only Bash-specific type predicates and signature computation
45
+ - Adds `#node_wrapper?` method for distinguishing from `NodeTyping::Wrapper`
46
+ - **FileAnalysis error handling**: Now rescues `TreeHaver::Error` instead of `TreeHaver::NotAvailable`
47
+ - `TreeHaver::Error` inherits from `Exception`, not `StandardError`
48
+ - `TreeHaver::NotAvailable` is a subclass of `TreeHaver::Error`, so it's also caught
49
+ - Fixes parse error handling on alternative Ruby engines
50
+
33
51
  ## [1.0.0] - 2026-01-01
34
52
 
35
53
  - TAG: [v1.0.0][1.0.0t]
@@ -43,6 +61,8 @@ Please file a bug if you notice a violation of semantic versioning.
43
61
 
44
62
  ### Security
45
63
 
46
- [Unreleased]: https://github.com/kettle-rb/bash-merge/compare/v1.0.0...HEAD
64
+ [Unreleased]: https://github.com/kettle-rb/bash-merge/compare/v1.0.1...HEAD
65
+ [1.0.1]: https://github.com/kettle-rb/bash-merge/compare/v1.0.0...v1.0.1
66
+ [1.0.1t]: https://github.com/kettle-rb/bash-merge/releases/tag/v1.0.1
47
67
  [1.0.0]: https://github.com/kettle-rb/bash-merge/compare/db525d5aedd0c895422a067629118f3fa9c3c22d...v1.0.0
48
68
  [1.0.0t]: https://github.com/kettle-rb/bash-merge/tags/v1.0.0
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2025 Peter H. Boling
3
+ Copyright (c) 2025-2026 Peter H. Boling
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -685,7 +685,7 @@ See [LICENSE.txt](LICENSE.txt) for the official [Copyright Notice](https://opens
685
685
 
686
686
  <ul>
687
687
  <li>
688
- Copyright (c) 2025 Peter H. Boling, of
688
+ Copyright (c) 2025-2026 Peter H. Boling, of
689
689
  <a href="https://discord.gg/3qme4XHNKN">
690
690
  Galtzo.com
691
691
  <picture>
@@ -144,7 +144,9 @@ module Bash
144
144
  if @ast&.root_node&.has_error?
145
145
  collect_parse_errors(@ast.root_node)
146
146
  end
147
- rescue TreeHaver::NotAvailable => e
147
+ rescue TreeHaver::Error => e
148
+ # TreeHaver::Error inherits from Exception, not StandardError.
149
+ # This also catches TreeHaver::NotAvailable (subclass of Error).
148
150
  @errors << e.message
149
151
  @ast = nil
150
152
  rescue StandardError => e
@@ -5,87 +5,20 @@ module Bash
5
5
  # Wraps TreeHaver nodes with comment associations, line information, and signatures.
6
6
  # This provides a unified interface for working with Bash AST nodes during merging.
7
7
  #
8
+ # Inherits common functionality from Ast::Merge::NodeWrapperBase:
9
+ # - Source context (lines, source, comments)
10
+ # - Line info extraction
11
+ # - Basic methods: #type, #type?, #text, #content, #signature
12
+ #
8
13
  # @example Basic usage
9
14
  # parser = TreeHaver::Parser.new
10
15
  # parser.language = TreeHaver::Language.bash
11
16
  # tree = parser.parse(source)
12
17
  # wrapper = NodeWrapper.new(tree.root_node, lines: source.lines, source: source)
13
18
  # wrapper.signature # => [:program, ...]
14
- class NodeWrapper
15
- # @return [TreeHaver::Node] The wrapped tree-haver node
16
- attr_reader :node
17
-
18
- # @return [Array<Hash>] Leading comments associated with this node
19
- attr_reader :leading_comments
20
-
21
- # @return [Hash, nil] Inline/trailing comment on the same line
22
- attr_reader :inline_comment
23
-
24
- # @return [Integer] Start line (1-based)
25
- attr_reader :start_line
26
-
27
- # @return [Integer] End line (1-based)
28
- attr_reader :end_line
29
-
30
- # @return [Array<String>] Source lines
31
- attr_reader :lines
32
-
33
- # @return [String] The original source string
34
- attr_reader :source
35
-
36
- # @param node [TreeHaver::Node] tree-haver node to wrap
37
- # @param lines [Array<String>] Source lines for content extraction
38
- # @param source [String] Original source string for byte-based text extraction
39
- # @param leading_comments [Array<Hash>] Comments before this node
40
- # @param inline_comment [Hash, nil] Inline comment on the node's line
41
- def initialize(node, lines:, source: nil, leading_comments: [], inline_comment: nil)
42
- @node = node
43
- @lines = lines
44
- @source = source || lines.join("\n")
45
- @leading_comments = leading_comments
46
- @inline_comment = inline_comment
47
-
48
- # Extract line information from the tree-haver node (0-indexed to 1-indexed)
49
- if node.respond_to?(:start_point)
50
- point = node.start_point
51
- @start_line = (point.respond_to?(:row) ? point.row : point[:row]) + 1
52
- end
53
- if node.respond_to?(:end_point)
54
- point = node.end_point
55
- @end_line = (point.respond_to?(:row) ? point.row : point[:row]) + 1
56
- end
57
-
58
- # Handle edge case where end_line might be before start_line
59
- @end_line = @start_line if @start_line && @end_line && @end_line < @start_line
60
- end
61
-
62
- # Generate a signature for this node for matching purposes.
63
- # Signatures are used to identify corresponding nodes between template and destination.
64
- #
65
- # @return [Array, nil] Signature array or nil if not signaturable
66
- def signature
67
- compute_signature(@node)
68
- end
69
-
70
- # Check if this is a freeze node
71
- # @return [Boolean]
72
- def freeze_node?
73
- false
74
- end
75
-
76
- # Get the node type as a symbol
77
- # @return [Symbol]
78
- def type
79
- @node.type.to_sym
80
- end
81
-
82
- # Check if this node has a specific type
83
- # @param type_name [Symbol, String] Type to check
84
- # @return [Boolean]
85
- def type?(type_name)
86
- @node.type.to_s == type_name.to_s
87
- end
88
-
19
+ #
20
+ # @see Ast::Merge::NodeWrapperBase
21
+ class NodeWrapper < Ast::Merge::NodeWrapperBase
89
22
  # Check if this is a function definition
90
23
  # @return [Boolean]
91
24
  def function_definition?
@@ -174,18 +107,6 @@ module Bash
174
107
  nil
175
108
  end
176
109
 
177
- # Get children wrapped as NodeWrappers
178
- # @return [Array<NodeWrapper>]
179
- def children
180
- return [] unless @node.respond_to?(:each)
181
-
182
- result = []
183
- @node.each do |child|
184
- result << NodeWrapper.new(child, lines: @lines, source: @source)
185
- end
186
- result
187
- end
188
-
189
110
  # Find a child by field name
190
111
  # @param field_name [String] Field name to look for
191
112
  # @return [TreeSitter::Node, nil]
@@ -207,37 +128,13 @@ module Bash
207
128
  nil
208
129
  end
209
130
 
210
- # Get the text content for this node by extracting from source using byte positions
211
- # @return [String]
212
- def text
213
- node_text(@node)
214
- end
215
-
216
- # Extract text from a tree-sitter node using byte positions
217
- # @param ts_node [TreeSitter::Node] The tree-sitter node
218
- # @return [String]
219
- def node_text(ts_node)
220
- return "" unless ts_node.respond_to?(:start_byte) && ts_node.respond_to?(:end_byte)
221
-
222
- @source[ts_node.start_byte...ts_node.end_byte] || ""
223
- end
224
-
225
- # Get the content for this node from source lines
226
- # @return [String]
227
- def content
228
- return "" unless @start_line && @end_line
229
-
230
- (@start_line..@end_line).map { |ln| @lines[ln - 1] }.compact.join("\n")
231
- end
131
+ protected
232
132
 
233
- # String representation for debugging
234
- # @return [String]
235
- def inspect
236
- "#<#{self.class.name} type=#{@node.type} lines=#{@start_line}..#{@end_line}>"
133
+ # Override wrap_child to use Bash::Merge::NodeWrapper
134
+ def wrap_child(child)
135
+ NodeWrapper.new(child, lines: @lines, source: @source)
237
136
  end
238
137
 
239
- private
240
-
241
138
  def compute_signature(node)
242
139
  node_type = node.type.to_s
243
140
 
@@ -289,6 +186,8 @@ module Bash
289
186
  end
290
187
  end
291
188
 
189
+ private
190
+
292
191
  def extract_command_signature_context(node)
293
192
  # Extract additional context like redirections
294
193
  redirections = []
@@ -5,7 +5,7 @@ module Bash
5
5
  # Version information for Bash::Merge
6
6
  module Version
7
7
  # Current version of the bash-merge gem
8
- VERSION = "1.0.0"
8
+ VERSION = "1.0.1"
9
9
  end
10
10
  VERSION = Version::VERSION # traditional location
11
11
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bash-merge
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter H. Boling
@@ -66,7 +66,7 @@ dependencies:
66
66
  version: '2.0'
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: 2.0.6
69
+ version: 2.0.8
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '2.0'
77
77
  - - ">="
78
78
  - !ruby/object:Gem::Version
79
- version: 2.0.6
79
+ version: 2.0.8
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: version_gem
82
82
  requirement: !ruby/object:Gem::Requirement
@@ -315,10 +315,10 @@ licenses:
315
315
  - MIT
316
316
  metadata:
317
317
  homepage_uri: https://bash-merge.galtzo.com/
318
- source_code_uri: https://github.com/kettle-rb/bash-merge/tree/v1.0.0
319
- changelog_uri: https://github.com/kettle-rb/bash-merge/blob/v1.0.0/CHANGELOG.md
318
+ source_code_uri: https://github.com/kettle-rb/bash-merge/tree/v1.0.1
319
+ changelog_uri: https://github.com/kettle-rb/bash-merge/blob/v1.0.1/CHANGELOG.md
320
320
  bug_tracker_uri: https://github.com/kettle-rb/bash-merge/issues
321
- documentation_uri: https://www.rubydoc.info/gems/bash-merge/1.0.0
321
+ documentation_uri: https://www.rubydoc.info/gems/bash-merge/1.0.1
322
322
  funding_uri: https://github.com/sponsors/pboling
323
323
  wiki_uri: https://github.com/kettle-rb/bash-merge/wiki
324
324
  news_uri: https://www.railsbling.com/tags/bash-merge
metadata.gz.sig CHANGED
Binary file