ast-template 7.1.22 → 8.0.0

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: 70957e043a2db1296e3a94ae3831a39b3210bfd57e8f855ca9c2fc3e19f96b3d
4
- data.tar.gz: 75fe53f8289db9e22dfce8b1ae184e937f7d0de4489cc3df56bdba05a9547d02
3
+ metadata.gz: 060720548772a44afcc652fa775e3407455edc221fe49cd679fa95da551bcc32
4
+ data.tar.gz: 2d7df4a012955d9f02fa943da3c48d1bc6556a71bc7b4df3caef33bf4f7e6acb
5
5
  SHA512:
6
- metadata.gz: 927ccbd5e190a8d44cb7735de6b10341739290d51a12d9399d77b1bc40c2f4d20e5cc2e08c71e10850266297dc1e1568a7e8b722aa739a82fea7dea046e568d2
7
- data.tar.gz: bac5b53b3d70ec41b4218b278686fc75a8e7895039689b65a25ee88f5797898030e37f378121e383f966eaea848337234d02cdd3ed0c8fcb81fc333121743d7f
6
+ metadata.gz: 26af9c38ec42053f2c64f18435ffc418a830f69684e7bc8e325f656a875c1722d4bb003765998bcd25901d590e234f69e54f8768d80d5fa4202ca52fec227d07
7
+ data.tar.gz: e2a482ffbfd3516fe447c55210917cb4d39b63fd550c863b098ce44773ce543a80d57c73a54c9ccc2ceb5aacd12c68df92fd284ff31e75270f2aa2c29d9b320f
checksums.yaml.gz.sig CHANGED
Binary file
data/LICENSE.md CHANGED
@@ -1,13 +1,10 @@
1
1
  # License
2
2
 
3
- This project is made available under the following licenses.
3
+ This project is made available under the following license.
4
4
  Choose the option that best fits your use case:
5
5
 
