ast-merge 4.0.3 → 4.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
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +71 -1
- data/README.md +16 -16
- data/lib/ast/merge/rspec/dependency_tags.rb +24 -129
- data/lib/ast/merge/rspec/dependency_tags_config.rb +74 -0
- data/lib/ast/merge/rspec/dependency_tags_helpers.rb +56 -0
- data/lib/ast/merge/rspec/merge_gem_registry.rb +32 -2
- data/lib/ast/merge/rspec/setup.rb +24 -0
- data/lib/ast/merge/rspec/shared_examples/conflict_resolver_base.rb +74 -0
- data/lib/ast/merge/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +10 -7
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 79568b485368737ba2d8ca559d968d4183e79f855f01a7dff784679829f0ecf2
|
|
4
|
+
data.tar.gz: e8a2c6775409fdafdc4c7c10dd35d1ebdc85b23d38a876dd8658fb3017bd1d7e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4069151d47cd524740fb23cfd86a1d9de044d5b779afce7faadf2e4c096a393c8ea1b7c30b81f798da966f917029db2bc15f4251c034c811567ea5864e9a8fbd
|
|
7
|
+
data.tar.gz: 9f0d68f5a0050d1b796f3865491efd436d2737aac07a59e1274d8ab80f1f53502e76be020cb4010d7f009e1fd4cae3942926409ff8fec89bdf854ae72af0109d
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/CHANGELOG.md
CHANGED
|
@@ -30,6 +30,72 @@ Please file a bug if you notice a violation of semantic versioning.
|
|
|
30
30
|
|
|
31
31
|
### Security
|
|
32
32
|
|
|
33
|
+
## [4.0.5] - 2026-02-01
|
|
34
|
+
|
|
35
|
+
- TAG: [v4.0.5][4.0.5t]
|
|
36
|
+
- COVERAGE: 96.37% -- 2552/2648 lines in 50 files
|
|
37
|
+
- BRANCH COVERAGE: 87.22% -- 812/931 branches in 50 files
|
|
38
|
+
- 98.81% documented
|
|
39
|
+
|
|
40
|
+
### Added
|
|
41
|
+
|
|
42
|
+
- More shared examples for ConflictResolverBase
|
|
43
|
+
|
|
44
|
+
### Changed
|
|
45
|
+
|
|
46
|
+
- tree_haver v5.0.3
|
|
47
|
+
- improve robustness of tests
|
|
48
|
+
|
|
49
|
+
### Fixed
|
|
50
|
+
|
|
51
|
+
- Documentation fixes related to gem family section
|
|
52
|
+
|
|
53
|
+
## [4.0.4] - 2026-01-20
|
|
54
|
+
|
|
55
|
+
- TAG: [v4.0.4][4.0.4t]
|
|
56
|
+
- COVERAGE: 96.37% -- 2552/2648 lines in 50 files
|
|
57
|
+
- BRANCH COVERAGE: 87.22% -- 812/931 branches in 50 files
|
|
58
|
+
- 98.81% documented
|
|
59
|
+
|
|
60
|
+
### Added
|
|
61
|
+
|
|
62
|
+
- **RSpec Split Loading Pattern**: New files for granular RSpec dependency tag loading
|
|
63
|
+
- `lib/ast/merge/rspec/setup.rb` - Loads only registry and helper classes (no RSpec configuration)
|
|
64
|
+
- `lib/ast/merge/rspec/dependency_tags_helpers.rb` - DependencyTags helper module
|
|
65
|
+
- `lib/ast/merge/rspec/dependency_tags_config.rb` - RSpec.configure block with exclusion filters
|
|
66
|
+
- Enables registering known gems before RSpec.configure runs (solving catch-22 problem)
|
|
67
|
+
- Required for ast-merge test suite to preserve SimpleCov coverage
|
|
68
|
+
- Required for merge gems that register other merge gems as dependencies
|
|
69
|
+
- **`Ast::Merge::RSpec::MergeGemRegistry.force_check_availability!`**: Deferred availability checking for accurate test coverage
|
|
70
|
+
- Called automatically in `before(:suite)` hook AFTER SimpleCov is loaded
|
|
71
|
+
- Prevents premature gem loading that would bypass coverage instrumentation
|
|
72
|
+
- Ensures accurate coverage reporting in merge gem test suites
|
|
73
|
+
|
|
74
|
+
### Changed
|
|
75
|
+
|
|
76
|
+
- **RSpec Dependency Tags**: Fixed exclusion filter setup to properly skip tests when optional gems unavailable
|
|
77
|
+
- Exclusion filters now set during `RSpec.configure` (not in `before(:suite)` which runs too late)
|
|
78
|
+
- Fixed RSpec API usage: `config.filter_run_excluding tag => true` (not `[tag] = true`)
|
|
79
|
+
- `ast-merge` uses split loading pattern in `spec/spec_helper.rb` and `spec/config/tree_haver.rb`
|
|
80
|
+
- `markdown-merge` uses split pattern (registers `:commonmarker_merge`, `:markly_merge`)
|
|
81
|
+
- `markly-merge` uses split pattern (registers `:prism_merge`)
|
|
82
|
+
- `commonmarker-merge` uses simple pattern (no registrations needed)
|
|
83
|
+
|
|
84
|
+
### Fixed
|
|
85
|
+
|
|
86
|
+
- **Test coverage accuracy**: Fixed premature gem loading that bypassed SimpleCov instrumentation
|
|
87
|
+
- `MergeGemRegistry.registered_gems` now returns ONLY explicitly registered gems, not all KNOWN_GEMS
|
|
88
|
+
- RSpec exclusion filters are configured in `before(:suite)` hook after `force_check_availability!` runs
|
|
89
|
+
- This ensures gems are loaded AFTER SimpleCov sets up coverage instrumentation
|
|
90
|
+
- Previously, commonmarker-merge reported only 11 lines covered when it should have been far more
|
|
91
|
+
- **RSpec Dependency Tags**: Tests with tags like `:markdown_merge`, `:markly_merge` now properly skip when those gems aren't available
|
|
92
|
+
- Fixed 141 test failures caused by tests running without required gems loaded
|
|
93
|
+
- Removed `require` statements from integration specs - dependency tags handle gem loading
|
|
94
|
+
- Fixed tag usage: Tests using `Markdown::Merge::PartialTemplateMerger` with `:markly` backend now correctly tagged with both `:markdown_merge` and `:markly_merge`
|
|
95
|
+
- **Thread-Safety Spec**: Fixed JRuby concurrency test failure in `NodeTyping::Normalizer#canonical_type`
|
|
96
|
+
- Changed from unsynchronized `Array` to thread-safe `Queue` for collecting results from concurrent threads
|
|
97
|
+
- Eliminates `ConcurrencyError: Detected invalid array contents due to unsynchronized modifications`
|
|
98
|
+
|
|
33
99
|
## [4.0.3] - 2026-01-19
|
|
34
100
|
|
|
35
101
|
- TAG: [v4.0.3][4.0.3t]
|
|
@@ -687,7 +753,11 @@ Please file a bug if you notice a violation of semantic versioning.
|
|
|
687
753
|
|
|
688
754
|
- Initial release
|
|
689
755
|
|
|
690
|
-
[Unreleased]: https://github.com/kettle-rb/ast-merge/compare/v4.0.
|
|
756
|
+
[Unreleased]: https://github.com/kettle-rb/ast-merge/compare/v4.0.5...HEAD
|
|
757
|
+
[4.0.5]: https://github.com/kettle-rb/ast-merge/compare/v4.0.4...v4.0.5
|
|
758
|
+
[4.0.5t]: https://github.com/kettle-rb/ast-merge/releases/tag/v4.0.5
|
|
759
|
+
[4.0.4]: https://github.com/kettle-rb/ast-merge/compare/v4.0.3...v4.0.4
|
|
760
|
+
[4.0.4t]: https://github.com/kettle-rb/ast-merge/releases/tag/v4.0.4
|
|
691
761
|
[4.0.3]: https://github.com/kettle-rb/ast-merge/compare/v4.0.2...v4.0.3
|
|
692
762
|
[4.0.3t]: https://github.com/kettle-rb/ast-merge/releases/tag/v4.0.3
|
|
693
763
|
[4.0.2]: https://github.com/kettle-rb/ast-merge/compare/v4.0.1...v4.0.2
|
data/README.md
CHANGED
|
@@ -60,21 +60,21 @@ Ast::Merge is **not typically used directly** - instead, use one of the format-s
|
|
|
60
60
|
|
|
61
61
|
The `*-merge` gem family provides intelligent, AST-based merging for various file formats. At the foundation is [tree_haver][tree_haver], which provides a unified cross-Ruby parsing API that works seamlessly across MRI, JRuby, and TruffleRuby.
|
|
62
62
|
|
|
63
|
-
| Gem |
|
|
64
|
-
|
|
65
|
-
| [tree_haver][tree_haver] |
|
|
66
|
-
| [ast-merge][ast-merge] |
|
|
67
|
-
| [bash-merge][bash-merge] |
|
|
68
|
-
| [commonmarker-merge][commonmarker-merge] | [![Version][commonmarker-merge-gem-i]][commonmarker-merge-gem]
|
|
69
|
-
| [dotenv-merge][dotenv-merge] |
|
|
70
|
-
| [json-merge][json-merge] |
|
|
71
|
-
| [jsonc-merge][jsonc-merge] |
|
|
72
|
-
| [markdown-merge][markdown-merge] |
|
|
73
|
-
| [markly-merge][markly-merge] |
|
|
74
|
-
| [prism-merge][prism-merge] |
|
|
75
|
-
| [psych-merge][psych-merge] |
|
|
76
|
-
| [rbs-merge][rbs-merge] |
|
|
77
|
-
| [toml-merge][toml-merge] |
|
|
63
|
+
| Gem | Version / CI | Language<br>/ Format | Parser Backend(s) | Description |
|
|
64
|
+
|------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------:|----------------------|-------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------|
|
|
65
|
+
| [tree_haver][tree_haver] | [![Version][tree_haver-gem-i]][tree_haver-gem] <br/> [![CI][tree_haver-ci-i]][tree_haver-ci] | Multi | Supported Backends: MRI C, Rust, FFI, Java, Prism, Psych, Commonmarker, Markly, Citrus, Parslet | **Foundation**: Cross-Ruby adapter for parsing libraries (like Faraday for HTTP) |
|
|
66
|
+
| [ast-merge][ast-merge] | [![Version][ast-merge-gem-i]][ast-merge-gem] <br/> [![CI][ast-merge-ci-i]][ast-merge-ci] | Text | internal | **Infrastructure**: Shared base classes and merge logic for all `*-merge` gems |
|
|
67
|
+
| [bash-merge][bash-merge] | [![Version][bash-merge-gem-i]][bash-merge-gem] <br/> [![CI][bash-merge-ci-i]][bash-merge-ci] | Bash | [tree-sitter-bash][ts-bash] (via tree_haver) | Smart merge for Bash scripts |
|
|
68
|
+
| [commonmarker-merge][commonmarker-merge] | [![Version][commonmarker-merge-gem-i]][commonmarker-merge-gem] <br/> [![CI][commonmarker-merge-ci-i]][commonmarker-merge-ci] | Markdown | [Commonmarker][commonmarker] (via tree_haver) | Smart merge for Markdown (CommonMark via comrak Rust) |
|
|
69
|
+
| [dotenv-merge][dotenv-merge] | [![Version][dotenv-merge-gem-i]][dotenv-merge-gem] <br/> [![CI][dotenv-merge-ci-i]][dotenv-merge-ci] | Dotenv | internal | Smart merge for `.env` files |
|
|
70
|
+
| [json-merge][json-merge] | [![Version][json-merge-gem-i]][json-merge-gem] <br/> [![CI][json-merge-ci-i]][json-merge-ci] | JSON | [tree-sitter-json][ts-json] (via tree_haver) | Smart merge for JSON files |
|
|
71
|
+
| [jsonc-merge][jsonc-merge] | [![Version][jsonc-merge-gem-i]][jsonc-merge-gem] <br/> [![CI][jsonc-merge-ci-i]][jsonc-merge-ci] | JSONC | [tree-sitter-jsonc][ts-jsonc] (via tree_haver) | ⚠️ Proof of concept; Smart merge for JSON with Comments |
|
|
72
|
+
| [markdown-merge][markdown-merge] | [![Version][markdown-merge-gem-i]][markdown-merge-gem] <br/> [![CI][markdown-merge-ci-i]][markdown-merge-ci] | Markdown | [Commonmarker][commonmarker] / [Markly][markly] (via tree_haver), [Parslet][parslet] | **Foundation**: Shared base for Markdown mergers with inner code block merging |
|
|
73
|
+
| [markly-merge][markly-merge] | [![Version][markly-merge-gem-i]][markly-merge-gem] <br/> [![CI][markly-merge-ci-i]][markly-merge-ci] | Markdown | [Markly][markly] (via tree_haver) | Smart merge for Markdown (CommonMark via cmark-gfm C) |
|
|
74
|
+
| [prism-merge][prism-merge] | [![Version][prism-merge-gem-i]][prism-merge-gem] <br/> [![CI][prism-merge-ci-i]][prism-merge-ci] | Ruby | [Prism][prism] (`prism` std lib gem) | Smart merge for Ruby source files |
|
|
75
|
+
| [psych-merge][psych-merge] | [![Version][psych-merge-gem-i]][psych-merge-gem] <br/> [![CI][psych-merge-ci-i]][psych-merge-ci] | YAML | [Psych][psych] (`psych` std lib gem) | Smart merge for YAML files |
|
|
76
|
+
| [rbs-merge][rbs-merge] | [![Version][rbs-merge-gem-i]][rbs-merge-gem] <br/> [![CI][rbs-merge-ci-i]][rbs-merge-ci] | RBS | [tree-sitter-bash][ts-rbs] (via tree_haver), [RBS][rbs] (`rbs` std lib gem) | Smart merge for Ruby type signatures |
|
|
77
|
+
| [toml-merge][toml-merge] | [![Version][toml-merge-gem-i]][toml-merge-gem] <br/> [![CI][toml-merge-ci-i]][toml-merge-ci] | TOML | [Parslet + toml][toml], [Citrus + toml-rb][toml-rb], [tree-sitter-toml][ts-toml] (all via tree_haver) | Smart merge for TOML files |
|
|
78
78
|
|
|
79
79
|
#### Backend Platform Compatibility
|
|
80
80
|
|
|
@@ -1106,7 +1106,7 @@ Thanks for RTFM. ☺️
|
|
|
1106
1106
|
[📌gitmoji]: https://gitmoji.dev
|
|
1107
1107
|
[📌gitmoji-img]: https://img.shields.io/badge/gitmoji_commits-%20%F0%9F%98%9C%20%F0%9F%98%8D-34495e.svg?style=flat-square
|
|
1108
1108
|
[🧮kloc]: https://www.youtube.com/watch?v=dQw4w9WgXcQ
|
|
1109
|
-
[🧮kloc-img]: https://img.shields.io/badge/KLOC-2.
|
|
1109
|
+
[🧮kloc-img]: https://img.shields.io/badge/KLOC-2.648-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
|
|
1110
1110
|
[🔐security]: SECURITY.md
|
|
1111
1111
|
[🔐security-img]: https://img.shields.io/badge/security-policy-259D6C.svg?style=flat
|
|
1112
1112
|
[📄copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year
|
|
@@ -1,140 +1,35 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
#
|
|
3
|
+
# Ast::Merge RSpec Dependency Tags - Combined Loader
|
|
4
|
+
#
|
|
5
|
+
# This file provides the standard entry point for RSpec dependency tags.
|
|
6
|
+
# It loads both the helper module and the RSpec configuration.
|
|
7
|
+
#
|
|
8
|
+
# **When to use the split loading pattern:**
|
|
9
|
+
# - ast-merge: MUST use split pattern (to preserve SimpleCov coverage of ast-merge itself)
|
|
10
|
+
# - Merge gems that register other merge gems: MUST use split pattern (to avoid catch-22)
|
|
11
|
+
# - Other gems: Can use simple `require "ast/merge/rspec"` (this file)
|
|
6
12
|
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
13
|
+
# @example Simple pattern (for gems that DON'T register other gems)
|
|
14
|
+
# # In spec/config/tree_haver.rb:
|
|
15
|
+
# require "ast-merge"
|
|
16
|
+
# require "ast/merge/rspec" # Loads everything
|
|
9
17
|
#
|
|
10
|
-
# @example
|
|
11
|
-
#
|
|
18
|
+
# @example Split pattern (for ast-merge or gems that register other merge gems)
|
|
19
|
+
# # In spec/config/tree_haver.rb:
|
|
20
|
+
# require "ast-merge"
|
|
21
|
+
# require "ast/merge/rspec/setup" # Load registry/helpers only
|
|
22
|
+
# Ast::Merge::RSpec::MergeGemRegistry.register_known_gems(:markly_merge)
|
|
23
|
+
# require "ast/merge/rspec/dependency_tags_config" # Load RSpec config
|
|
24
|
+
# require "ast/merge/rspec/shared_examples"
|
|
12
25
|
#
|
|
13
26
|
# @example Usage in specs
|
|
14
27
|
# it "requires markly-merge", :markly_merge do
|
|
15
28
|
# # This test only runs when markly-merge is available
|
|
16
29
|
# end
|
|
17
|
-
#
|
|
18
|
-
# it "requires prism-merge", :prism_merge do
|
|
19
|
-
# # This test only runs when prism-merge is available
|
|
20
|
-
# end
|
|
21
|
-
#
|
|
22
|
-
# == Dynamic Tag Registration
|
|
23
|
-
#
|
|
24
|
-
# Merge gems register themselves with MergeGemRegistry, which automatically:
|
|
25
|
-
# - Defines `*_available?` methods on DependencyTags
|
|
26
|
-
# - Configures RSpec exclusion filters for the tag
|
|
27
|
-
# - Supports negated tags (`:not_*`)
|
|
28
|
-
#
|
|
29
|
-
# @example How merge gems register (in their lib file)
|
|
30
|
-
# Ast::Merge::RSpec::MergeGemRegistry.register(
|
|
31
|
-
# :markly_merge,
|
|
32
|
-
# require_path: "markly/merge",
|
|
33
|
-
# merger_class: "Markly::Merge::SmartMerger",
|
|
34
|
-
# test_source: "# Test\n\nParagraph",
|
|
35
|
-
# category: :markdown
|
|
36
|
-
# )
|
|
37
|
-
#
|
|
38
|
-
# == Built-in Composite Tags
|
|
39
|
-
#
|
|
40
|
-
# [:any_markdown_merge]
|
|
41
|
-
# At least one markdown merge gem is available (category: :markdown).
|
|
42
|
-
|
|
43
|
-
module Ast
|
|
44
|
-
module Merge
|
|
45
|
-
module RSpec
|
|
46
|
-
# Dependency detection helpers for conditional test execution
|
|
47
|
-
module DependencyTags
|
|
48
|
-
class << self
|
|
49
|
-
# ============================================================
|
|
50
|
-
# Composite Availability Checks
|
|
51
|
-
# ============================================================
|
|
52
|
-
|
|
53
|
-
# Check if at least one markdown merge gem is available
|
|
54
|
-
#
|
|
55
|
-
# @return [Boolean] true if any markdown merge gem works
|
|
56
|
-
def any_markdown_merge_available?
|
|
57
|
-
MergeGemRegistry.gems_by_category(:markdown).any? do |tag|
|
|
58
|
-
MergeGemRegistry.available?(tag)
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
# ============================================================
|
|
63
|
-
# Summary and Reset
|
|
64
|
-
# ============================================================
|
|
65
|
-
|
|
66
|
-
# Get a summary of available dependencies (for debugging)
|
|
67
|
-
#
|
|
68
|
-
# @return [Hash{Symbol => Boolean}] map of dependency name to availability
|
|
69
|
-
def summary
|
|
70
|
-
result = MergeGemRegistry.summary
|
|
71
|
-
result[:any_markdown_merge] = any_markdown_merge_available?
|
|
72
|
-
result
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
# Reset all memoized availability checks
|
|
76
|
-
#
|
|
77
|
-
# @return [void]
|
|
78
|
-
def reset!
|
|
79
|
-
MergeGemRegistry.reset_availability!
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
# NOTE: Known merge gems (KNOWN_GEMS) are NOT automatically registered here.
|
|
88
|
-
# Each test suite should explicitly register only the gems it needs in its
|
|
89
|
-
# spec/config/tree_haver.rb file using:
|
|
90
|
-
#
|
|
91
|
-
# Ast::Merge::RSpec::MergeGemRegistry.register_known_gems(:gem1, :gem2, ...)
|
|
92
|
-
#
|
|
93
|
-
# This avoids wasting time registering gems that aren't needed for a particular
|
|
94
|
-
# test suite. Only the gems that are actually required for testing should be registered.
|
|
95
|
-
#
|
|
96
|
-
# Example for a gem that needs to test with optional markdown backends:
|
|
97
|
-
# Ast::Merge::RSpec::MergeGemRegistry.register_known_gems(
|
|
98
|
-
# :commonmarker_merge,
|
|
99
|
-
# :markly_merge
|
|
100
|
-
# )
|
|
101
|
-
|
|
102
|
-
# Configure RSpec with dependency-based exclusion filters
|
|
103
|
-
RSpec.configure do |config|
|
|
104
|
-
deps = Ast::Merge::RSpec::DependencyTags
|
|
105
|
-
registry = Ast::Merge::RSpec::MergeGemRegistry
|
|
106
|
-
|
|
107
|
-
config.before(:suite) do
|
|
108
|
-
# Print dependency summary if AST_MERGE_DEBUG is set
|
|
109
|
-
unless ENV.fetch("AST_MERGE_DEBUG", "false").casecmp?("false")
|
|
110
|
-
puts "\n=== Ast::Merge Test Dependencies ==="
|
|
111
|
-
deps.summary.each do |dep, available|
|
|
112
|
-
status = available ? "✓ available" : "✗ not available"
|
|
113
|
-
puts " #{dep}: #{status}"
|
|
114
|
-
end
|
|
115
|
-
puts "=====================================\n"
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
# ============================================================
|
|
120
|
-
# Dynamic Merge Gem Tags
|
|
121
|
-
# ============================================================
|
|
122
|
-
# Tags are configured dynamically based on what's registered in MergeGemRegistry.
|
|
123
|
-
# Each merge gem registers itself, and exclusion filters are set up automatically.
|
|
124
|
-
|
|
125
|
-
registry.registered_gems.each do |tag|
|
|
126
|
-
# Positive tag: run when gem IS available
|
|
127
|
-
config.filter_run_excluding(tag => true) unless registry.available?(tag)
|
|
128
|
-
|
|
129
|
-
# Negated tag: run when gem is NOT available
|
|
130
|
-
negated_tag = :"not_#{tag}"
|
|
131
|
-
config.filter_run_excluding(negated_tag => true) if registry.available?(tag)
|
|
132
|
-
end
|
|
133
30
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
# ============================================================
|
|
31
|
+
# Load the helper module (DependencyTags methods)
|
|
32
|
+
require_relative "dependency_tags_helpers"
|
|
137
33
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
end
|
|
34
|
+
# Load the RSpec configuration (exclusion filters)
|
|
35
|
+
require_relative "dependency_tags_config"
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "dependency_tags_helpers"
|
|
4
|
+
|
|
5
|
+
# Ast::Merge RSpec Dependency Tags - RSpec Configuration
|
|
6
|
+
#
|
|
7
|
+
# This file configures RSpec with dependency-based exclusion filters.
|
|
8
|
+
# It should be loaded AFTER gems have been registered with MergeGemRegistry.
|
|
9
|
+
#
|
|
10
|
+
# @example Loading in spec_helper.rb (for merge gem test suites)
|
|
11
|
+
# require "ast/merge/rspec" # Loads this file automatically
|
|
12
|
+
#
|
|
13
|
+
# @example For ast-merge test suite (split loading)
|
|
14
|
+
# # In spec_helper.rb BEFORE requiring ast-merge:
|
|
15
|
+
# require "ast/merge/rspec/setup"
|
|
16
|
+
#
|
|
17
|
+
# # Register known gems:
|
|
18
|
+
# Ast::Merge::RSpec::MergeGemRegistry.register_known_gems(:markly_merge)
|
|
19
|
+
#
|
|
20
|
+
# # Then AFTER requiring ast-merge, load config:
|
|
21
|
+
# require "ast/merge/rspec/dependency_tags_config"
|
|
22
|
+
|
|
23
|
+
# Configure RSpec with dependency-based exclusion filters
|
|
24
|
+
RSpec.configure do |config|
|
|
25
|
+
deps = Ast::Merge::RSpec::DependencyTags
|
|
26
|
+
registry = Ast::Merge::RSpec::MergeGemRegistry
|
|
27
|
+
|
|
28
|
+
# CRITICAL: Exclusion filters MUST be set during RSpec.configure, not in before(:suite)
|
|
29
|
+
# because RSpec filters tests before before(:suite) runs!
|
|
30
|
+
|
|
31
|
+
# Force availability checking for all registered gems
|
|
32
|
+
# This loads the gems NOW during configuration, which is after SimpleCov has instrumented
|
|
33
|
+
# the code (since this file is required AFTER ast-merge loads in spec_helper.rb)
|
|
34
|
+
registry.force_check_availability!
|
|
35
|
+
|
|
36
|
+
# Now configure exclusion filters based on actual availability
|
|
37
|
+
registry.registered_gems.each do |tag|
|
|
38
|
+
if registry.available?(tag)
|
|
39
|
+
# Gem is available - exclude tests tagged with :not_tag
|
|
40
|
+
negated_tag = :"not_#{tag}"
|
|
41
|
+
config.filter_run_excluding(negated_tag => true)
|
|
42
|
+
else
|
|
43
|
+
# Gem is NOT available - exclude tests tagged with :tag
|
|
44
|
+
config.filter_run_excluding(tag => true)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Configure composite tags (these also trigger gem loading, so must be here)
|
|
49
|
+
if deps.any_markdown_merge_available?
|
|
50
|
+
config.filter_run_excluding(not_any_markdown_merge: true)
|
|
51
|
+
else
|
|
52
|
+
config.filter_run_excluding(any_markdown_merge: true)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Print dependency summary if AST_MERGE_DEBUG is set
|
|
56
|
+
config.before(:suite) do
|
|
57
|
+
unless ENV.fetch("AST_MERGE_DEBUG", "false").casecmp?("false")
|
|
58
|
+
puts "\n=== Ast::Merge Test Dependencies ==="
|
|
59
|
+
deps.summary.each do |dep, available|
|
|
60
|
+
status = available ? "✓ available" : "✗ not available"
|
|
61
|
+
puts " #{dep}: #{status}"
|
|
62
|
+
end
|
|
63
|
+
puts "=====================================\n"
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# ============================================================
|
|
68
|
+
# Dynamic Merge Gem Tags - Initial Setup
|
|
69
|
+
# ============================================================
|
|
70
|
+
# Note: We don't set exclusions here because that would require checking
|
|
71
|
+
# availability (loading gems) before SimpleCov. The actual exclusions are
|
|
72
|
+
# set in the before(:suite) hook above after force_check_availability! runs.
|
|
73
|
+
# This includes composite tags like :any_markdown_merge.
|
|
74
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "merge_gem_registry"
|
|
4
|
+
|
|
5
|
+
# Ast::Merge RSpec Dependency Tags - Helper Module Only
|
|
6
|
+
#
|
|
7
|
+
# This module provides dependency detection helpers for conditional test execution
|
|
8
|
+
# in the ast-merge gem family. It uses MergeGemRegistry for dynamic merge gem detection.
|
|
9
|
+
#
|
|
10
|
+
# NOTE: This file contains ONLY the helper module, not the RSpec configuration.
|
|
11
|
+
# The RSpec configuration is in dependency_tags_config.rb and is loaded by
|
|
12
|
+
# ast/merge/rspec (the full entry point).
|
|
13
|
+
|
|
14
|
+
module Ast
|
|
15
|
+
module Merge
|
|
16
|
+
module RSpec
|
|
17
|
+
# Dependency detection helpers for conditional test execution
|
|
18
|
+
module DependencyTags
|
|
19
|
+
class << self
|
|
20
|
+
# ============================================================
|
|
21
|
+
# Composite Availability Checks
|
|
22
|
+
# ============================================================
|
|
23
|
+
|
|
24
|
+
# Check if at least one markdown merge gem is available
|
|
25
|
+
#
|
|
26
|
+
# @return [Boolean] true if any markdown merge gem works
|
|
27
|
+
def any_markdown_merge_available?
|
|
28
|
+
MergeGemRegistry.gems_by_category(:markdown).any? do |tag|
|
|
29
|
+
MergeGemRegistry.available?(tag)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# ============================================================
|
|
34
|
+
# Summary and Reset
|
|
35
|
+
# ============================================================
|
|
36
|
+
|
|
37
|
+
# Get a summary of available dependencies (for debugging)
|
|
38
|
+
#
|
|
39
|
+
# @return [Hash{Symbol => Boolean}] map of dependency name to availability
|
|
40
|
+
def summary
|
|
41
|
+
result = MergeGemRegistry.summary
|
|
42
|
+
result[:any_markdown_merge] = any_markdown_merge_available?
|
|
43
|
+
result
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Reset all memoized availability checks
|
|
47
|
+
#
|
|
48
|
+
# @return [void]
|
|
49
|
+
def reset!
|
|
50
|
+
MergeGemRegistry.reset_availability!
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -295,12 +295,17 @@ module Ast
|
|
|
295
295
|
end
|
|
296
296
|
end
|
|
297
297
|
|
|
298
|
-
# Get all registered gem tag names
|
|
298
|
+
# Get all explicitly registered gem tag names
|
|
299
|
+
#
|
|
300
|
+
# This returns ONLY gems that were explicitly registered via register() or
|
|
301
|
+
# register_known_gems(), NOT all gems in KNOWN_GEMS. This prevents premature
|
|
302
|
+
# loading of gems during RSpec tag setup, which would happen before SimpleCov
|
|
303
|
+
# and ruin coverage reporting.
|
|
299
304
|
#
|
|
300
305
|
# @return [Array<Symbol>] list of registered tag names
|
|
301
306
|
def registered_gems
|
|
302
307
|
@mutex.synchronize do
|
|
303
|
-
|
|
308
|
+
@registry.keys
|
|
304
309
|
end
|
|
305
310
|
end
|
|
306
311
|
|
|
@@ -316,6 +321,31 @@ module Ast
|
|
|
316
321
|
end
|
|
317
322
|
end
|
|
318
323
|
|
|
324
|
+
# Force availability checking for all registered gems
|
|
325
|
+
#
|
|
326
|
+
# This method should be called AFTER SimpleCov is loaded (typically at the end
|
|
327
|
+
# of spec_helper.rb) to trigger gem loading and availability checking. Calling
|
|
328
|
+
# this ensures RSpec exclusion filters are properly configured based on which
|
|
329
|
+
# gems are actually available.
|
|
330
|
+
#
|
|
331
|
+
# This is necessary because register_known_gems() only registers gems without
|
|
332
|
+
# checking availability. The actual availability check (which requires loading
|
|
333
|
+
# the gem) must happen AFTER coverage instrumentation is set up.
|
|
334
|
+
#
|
|
335
|
+
# @return [void]
|
|
336
|
+
#
|
|
337
|
+
# @example At the end of spec_helper.rb (after SimpleCov loads)
|
|
338
|
+
# # Force availability checking now that coverage is instrumented
|
|
339
|
+
# Ast::Merge::RSpec::MergeGemRegistry.force_check_availability!
|
|
340
|
+
def force_check_availability!
|
|
341
|
+
registered_gems.each do |tag|
|
|
342
|
+
# This will trigger gem_works? which loads the gem
|
|
343
|
+
# Results are cached, so subsequent calls are fast
|
|
344
|
+
available?(tag)
|
|
345
|
+
end
|
|
346
|
+
nil
|
|
347
|
+
end
|
|
348
|
+
|
|
319
349
|
# Get registration info for a gem
|
|
320
350
|
#
|
|
321
351
|
# @param tag_name [Symbol] the tag name
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Ast::Merge RSpec Setup (Registry Only)
|
|
4
|
+
#
|
|
5
|
+
# This file loads ONLY the registry and helper classes without configuring RSpec.
|
|
6
|
+
# It's used in the ast-merge test suite to allow registering known gems before
|
|
7
|
+
# SimpleCov loads the library code.
|
|
8
|
+
#
|
|
9
|
+
# DO NOT load this in merge gem test suites - they should use require "ast/merge/rspec"
|
|
10
|
+
# which includes the full RSpec configuration.
|
|
11
|
+
#
|
|
12
|
+
# @example Loading in ast-merge's spec_helper.rb (BEFORE requiring ast-merge)
|
|
13
|
+
# require "ast/merge/rspec/setup"
|
|
14
|
+
#
|
|
15
|
+
# # Now you can register known gems:
|
|
16
|
+
# Ast::Merge::RSpec::MergeGemRegistry.register_known_gems(:markly_merge, :prism_merge)
|
|
17
|
+
#
|
|
18
|
+
# @example For merge gem test suites (normal pattern)
|
|
19
|
+
# # Don't use this file! Use the full loader instead:
|
|
20
|
+
# require "ast/merge/rspec" # Loads setup + RSpec configuration
|
|
21
|
+
|
|
22
|
+
# Load only the registry - no RSpec configuration
|
|
23
|
+
require_relative "merge_gem_registry"
|
|
24
|
+
require_relative "dependency_tags_helpers"
|
|
@@ -155,6 +155,18 @@ RSpec.shared_examples("Ast::Merge::ConflictResolverBase") do
|
|
|
155
155
|
it "has #add_template_only_nodes reader" do
|
|
156
156
|
expect(resolver).to(respond_to(:add_template_only_nodes))
|
|
157
157
|
end
|
|
158
|
+
|
|
159
|
+
it "has #remove_template_missing_nodes reader" do
|
|
160
|
+
expect(resolver).to(respond_to(:remove_template_missing_nodes))
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
it "has #recursive reader" do
|
|
164
|
+
expect(resolver).to(respond_to(:recursive))
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
it "has #match_refiner reader" do
|
|
168
|
+
expect(resolver).to(respond_to(:match_refiner))
|
|
169
|
+
end
|
|
158
170
|
end
|
|
159
171
|
|
|
160
172
|
describe "#resolve" do
|
|
@@ -199,6 +211,68 @@ RSpec.shared_examples("Ast::Merge::ConflictResolverBase") do
|
|
|
199
211
|
expect(resolver.freeze_node?(node)).to(be(false))
|
|
200
212
|
end
|
|
201
213
|
end
|
|
214
|
+
|
|
215
|
+
describe "per-node-type preferences" do
|
|
216
|
+
let(:template_analysis) { build_mock_analysis.call }
|
|
217
|
+
let(:dest_analysis) { build_mock_analysis.call }
|
|
218
|
+
|
|
219
|
+
context "with hash preferences" do
|
|
220
|
+
let(:resolver) do
|
|
221
|
+
build_conflict_resolver.call(
|
|
222
|
+
preference: {default: :destination, special: :template},
|
|
223
|
+
template_analysis: template_analysis,
|
|
224
|
+
dest_analysis: dest_analysis,
|
|
225
|
+
)
|
|
226
|
+
end
|
|
227
|
+
let(:typed_template_node) { Ast::Merge::NodeTyping.with_merge_type(Object.new, :special) }
|
|
228
|
+
let(:typed_dest_node) { Ast::Merge::NodeTyping.with_merge_type(Object.new, :special) }
|
|
229
|
+
let(:untyped_node) { Object.new }
|
|
230
|
+
|
|
231
|
+
it "reports per-type preference enabled" do
|
|
232
|
+
expect(resolver.per_type_preference?).to(be(true))
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
it "returns default preference for untyped nodes" do
|
|
236
|
+
expect(resolver.preference_for_node(untyped_node)).to(eq(:destination))
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
it "returns per-type preference for typed nodes" do
|
|
240
|
+
expect(resolver.preference_for_node(typed_template_node)).to(eq(:template))
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
it "prefers typed template nodes when configured" do
|
|
244
|
+
resolution = resolver.send(:preference_resolution, template_node: typed_template_node, dest_node: untyped_node)
|
|
245
|
+
expect(resolution[:source]).to(eq(:template))
|
|
246
|
+
expect(resolution[:decision]).to(eq(conflict_resolver_class::DECISION_TEMPLATE))
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
it "prefers typed destination nodes when configured" do
|
|
250
|
+
resolver_with_dest = build_conflict_resolver.call(
|
|
251
|
+
preference: {default: :template, special: :destination},
|
|
252
|
+
template_analysis: template_analysis,
|
|
253
|
+
dest_analysis: dest_analysis,
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
resolution = resolver_with_dest.send(:preference_resolution, template_node: untyped_node, dest_node: typed_dest_node)
|
|
257
|
+
expect(resolution[:source]).to(eq(:destination))
|
|
258
|
+
expect(resolution[:decision]).to(eq(conflict_resolver_class::DECISION_DESTINATION))
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
context "with scalar preference" do
|
|
263
|
+
let(:resolver) do
|
|
264
|
+
build_conflict_resolver.call(
|
|
265
|
+
preference: :template,
|
|
266
|
+
template_analysis: template_analysis,
|
|
267
|
+
dest_analysis: dest_analysis,
|
|
268
|
+
)
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
it "reports per-type preference disabled" do
|
|
272
|
+
expect(resolver.per_type_preference?).to(be(false))
|
|
273
|
+
end
|
|
274
|
+
end
|
|
275
|
+
end
|
|
202
276
|
end
|
|
203
277
|
|
|
204
278
|
RSpec.shared_examples("Ast::Merge::ConflictResolverBase validation") do
|
data/lib/ast/merge/version.rb
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ast-merge
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.0.
|
|
4
|
+
version: 4.0.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Peter H. Boling
|
|
@@ -66,7 +66,7 @@ dependencies:
|
|
|
66
66
|
version: '5.0'
|
|
67
67
|
- - ">="
|
|
68
68
|
- !ruby/object:Gem::Version
|
|
69
|
-
version: 5.0.
|
|
69
|
+
version: 5.0.3
|
|
70
70
|
type: :runtime
|
|
71
71
|
prerelease: false
|
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -76,7 +76,7 @@ dependencies:
|
|
|
76
76
|
version: '5.0'
|
|
77
77
|
- - ">="
|
|
78
78
|
- !ruby/object:Gem::Version
|
|
79
|
-
version: 5.0.
|
|
79
|
+
version: 5.0.3
|
|
80
80
|
- !ruby/object:Gem::Dependency
|
|
81
81
|
name: kettle-dev
|
|
82
82
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -355,7 +355,10 @@ files:
|
|
|
355
355
|
- lib/ast/merge/recipe/script_loader.rb
|
|
356
356
|
- lib/ast/merge/rspec.rb
|
|
357
357
|
- lib/ast/merge/rspec/dependency_tags.rb
|
|
358
|
+
- lib/ast/merge/rspec/dependency_tags_config.rb
|
|
359
|
+
- lib/ast/merge/rspec/dependency_tags_helpers.rb
|
|
358
360
|
- lib/ast/merge/rspec/merge_gem_registry.rb
|
|
361
|
+
- lib/ast/merge/rspec/setup.rb
|
|
359
362
|
- lib/ast/merge/rspec/shared_examples.rb
|
|
360
363
|
- lib/ast/merge/rspec/shared_examples/conflict_resolver_base.rb
|
|
361
364
|
- lib/ast/merge/rspec/shared_examples/debug_logger.rb
|
|
@@ -382,10 +385,10 @@ licenses:
|
|
|
382
385
|
- MIT
|
|
383
386
|
metadata:
|
|
384
387
|
homepage_uri: https://ast-merge.galtzo.com/
|
|
385
|
-
source_code_uri: https://github.com/kettle-rb/ast-merge/tree/v4.0.
|
|
386
|
-
changelog_uri: https://github.com/kettle-rb/ast-merge/blob/v4.0.
|
|
388
|
+
source_code_uri: https://github.com/kettle-rb/ast-merge/tree/v4.0.5
|
|
389
|
+
changelog_uri: https://github.com/kettle-rb/ast-merge/blob/v4.0.5/CHANGELOG.md
|
|
387
390
|
bug_tracker_uri: https://github.com/kettle-rb/ast-merge/issues
|
|
388
|
-
documentation_uri: https://www.rubydoc.info/gems/ast-merge/4.0.
|
|
391
|
+
documentation_uri: https://www.rubydoc.info/gems/ast-merge/4.0.5
|
|
389
392
|
funding_uri: https://github.com/sponsors/pboling
|
|
390
393
|
wiki_uri: https://github.com/kettle-rb/ast-merge/wiki
|
|
391
394
|
news_uri: https://www.railsbling.com/tags/ast-merge
|
|
@@ -414,7 +417,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
414
417
|
- !ruby/object:Gem::Version
|
|
415
418
|
version: '0'
|
|
416
419
|
requirements: []
|
|
417
|
-
rubygems_version: 4.0.
|
|
420
|
+
rubygems_version: 4.0.5
|
|
418
421
|
specification_version: 4
|
|
419
422
|
summary: "☯️ Shared infrastructure for the *-merge gem family"
|
|
420
423
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|