ast-template 7.1.13 → 7.1.15
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/lib/ast/template/file_types.rb +15 -15
- data/lib/ast/template/merge_dispatch.rb +10 -4
- data/lib/ast/template/strategies.rb +13 -13
- data/lib/ast/template/token_application.rb +10 -5
- data/lib/ast/template/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +14 -14
- 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: 8af1c17c8d3cbf7839dc6705e5f85804b6ce5882e3053d8d533e2c9e609c0c07
|
|
4
|
+
data.tar.gz: 85a25701587ee6db8cef8612b781aa1c5de7d4444faac36403a10a4f67bc9cfe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '02449c18f0d65e364564ed18a6735e1895b8330a472894b73c33c2491beb30cd3da80d2a5ba8973d736e68940b6f690362ec6ad6a489cd68ba96c8e531c33bd6'
|
|
7
|
+
data.tar.gz: aa2cecce0d580735916cba4790534c1d2737b60b22663ebfcd4b4a506b586bfd078cc03c1e15e9396231ca5835be42a071a103018ad06d0bf1b3d7e97f9b43c8
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
|
@@ -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 ==
|
|
29
|
-
return :gemfile if basename ==
|
|
30
|
-
return :appraisals if basename.start_with?(
|
|
31
|
-
return :gemspec if basename.end_with?(
|
|
32
|
-
return :rakefile if basename ==
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
return :yaml if extension.match?(/\A\.ya?ml\z/) || basename.casecmp(
|
|
37
|
-
return :toml if extension ==
|
|
38
|
-
return :jsonc if relative_path ==
|
|
39
|
-
return :jsonc if extension ==
|
|
40
|
-
return :json5 if extension ==
|
|
41
|
-
return :json if extension ==
|
|
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?(
|
|
44
|
-
return :rbs if extension ==
|
|
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,9 +15,15 @@ module Ast
|
|
|
15
15
|
Adapter = Struct.new(:gem_name, :require_path, :invoke)
|
|
16
16
|
|
|
17
17
|
DEFAULT_ADAPTERS = {
|
|
18
|
-
yaml: Adapter.new(
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
yaml: Adapter.new('psych-merge', 'psych/merge', lambda { |t, d, **opts|
|
|
19
|
+
Psych::Merge.merge_yaml(t, d, 'yaml', **opts)
|
|
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)
|
|
23
|
+
}),
|
|
24
|
+
markdown: Adapter.new('markdown-merge', 'markdown/merge', lambda { |t, d, **opts|
|
|
25
|
+
Markdown::Merge.merge_markdown(t, d, 'markdown', **opts)
|
|
26
|
+
})
|
|
21
27
|
}.freeze
|
|
22
28
|
|
|
23
29
|
@adapters = {}
|
|
@@ -28,7 +34,7 @@ module Ast
|
|
|
28
34
|
# merger result hash ({ok:, output:, diagnostics:}).
|
|
29
35
|
def register(file_type, callable = nil, &block)
|
|
30
36
|
adapter = callable || block
|
|
31
|
-
raise ArgumentError,
|
|
37
|
+
raise ArgumentError, 'adapter callable required' unless adapter.respond_to?(:call)
|
|
32
38
|
|
|
33
39
|
adapters[file_type.to_sym] = adapter
|
|
34
40
|
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 =
|
|
16
|
+
DEFAULT_STRATEGY = 'merge'
|
|
17
17
|
|
|
18
18
|
module_function
|
|
19
19
|
|
|
@@ -25,9 +25,9 @@ module Ast
|
|
|
25
25
|
# @param overrides [Array<Hash>] per-path strategy overrides
|
|
26
26
|
# @param path [String] logical destination path
|
|
27
27
|
# @return [String] the effective strategy
|
|
28
|
-
def resolve(default: DEFAULT_STRATEGY, overrides: []
|
|
29
|
-
override = Array(overrides).find { |entry| (entry[:path] || entry[
|
|
30
|
-
strategy = override && (override[:strategy] || override[
|
|
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'])
|
|
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 ==
|
|
46
|
+
return keep_decision if strategy == 'keep_destination'
|
|
47
47
|
|
|
48
48
|
absent = destination_content.nil?
|
|
49
|
-
if strategy ==
|
|
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(
|
|
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 =
|
|
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 ==
|
|
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:
|
|
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 ?
|
|
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
|
-
|
|
88
|
+
strategy == 'raw_copy' ? 'raw_copy' : 'merge_prepared_content'
|
|
89
89
|
end
|
|
90
90
|
end
|
|
91
91
|
end
|
|
@@ -39,7 +39,8 @@ module Ast
|
|
|
39
39
|
# @raise [UnresolvedTokensError] unresolved namespaced tokens remain
|
|
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
|
-
resolved = Token::Resolver::Resolve.new(on_missing: :keep).resolve(document,
|
|
42
|
+
resolved = Token::Resolver::Resolve.new(on_missing: :keep).resolve(document,
|
|
43
|
+
stringify_replacements(replacements))
|
|
43
44
|
return resolved unless scan_unresolved
|
|
44
45
|
|
|
45
46
|
unresolved = unresolved_namespaced_tokens(resolved, config: config, namespace: namespace)
|
|
@@ -54,10 +55,14 @@ module Ast
|
|
|
54
55
|
# @return [Array<String>]
|
|
55
56
|
def unresolved_namespaced_tokens(content, config:, namespace:)
|
|
56
57
|
Token::Resolver::Document.new(content.to_s, config: config)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
.
|
|
60
|
-
|
|
58
|
+
.token_keys
|
|
59
|
+
.select do |key|
|
|
60
|
+
key.split(
|
|
61
|
+
config.separators.first, 2
|
|
62
|
+
).first == namespace
|
|
63
|
+
end
|
|
64
|
+
.uniq
|
|
65
|
+
.sort
|
|
61
66
|
end
|
|
62
67
|
|
|
63
68
|
# Normalize replacements for the resolver: string keys and values.
|
data/lib/ast/template/version.rb
CHANGED
|
@@ -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.
|
|
8
|
+
VERSION = '7.1.15'
|
|
9
9
|
end
|
|
10
10
|
# Current gem version exposed at the traditional constant location.
|
|
11
11
|
VERSION = Version::VERSION # Traditional Constant Location
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ast-template
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 7.1.
|
|
4
|
+
version: 7.1.15
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Peter H. Boling
|
|
@@ -43,14 +43,14 @@ dependencies:
|
|
|
43
43
|
requirements:
|
|
44
44
|
- - '='
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: 7.1.
|
|
46
|
+
version: 7.1.15
|
|
47
47
|
type: :runtime
|
|
48
48
|
prerelease: false
|
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
51
|
- - '='
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: 7.1.
|
|
53
|
+
version: 7.1.15
|
|
54
54
|
- !ruby/object:Gem::Dependency
|
|
55
55
|
name: token-resolver
|
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -100,7 +100,7 @@ dependencies:
|
|
|
100
100
|
version: '3.1'
|
|
101
101
|
- - ">="
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: 3.1.
|
|
103
|
+
version: 3.1.19
|
|
104
104
|
type: :development
|
|
105
105
|
prerelease: false
|
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -110,7 +110,7 @@ dependencies:
|
|
|
110
110
|
version: '3.1'
|
|
111
111
|
- - ">="
|
|
112
112
|
- !ruby/object:Gem::Version
|
|
113
|
-
version: 3.1.
|
|
113
|
+
version: 3.1.19
|
|
114
114
|
- !ruby/object:Gem::Dependency
|
|
115
115
|
name: bundler-audit
|
|
116
116
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -208,7 +208,7 @@ dependencies:
|
|
|
208
208
|
version: '2.0'
|
|
209
209
|
- - ">="
|
|
210
210
|
- !ruby/object:Gem::Version
|
|
211
|
-
version: 2.0.
|
|
211
|
+
version: 2.0.27
|
|
212
212
|
type: :development
|
|
213
213
|
prerelease: false
|
|
214
214
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -218,27 +218,27 @@ dependencies:
|
|
|
218
218
|
version: '2.0'
|
|
219
219
|
- - ">="
|
|
220
220
|
- !ruby/object:Gem::Version
|
|
221
|
-
version: 2.0.
|
|
221
|
+
version: 2.0.27
|
|
222
222
|
- !ruby/object:Gem::Dependency
|
|
223
223
|
name: turbo_tests2
|
|
224
224
|
requirement: !ruby/object:Gem::Requirement
|
|
225
225
|
requirements:
|
|
226
226
|
- - "~>"
|
|
227
227
|
- !ruby/object:Gem::Version
|
|
228
|
-
version: '
|
|
228
|
+
version: '4.0'
|
|
229
229
|
- - ">="
|
|
230
230
|
- !ruby/object:Gem::Version
|
|
231
|
-
version:
|
|
231
|
+
version: 4.0.0
|
|
232
232
|
type: :development
|
|
233
233
|
prerelease: false
|
|
234
234
|
version_requirements: !ruby/object:Gem::Requirement
|
|
235
235
|
requirements:
|
|
236
236
|
- - "~>"
|
|
237
237
|
- !ruby/object:Gem::Version
|
|
238
|
-
version: '
|
|
238
|
+
version: '4.0'
|
|
239
239
|
- - ">="
|
|
240
240
|
- !ruby/object:Gem::Version
|
|
241
|
-
version:
|
|
241
|
+
version: 4.0.0
|
|
242
242
|
- !ruby/object:Gem::Dependency
|
|
243
243
|
name: ruby-progressbar
|
|
244
244
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -319,10 +319,10 @@ licenses:
|
|
|
319
319
|
- PolyForm-Small-Business-1.0.0
|
|
320
320
|
metadata:
|
|
321
321
|
homepage_uri: https://structuredmerge.org
|
|
322
|
-
source_code_uri: https://github.com/structuredmerge/structuredmerge-ruby/tree/v7.1.
|
|
323
|
-
changelog_uri: https://github.com/structuredmerge/structuredmerge-ruby/blob/v7.1.
|
|
322
|
+
source_code_uri: https://github.com/structuredmerge/structuredmerge-ruby/tree/v7.1.15
|
|
323
|
+
changelog_uri: https://github.com/structuredmerge/structuredmerge-ruby/blob/v7.1.15/CHANGELOG.md
|
|
324
324
|
bug_tracker_uri: https://github.com/structuredmerge/structuredmerge-ruby/issues
|
|
325
|
-
documentation_uri: https://www.rubydoc.info/gems/ast-template/7.1.
|
|
325
|
+
documentation_uri: https://www.rubydoc.info/gems/ast-template/7.1.15
|
|
326
326
|
funding_uri: https://github.com/sponsors/pboling
|
|
327
327
|
wiki_uri: https://github.com/structuredmerge/structuredmerge-ruby/wiki
|
|
328
328
|
news_uri: https://www.railsbling.com/tags/ast-template
|
metadata.gz.sig
CHANGED
|
Binary file
|