6
- - [AGPL-3.0-only](https://github.com/structuredmerge/structuredmerge-ruby/blob/main/AGPL-3.0-only.md)
7
- - [PolyForm-Small-Business-1.0.0](https://github.com/structuredmerge/structuredmerge-ruby/blob/main/PolyForm-Small-Business-1.0.0.md)
8
-
9
- If none of the above licenses fit your use case, please [contact us](mailto:floss@galtzo.com) to discuss a custom commercial license.
6
+ - [MIT](https://github.com/structuredmerge/structuredmerge-ruby/blob/main/MIT.md)
10
7
 
11
8
  ## Copyright Notice
12
9
 
13
- - Required Notice: Copyright (c) 2026 Peter H. Boling
10
+ - Copyright (c) 2026 Peter H. Boling
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # 💎 Ast::Template
4
4
 
5
- [![Version][👽versioni]][👽version] [![Ruby Users Forum][✉️ruby-forum-top-img]][✉️ruby-forum] [![GitHub tag (latest SemVer)][⛳️tag-img]][⛳️tag] [![License: AGPL-3.0-only OR PolyForm-Small-Business-1.0.0][📄license-img]][📄license] [![Total downloads][👽dl-ranki]][👽dl-rank] [![CodeCov Test Coverage][🏀codecovi]][🏀codecov] [![Coveralls Test Coverage][🏀coveralls-img]][🏀coveralls] [![QLTY Test Coverage][🏀qlty-covi]][🏀qlty-cov] [![QLTY Maintainability][🏀qlty-mnti]][🏀qlty-mnt] [![CI Current][🚎11-c-wfi]][🚎11-c-wf] [![CI Test Coverage][🚎2-cov-wfi]][🚎2-cov-wf]
5
+ [![Version][👽versioni]][👽version] [![Ruby Users Forum][✉️ruby-forum-top-img]][✉️ruby-forum] [![GitHub tag (latest SemVer)][⛳️tag-img]][⛳️tag] [![License: MIT][📄license-img]][📄license] [![Total downloads][👽dl-ranki]][👽dl-rank] [![CodeCov Test Coverage][🏀codecovi]][🏀codecov] [![Coveralls Test Coverage][🏀coveralls-img]][🏀coveralls] [![QLTY Test Coverage][🏀qlty-covi]][🏀qlty-cov] [![QLTY Maintainability][🏀qlty-mnti]][🏀qlty-mnt] [![CI Current][🚎11-c-wfi]][🚎11-c-wf] [![CI Test Coverage][🚎2-cov-wfi]][🚎2-cov-wf]
6
6
 
7
7
  `if ci_badges.map(&:color).detect { it != "green"}` ☝️ [let me know on Discord][✉️discord-invite] or [RubyForum][✉️ruby-forum], as I may have missed the notification.
8
8
 
@@ -11,6 +11,7 @@
11
11
  [![Sponsor Me on Github][🖇sponsor-img]][🖇sponsor] [![Liberapay Goal Progress][⛳liberapay-img]][⛳liberapay] [![Donate on PayPal][🖇paypal-img]][🖇paypal] [![Buy me a coffee][🖇buyme-small-img]][🖇buyme] [![Donate at ko-fi.com][🖇kofi-img]][🖇kofi]
12
12
 
13
13
  <!-- kettle-sponsors:shields:start -->
14
+ <a href="#corporate-sponsorship"><img src="https://logos.galtzo.com/assets/images/sponsors/shield/github.svg" alt="services: GitHub"></a> <a href="#corporate-sponsorship"><img src="https://logos.galtzo.com/assets/images/sponsors/shield/healthsherpa.svg" alt="sponsor: HealthSherpa"></a> <a href="#corporate-sponsorship"><img src="https://logos.galtzo.com/assets/images/sponsors/shield/microsoft.svg" alt="compute: Microsoft"></a>
14
15
  <!-- kettle-sponsors:shields:end -->
15
16
 
16
17
  ## 🌻 Synopsis <a href="https://discord.gg/3qme4XHNKN"><img alt="Galtzo FLOSS Logo by Aboling0, CC BY-SA 4.0" src="https://logos.galtzo.com/assets/images/galtzo-floss/avatar-128px.svg" width="8%" align="right"/></a> <a href="https://ruby-toolbox.com"><img alt="ruby-lang Logo, Yukihiro Matsumoto, Ruby Visual Identity Team, CC BY-SA 2.5" src="https://logos.galtzo.com/assets/images/ruby-lang/avatar-128px.svg" width="8%" align="right"/></a>
@@ -60,6 +61,17 @@ report = Ast::Template.run_package_directory_session(request)
60
61
  puts report.fetch(:mode)
61
62
  ```
62
63
 
64
+ ## 🏢 Corporate Sponsorship
65
+
66
+ <!-- kettle-sponsors:cards:start -->
67
+ <a href="https://github.com"><picture><source media="(max-width: 600px)" srcset="https://logos.galtzo.com/assets/images/sponsors/phone/github.svg"><img src="https://logos.galtzo.com/assets/images/sponsors/github.svg" align="top" alt="Sponsor: GitHub - Copilot Max"></picture></a> <a href="https://healthsherpa.com"><picture><source media="(max-width: 600px)" srcset="https://logos.galtzo.com/assets/images/sponsors/phone/healthsherpa.svg"><img src="https://logos.galtzo.com/assets/images/sponsors/healthsherpa.svg" align="top" alt="Sponsor: HealthSherpa - GitHub Sponsors =&gt; @pboling (maintainer)"></picture></a> <a href="https://opensource.microsoft.com"><picture><source media="(max-width: 600px)" srcset="https://logos.galtzo.com/assets/images/sponsors/phone/microsoft.svg"><img src="https://logos.galtzo.com/assets/images/sponsors/microsoft.svg" align="top" alt="Sponsor: Microsoft - Azure compute resources"></picture></a>
68
+
69
+ <sub>Create sponsorship badges for your project with [kettle-sponsors](https://github.com/kettle-dev/kettle-sponsors).</sub>
70
+ <!-- kettle-sponsors:cards:end -->
71
+
72
+ **If you're working in a company that's making significant use of structuredmerge tools we'd
73
+ appreciate it if you suggest to your company to become a structuredmerge sponsor.**
74
+
63
75
  ## 💡 Info you can shake a stick at
64
76
 
65
77
  | Tokens to Remember | [![Gem name][⛳️name-img]][⛳️gem-name] [![Gem namespace][⛳️namespace-img]][⛳️gem-namespace] |
@@ -68,7 +80,7 @@ puts report.fetch(:mode)
68
80
  | Support & Community | [![Join Me on Daily.dev's RubyFriends][✉️ruby-friends-img]][✉️ruby-friends] [![Get help from RubyForum][✉️ruby-forum-img]][✉️ruby-forum] [![Live Chat on Discord][✉️discord-invite-img-ftb]][✉️discord-invite] [![Get help from me on Upwork][👨🏼‍🏫expsup-upwork-img]][👨🏼‍🏫expsup-upwork] [![Get help from me on Codementor][👨🏼‍🏫expsup-codementor-img]][👨🏼‍🏫expsup-codementor] |
69
81
  | Source | [![Source on GitLab.com][📜src-gl-img]][📜src-gl] [![Source on CodeBerg.org][📜src-cb-img]][📜src-cb] [![Source on GitHub.com][📜src-gh-img]][📜src-gh] [![The best SHA: dQw4w9WgXcQ!][🧮kloc-img]][🧮kloc] |
70
82
  | Documentation | [![Current release on RubyDoc.info][📜docs-cr-rd-img]][🚎yard-current] [![YARD on Galtzo.com][📜docs-head-rd-img]][🚎yard-head] [![Maintainer Blog][🚂maint-blog-img]][🚂maint-blog] [![GitLab Wiki][📜gl-wiki-img]][📜gl-wiki] [![GitHub Wiki][📜gh-wiki-img]][📜gh-wiki] |
71
- | Compliance | [![License: AGPL-3.0-only OR PolyForm-Small-Business-1.0.0][📄license-img]][📄license] [![Apache license compatibility: Category X][📄license-compat-img]][📄license-compat] [![📄ilo-declaration-img]][📄ilo-declaration] [![Security Policy][🔐security-img]][🔐security] [![Contributor Covenant 2.1][🪇conduct-img]][🪇conduct] [![SemVer 2.0.0][📌semver-img]][📌semver] |
83
+ | Compliance | [![License: MIT][📄license-img]][📄license] [![Apache license compatibility: Category A][📄license-compat-img]][📄license-compat] [![📄ilo-declaration-img]][📄ilo-declaration] [![Security Policy][🔐security-img]][🔐security] [![Contributor Covenant 3.0][🪇conduct-img]][🪇conduct] [![SemVer 2.0.0][📌semver-img]][📌semver] |
72
84
  | Style | [![Enforced Code Style Linter][💎rlts-img]][💎rlts] [![Keep-A-Changelog 1.0.0][📗keep-changelog-img]][📗keep-changelog] [![Gitmoji Commits][📌gitmoji-img]][📌gitmoji] [![Compatibility appraised by: appraisal2][💎appraisal2-img]][💎appraisal2] |
73
85
  | Maintainer 🎖️ | [![Follow Me on LinkedIn][💖🖇linkedin-img]][💖🖇linkedin] [![Follow Me on Ruby.Social][💖🐘ruby-mast-img]][💖🐘ruby-mast] [![Follow Me on Bluesky][💖🦋bluesky-img]][💖🦋bluesky] [![Contact Maintainer][🚂maint-contact-img]][🚂maint-contact] [![My technical writing][💖💁🏼‍♂️devto-img]][💖💁🏼‍♂️devto] |
74
86
  | `...` 💖 | [![Find Me on WellFound:][💖✌️wellfound-img]][💖✌️wellfound] [![Find Me on CrunchBase][💖💲crunchbase-img]][💖💲crunchbase] [![My LinkTree][💖🌳linktree-img]][💖🌳linktree] [![More About Me][💖💁🏼‍♂️aboutme-img]][💖💁🏼‍♂️aboutme] [🧊][💖🧊berg] [🐙][💖🐙hub] [🛖][💖🛖hut] [🧪][💖🧪lab] |
@@ -115,6 +127,8 @@ We [![Keep A Changelog][📗keep-changelog-img]][📗keep-changelog] so if you m
115
127
 
116
128
  See [CONTRIBUTING.md][🤝contributing] for more detailed instructions.
117
129
 
130
+ Want to contribute with AI coding agents? This project is developed with [Cloudroom][🖇cloudroom] and ships an `AGENTS.md` with repo conventions so agents can jump straight in. Signing up with [my referral link][🖇cloudroom] also supports ongoing maintenance at no extra cost to you.
131
+
118
132
  ## 📌 Versioning
119
133
 
120
134
  This library follows [![Semantic Versioning 2.0.0][📌semver-img]][📌semver] for its public API where practical.
@@ -143,10 +157,8 @@ See [CHANGELOG.md][📌changelog] for a list of releases.
143
157
 
144
158
  ## 📄 License
145
159
 
146
- The gem is available under the following licenses: [AGPL-3.0-only](https://github.com/structuredmerge/structuredmerge-ruby/blob/main/AGPL-3.0-only.md), [PolyForm-Small-Business-1.0.0](https://github.com/structuredmerge/structuredmerge-ruby/blob/main/PolyForm-Small-Business-1.0.0.md).
147
- See [LICENSE.md][📄license] for details.
148
-
149
- If none of the available licenses suit your use case, please [contact us](mailto:floss@galtzo.com) to discuss a custom commercial license.
160
+ The gem is available as open source under the terms of
161
+ the [MIT](https://github.com/structuredmerge/structuredmerge-ruby/blob/main/MIT.md) [![License: MIT][📄license-img]][📄license-ref].
150
162
 
151
163
  ### Please give the project a star ⭐ ♥.
152
164
 
@@ -156,6 +168,11 @@ If this project helps you, please consider supporting the maintainer. This is no
156
168
 
157
169
  [![Sponsor me on GitHub Sponsors][🖇sponsor-bottom-img]][🖇sponsor] 💌 [![Sponsor me on Liberapay][⛳liberapay-bottom-img]][⛳liberapay] 💌 [![Donate on PayPal][🖇paypal-bottom-img]][🖇paypal] 💌 [![Buy me a coffee][🖇buyme-small-img]][🖇buyme] 💌 [![Donate at ko-fi.com][🖇kofi-img]][🖇kofi]
158
170
 
171
+ I use [Cloudroom][🖇cloudroom], an agentic AI coding environment, every day. It's the first AI product that made me say "shut up and take my money."
172
+ If you sign up with [my referral link][🖇cloudroom], I receive a share of your subscription for as long as you stay subscribed, at no extra cost to you.
173
+
174
+ [🖇cloudroom]: https://go.cloudroom.dev/u9f53f181a
175
+
159
176
  Thanks for RTFM. ☺️
160
177
 
161
178
  [⛳liberapay-img]: https://img.shields.io/liberapay/goal/pboling.svg?logo=liberapay&color=a51611&style=flat
@@ -213,7 +230,6 @@ Thanks for RTFM. ☺️
213
230
  [💖🐙hub]: https://github.org/pboling
214
231
  [💖🛖hut]: https://sr.ht/~galtzo/
215
232
  [💖🧪lab]: https://gitlab.com/pboling
216
- [🏙️entsup-tidelift-sonar]: https://blog.tidelift.com/tidelift-joins-sonar
217
233
  [👨🏼‍🏫expsup-upwork]: https://www.upwork.com/freelancers/~014942e9b056abdf86?mp_source=share
218
234
  [👨🏼‍🏫expsup-upwork-img]: https://img.shields.io/badge/UpWork-13544E?style=for-the-badge&logo=Upwork&logoColor=white
219
235
  [👨🏼‍🏫expsup-codementor]: https://www.codementor.io/peterboling?utm_source=github&utm_medium=button&utm_term=peterboling&utm_campaign=github
@@ -262,7 +278,7 @@ Thanks for RTFM. ☺️
262
278
  [🖐contributors]: https://github.com/structuredmerge/structuredmerge-ruby/graphs/contributors
263
279
  [🖐contributors-img]: https://contrib.rocks/image?repo=structuredmerge/structuredmerge-ruby
264
280
  [🪇conduct]: https://github.com/structuredmerge/structuredmerge-ruby/blob/main/CODE_OF_CONDUCT.md
265
- [🪇conduct-img]: https://img.shields.io/badge/Contributor_Covenant-2.1-259D6C.svg
281
+ [🪇conduct-img]: https://img.shields.io/badge/Contributor_Covenant-3.0-259D6C.svg
266
282
  [📌pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
267
283
  [📌semver]: https://semver.org/spec/v2.0.0.html
268
284
  [📌semver-img]: https://img.shields.io/badge/semver-2.0.0-259D6C.svg?style=flat
@@ -279,10 +295,10 @@ Thanks for RTFM. ☺️
279
295
  [🔐security-img]: https://img.shields.io/badge/security-policy-259D6C.svg?style=flat
280
296
  [📄copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year
281
297
  [📄license]: LICENSE.md
282
- [📄license-ref]: LICENSE.md
283
- [📄license-img]: https://img.shields.io/badge/License-AGPL--3.0--only_OR_PolyForm--Small--Business--1.0.0-259D6C.svg
284
- [📄license-compat]: https://www.apache.org/legal/resolved.html#category-x
285
- [📄license-compat-img]: https://img.shields.io/badge/Apache_Incompatible:_Category_X-%E2%9C%97-C0392B.svg?style=flat&logo=Apache
298
+ [📄license-ref]: https://github.com/structuredmerge/structuredmerge-ruby/blob/main/MIT.md
299
+ [📄license-img]: https://img.shields.io/badge/License-MIT-259D6C.svg
300
+ [📄license-compat]: https://www.apache.org/legal/resolved.html#category-a
301
+ [📄license-compat-img]: https://img.shields.io/badge/Apache_Compatible:_Category_A-%E2%9C%93-259D6C.svg?style=flat&logo=Apache
286
302
 
287
303
  [📄ilo-declaration]: https://www.ilo.org/declaration/lang--en/index.htm
288
304
  [📄ilo-declaration-img]: https://img.shields.io/badge/ILO_Fundamental_Principles-✓-259D6C.svg?style=flat
@@ -25,23 +25,23 @@ module Ast
25
25
  relative_path = path.to_s
26
26
  basename = File.basename(relative_path)
27
27
  extension = File.extname(relative_path).downcase
28
- return :gitignore if basename == '.gitignore'
29
- return :gemfile if basename == 'Gemfile' || basename.end_with?('.gemfile')
30
- return :appraisals if basename.start_with?('Appraisals')
31
- return :gemspec if basename.end_with?('.gemspec')
32
- return :rakefile if basename == 'Rakefile' || extension == '.rake'
28
+ return :gitignore if basename == ".gitignore"
29
+ return :gemfile if basename == "Gemfile" || basename.end_with?(".gemfile")
30
+ return :appraisals if basename.start_with?("Appraisals")
31
+ return :gemspec if basename.end_with?(".gemspec")
32
+ return :rakefile if basename == "Rakefile" || extension == ".rake"
33
33
  return :ruby if RUBY_BASENAMES.include?(basename) ||
34
- RUBY_SUFFIXES.any? { |suffix| basename.end_with?(suffix) } ||
35
- RUBY_EXTENSIONS.include?(extension)
36
- return :yaml if extension.match?(/\A\.ya?ml\z/) || basename.casecmp('citation.cff').zero?
37
- return :toml if extension == '.toml'
38
- return :jsonc if relative_path == '.devcontainer/devcontainer.json'
39
- return :jsonc if extension == '.jsonc'
40
- return :json5 if extension == '.json5'
41
- return :json if extension == '.json'
34
+ RUBY_SUFFIXES.any? { |suffix| basename.end_with?(suffix) } ||
35
+ RUBY_EXTENSIONS.include?(extension)
36
+ return :yaml if extension.match?(/\A\.ya?ml\z/) || basename.casecmp("citation.cff").zero?
37
+ return :toml if extension == ".toml"
38
+ return :jsonc if relative_path == ".devcontainer/devcontainer.json"
39
+ return :jsonc if extension == ".jsonc"
40
+ return :json5 if extension == ".json5"
41
+ return :json if extension == ".json"
42
42
  return :markdown if extension.match?(/\A\.md(?:own)?\z/)
43
- return :dotenv if basename.start_with?('.env') || basename.end_with?('.env') || extension == '.env'
44
- return :rbs if extension == '.rbs'
43
+ return :dotenv if basename.start_with?(".env") || basename.end_with?(".env") || extension == ".env"
44
+ return :rbs if extension == ".rbs"
45
45
 
46
46
  :text
47
47
  end
@@ -15,14 +15,14 @@ module Ast
15
15
  Adapter = Struct.new(:gem_name, :require_path, :invoke)
16
16
 
17
17
  DEFAULT_ADAPTERS = {
18
- yaml: Adapter.new('psych-merge', 'psych/merge', lambda { |t, d, **opts|
19
- Psych::Merge.merge_yaml(t, d, 'yaml', **opts)
18
+ yaml: Adapter.new("psych-merge", "psych/merge", lambda { |t, d, **opts|
19
+ Psych::Merge.merge_yaml(t, d, "yaml", **opts)
20
20
  }),
21
- toml: Adapter.new('citrus-toml-merge', 'citrus/toml/merge', lambda { |t, d, **opts|
22
- Citrus::Toml::Merge.merge_toml(t, d, 'toml', **opts)
21
+ toml: Adapter.new("citrus-toml-merge", "citrus/toml/merge", lambda { |t, d, **opts|
22
+ Citrus::Toml::Merge.merge_toml(t, d, "toml", **opts)
23
23
  }),
24
- markdown: Adapter.new('markdown-merge', 'markdown/merge', lambda { |t, d, **opts|
25
- Markdown::Merge.merge_markdown(t, d, 'markdown', **opts)
24
+ markdown: Adapter.new("markdown-merge", "markdown/merge", lambda { |t, d, **opts|
25
+ Markdown::Merge.merge_markdown(t, d, "markdown", **opts)
26
26
  })
27
27
  }.freeze
28
28
 
@@ -34,7 +34,7 @@ module Ast
34
34
  # merger result hash ({ok:, output:, diagnostics:}).
35
35
  def register(file_type, callable = nil, &block)
36
36
  adapter = callable || block
37
- raise ArgumentError, 'adapter callable required' unless adapter.respond_to?(:call)
37
+ raise ArgumentError, "adapter callable required" unless adapter.respond_to?(:call)
38
38
 
39
39
  adapters[file_type.to_sym] = adapter
40
40
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'typed_core_bridge'
3
+ require_relative "typed_core_bridge"
4
4
 
5
5
  module Ast
6
6
  module Template
@@ -8,11 +8,12 @@ module Ast
8
8
  # Template execution and filesystem mutation remain Ruby-owned.
9
9
  class RustHostProvider
10
10
  include TypedCoreBridge
11
- PROVIDER_ID = 'rust.ast-template.session-reports'
11
+
12
+ PROVIDER_ID = "rust.ast-template.session-reports"
12
13
 
13
14
  class << self
14
15
  def available?
15
- require 'structuredmerge_core' unless defined?(::StructuredmergeCore)
16
+ require "structuredmerge_core" unless defined?(::StructuredmergeCore)
16
17
  %i[report_template_options report_template_profile plan_template_directory].all? do |name|
17
18
  ::StructuredmergeCore.respond_to?(name)
18
19
  end
@@ -39,13 +40,13 @@ module Ast
39
40
  end
40
41
 
41
42
  def plan(request)
42
- report(request.merge(kind: 'plan'))
43
+ report(request.merge(kind: "plan"))
43
44
  end
44
45
 
45
46
  private
46
47
 
47
48
  def host
48
- require 'structuredmerge_core' unless defined?(::StructuredmergeCore)
49
+ require "structuredmerge_core" unless defined?(::StructuredmergeCore)
49
50
  ::StructuredmergeCore
50
51
  end
51
52
  end
@@ -13,7 +13,7 @@ module Ast
13
13
  module Strategies
14
14
  # The four strategy names a destination config may declare.
15
15
  STRATEGIES = %w[merge keep_destination raw_copy accept_template].freeze
16
- DEFAULT_STRATEGY = 'merge'
16
+ DEFAULT_STRATEGY = "merge"
17
17
 
18
18
  module_function
19
19
 
@@ -26,8 +26,8 @@ module Ast
26
26
  # @param path [String] logical destination path
27
27
  # @return [String] the effective strategy
28
28
  def resolve(path:, default: DEFAULT_STRATEGY, overrides: [])
29
- override = Array(overrides).find { |entry| (entry[:path] || entry['path']) == path }
30
- strategy = override && (override[:strategy] || override['strategy'])
29
+ override = Array(overrides).find { |entry| (entry[:path] || entry["path"]) == path }
30
+ strategy = override && (override[:strategy] || override["strategy"])
31
31
  strategy.to_s.empty? ? default : strategy.to_s
32
32
  end
33
33
 
@@ -43,25 +43,25 @@ module Ast
43
43
  # @return [Hash] {execution_action:, write_action:, status:, content:}
44
44
  def plan_entry(strategy:, template_content:, destination_content:)
45
45
  strategy = strategy.to_s
46
- return keep_decision if strategy == 'keep_destination'
46
+ return keep_decision if strategy == "keep_destination"
47
47
 
48
48
  absent = destination_content.nil?
49
- if strategy == 'merge'
49
+ if strategy == "merge"
50
50
  trivial = trivial_merge_outcome(template_content, destination_content)
51
51
  return keep_decision if trivial == :identical
52
- return write_decision('merge_prepared_content', absent, template_content) if trivial == :empty_destination
52
+ return write_decision("merge_prepared_content", absent, template_content) if trivial == :empty_destination
53
53
  end
54
54
 
55
55
  # accept_template and merge-of-differences both write prepared content;
56
56
  # for merge-of-differences the content is the merger's, not ours.
57
- content = strategy == 'merge' ? nil : template_content
57
+ content = (strategy == "merge") ? nil : template_content
58
58
  write_decision(execution_action_for(strategy), absent, content)
59
59
  end
60
60
 
61
61
  # Whether the strategy leaves the destination untouched. Absent
62
62
  # destinations are not created under keep_destination.
63
63
  def keep_destination?(strategy)
64
- strategy.to_s == 'keep_destination'
64
+ strategy.to_s == "keep_destination"
65
65
  end
66
66
 
67
67
  # The merge short-circuits that never invoke a merger:
@@ -76,16 +76,16 @@ module Ast
76
76
  end
77
77
 
78
78
  def keep_decision
79
- { execution_action: 'keep', write_action: 'keep', status: 'keep', content: nil }
79
+ {execution_action: "keep", write_action: "keep", status: "keep", content: nil}
80
80
  end
81
81
 
82
82
  def write_decision(execution_action, create, content)
83
- action = create ? 'create' : 'update'
84
- { execution_action: execution_action, write_action: action, status: action, content: content }
83
+ action = create ? "create" : "update"
84
+ {execution_action: execution_action, write_action: action, status: action, content: content}
85
85
  end
86
86
 
87
87
  def execution_action_for(strategy)
88
- strategy == 'raw_copy' ? 'raw_copy' : 'merge_prepared_content'
88
+ (strategy == "raw_copy") ? "raw_copy" : "merge_prepared_content"
89
89
  end
90
90
  end
91
91
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'token/resolver'
3
+ require "token/resolver"
4
4
 
5
5
  module Ast
6
6
  module Template
@@ -19,7 +19,7 @@ module Ast
19
19
 
20
20
  def initialize(tokens)
21
21
  @tokens = tokens
22
- super("unresolved template tokens: #{tokens.map { |token| "{#{token}}" }.join(', ')}")
22
+ super("unresolved template tokens: #{tokens.map { |token| "{#{token}}" }.join(", ")}")
23
23
  end
24
24
  end
25
25
 
@@ -40,7 +40,7 @@ module Ast
40
40
  def apply_tokens(content, replacements, config:, namespace:, scan_unresolved: true)
41
41
  document = Token::Resolver::Document.new(content.to_s, config: config)
42
42
  resolved = Token::Resolver::Resolve.new(on_missing: :keep).resolve(document,
43
- stringify_replacements(replacements))
43
+ stringify_replacements(replacements))
44
44
  return resolved unless scan_unresolved
45
45
 
46
46
  unresolved = unresolved_namespaced_tokens(resolved, config: config, namespace: namespace)
@@ -55,14 +55,14 @@ module Ast
55
55
  # @return [Array<String>]
56
56
  def unresolved_namespaced_tokens(content, config:, namespace:)
57
57
  Token::Resolver::Document.new(content.to_s, config: config)
58
- .token_keys
59
- .select do |key|
58
+ .token_keys
59
+ .select do |key|
60
60
  key.split(
61
61
  config.separators.first, 2
62
62
  ).first == namespace
63
63
  end
64
- .uniq
65
- .sort
64
+ .uniq
65
+ .sort
66
66
  end
67
67
 
68
68
  # Normalize replacements for the resolver: string keys and values.
@@ -6,49 +6,49 @@ module Ast
6
6
  # remain in Rust. No Ruby selection, template execution or writes occur here.
7
7
  module TypedCoreBridge
8
8
  REPORT_FIELDS = {
9
- 'TemplateSessionRequestReport' => %w[request_kind profile_name mode ready diagnostics resolved_options],
10
- 'TemplateSessionOptions' => %w[mode template_root destination_root context default_strategy overrides
11
- replacements allowed_families config],
12
- 'TemplateDestinationContext' => %w[project_name],
13
- 'TemplateStrategyOverride' => %w[path strategy],
14
- 'TemplateTokenConfig' => %w[pre post separators min_segments max_segments segment_pattern],
15
- 'SessionDiagnostic' => %w[severity category reason path family message],
16
- 'TemplateSessionPlanReport' => %w[mode runner_report],
17
- 'TemplateDirectoryRunnerReport' => %w[plan_report preview run_report apply_report],
18
- 'TemplateDirectoryPlanReport' => %w[entries summary],
19
- 'TemplateDirectoryPlanReportEntry' => %w[template_source_path logical_destination_path destination_path
20
- execution_action write_action status previewable],
21
- 'TemplateDirectoryPlanReportSummary' => %w[create update keep blocked omitted],
22
- 'TemplatePreviewResult' => %w[result_files created_paths updated_paths kept_paths blocked_paths omitted_paths]
9
+ "TemplateSessionRequestReport" => %w[request_kind profile_name mode ready diagnostics resolved_options],
10
+ "TemplateSessionOptions" => %w[mode template_root destination_root context default_strategy overrides
11
+ replacements allowed_families config],
12
+ "TemplateDestinationContext" => %w[project_name],
13
+ "TemplateStrategyOverride" => %w[path strategy],
14
+ "TemplateTokenConfig" => %w[pre post separators min_segments max_segments segment_pattern],
15
+ "SessionDiagnostic" => %w[severity category reason path family message],
16
+ "TemplateSessionPlanReport" => %w[mode runner_report],
17
+ "TemplateDirectoryRunnerReport" => %w[plan_report preview run_report apply_report],
18
+ "TemplateDirectoryPlanReport" => %w[entries summary],
19
+ "TemplateDirectoryPlanReportEntry" => %w[template_source_path logical_destination_path destination_path
20
+ execution_action write_action status previewable],
21
+ "TemplateDirectoryPlanReportSummary" => %w[create update keep blocked omitted],
22
+ "TemplatePreviewResult" => %w[result_files created_paths updated_paths kept_paths blocked_paths omitted_paths]
23
23
  }.freeze
24
24
  OMIT_NIL = {
25
- 'TemplateSessionRequestReport' => %w[profile_name],
26
- 'TemplateSessionOptions' => %w[config],
27
- 'TemplateDestinationContext' => %w[project_name],
28
- 'TemplateTokenConfig' => %w[max_segments],
29
- 'SessionDiagnostic' => %w[path family]
25
+ "TemplateSessionRequestReport" => %w[profile_name],
26
+ "TemplateSessionOptions" => %w[config],
27
+ "TemplateDestinationContext" => %w[project_name],
28
+ "TemplateTokenConfig" => %w[max_segments],
29
+ "SessionDiagnostic" => %w[path family]
30
30
  }.freeze
31
31
 
32
32
  private
33
33
 
34
34
  def core_report(request)
35
35
  request = require_hash(normalize_transport(request))
36
- options = template_options(request.fetch('options'))
37
- result = case request.fetch('kind')
38
- when 'options'
39
- host.report_template_options(options)
40
- when 'profile'
41
- profiles = require_hash(request.fetch('profiles', {})).transform_values do |profile|
42
- template_profile(profile)
43
- end
44
- host.report_template_profile(host::TemplateProfileRequest.new(
45
- profile_name: request.fetch('profile_name'), profiles: profiles, options: options
46
- ))
47
- when 'plan'
48
- host.plan_template_directory(options)
49
- else
50
- raise ArgumentError, "unsupported ast-template report kind #{request['kind'].inspect}"
51
- end
36
+ options = template_options(request.fetch("options"))
37
+ result = case request.fetch("kind")
38
+ when "options"
39
+ host.report_template_options(options)
40
+ when "profile"
41
+ profiles = require_hash(request.fetch("profiles", {})).transform_values do |profile|
42
+ template_profile(profile)
43
+ end
44
+ host.report_template_profile(host::TemplateProfileRequest.new(
45
+ profile_name: request.fetch("profile_name"), profiles: profiles, options: options
46
+ ))
47
+ when "plan"
48
+ host.plan_template_directory(options)
49
+ else
50
+ raise ArgumentError, "unsupported ast-template report kind #{request["kind"].inspect}"
51
+ end
52
52
  project_report(result).transform_keys(&:to_sym)
53
53
  end
54
54
 
@@ -66,34 +66,34 @@ module Ast
66
66
  fields = %w[mode default_strategy replacements].to_h { |field| [field.to_sym, value.fetch(field)] }
67
67
  fields[:replacements] = require_hash(fields[:replacements])
68
68
  fields[:context] =
69
- host::TemplateDestinationContext.new(project_name: require_hash(value.fetch('context'))['project_name'])
70
- overrides = value.fetch('overrides')
71
- raise TypeError, 'template overrides must be an array' unless overrides.is_a?(Array)
69
+ host::TemplateDestinationContext.new(project_name: require_hash(value.fetch("context"))["project_name"])
70
+ overrides = value.fetch("overrides")
71
+ raise TypeError, "template overrides must be an array" unless overrides.is_a?(Array)
72
72
 
73
73
  fields[:overrides] = overrides.map do |entry|
74
74
  entry = require_hash(entry)
75
- host::TemplateStrategyOverride.new(path: entry.fetch('path'), strategy: entry.fetch('strategy'))
75
+ host::TemplateStrategyOverride.new(path: entry.fetch("path"), strategy: entry.fetch("strategy"))
76
+ end
77
+ fields[:allowed_families] = value["allowed_families"]
78
+ fields[:config] = unless value["config"].nil?
79
+ config = require_hash(value["config"])
80
+ args = %w[pre post separators min_segments segment_pattern].to_h do |key|
81
+ [key.to_sym, config.fetch(key)]
82
+ end
83
+ host::TemplateTokenConfig.new(**args, max_segments: config["max_segments"])
76
84
  end
77
- fields[:allowed_families] = value['allowed_families']
78
- fields[:config] = unless value['config'].nil?
79
- config = require_hash(value['config'])
80
- args = %w[pre post separators min_segments segment_pattern].to_h do |key|
81
- [key.to_sym, config.fetch(key)]
82
- end
83
- host::TemplateTokenConfig.new(**args, max_segments: config['max_segments'])
84
- end
85
85
  fields
86
86
  end
87
87
 
88
88
  def require_hash(value)
89
- raise TypeError, 'template request fields must be objects' unless value.is_a?(Hash)
89
+ raise TypeError, "template request fields must be objects" unless value.is_a?(Hash)
90
90
 
91
91
  value
92
92
  end
93
93
 
94
94
  def template_options(value)
95
95
  host::TemplateSessionOptions.new(**template_fields(value),
96
- template_root: value.fetch('template_root'), destination_root: value.fetch('destination_root'))
96
+ template_root: value.fetch("template_root"), destination_root: value.fetch("destination_root"))
97
97
  end
98
98
 
99
99
  def template_profile(value)
@@ -107,7 +107,7 @@ module Ast
107
107
  when Symbol then value.to_s
108
108
  when NilClass, String, Numeric, TrueClass, FalseClass then value
109
109
  else
110
- type = value.class.name.delete_prefix('StructuredmergeCore::')
110
+ type = value.class.name.delete_prefix("StructuredmergeCore::")
111
111
  REPORT_FIELDS.fetch(type).each_with_object({}) do |field, result|
112
112
  item = value.public_send(field)
113
113
  next if item.nil? && OMIT_NIL.fetch(type, []).include?(field)
@@ -5,7 +5,7 @@ module Ast
5
5
  # Version namespace for this gem.
6
6
  module Version
7
7
  # Current gem version.
8
- VERSION = '7.1.22'
8
+ VERSION = "8.0.0"
9
9
  end
10
10
  # Current gem version exposed at the traditional constant location.
11
11
  VERSION = Version::VERSION # Traditional Constant Location