pray-cli 1.8.1 → 1.9.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: 7712d0c9a8ea370b50c90c7212ab7d15ea2c8ea90a304365194f9c34242b72dc
4
- data.tar.gz: 0a5a5de36c49409e1e9bb8d689a1fdd7284eaa79b472eee210f19144835812a4
3
+ metadata.gz: 4aabea84f997a26ce08fd78e561be889a990f16fde64956f55ea92249b2d13b0
4
+ data.tar.gz: 360408860ba9184cfa6e09434092f2758b4bdced69a7d3873288b54157450e63
5
5
  SHA512:
6
- metadata.gz: 6750b00e4f4cc372849209ec4e23ae222cee7ef49134afe7dd2f2fbd19d2efcfd1bed5a143ae829b17c68b596d2320e1a8095be36c01c335c894f07c4415bcc0
7
- data.tar.gz: 173d7e11c528fec7a3d816aedb511952e8189e2ba8fd061245c0cf13b3a00a9f658df255be54c0e44b75326c47435f88933d867bea0db4ffa99cc0456089effa
6
+ metadata.gz: d4703291e60da15ad0109712fc07e6e4f5dbd35efeafd3e8e49f86ccdbddaad39b3f5faca751f80662f618abcb3f618d4c0d4ea5962a470ef5c417ef94112e08
7
+ data.tar.gz: 68b4a7df9a8a0aef4879ff2ef1f101068b494baafef3ddc869385f7565cb4cdaf4afe42ea35c4966f2e090cf21461bdac021f3fcb64fd44ac1cadc00b29561dc
data/CHANGELOG.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # CHANGELOG
2
2
 
3
- ## Unreleased
3
+ ## 1.9.1 (2026-08-29)
4
+
5
+ - Rewrite every matching `pray` line when a package constraint is updated, keeping indent and extra keywords.
4
6
 
5
7
  ## 1.7.0 (2026-07-29)
6
8
 
data/README.md CHANGED
@@ -10,6 +10,8 @@ Resolve, lock, render, verify, and publish shared instructions, policies, templa
10
10
 
11
11
  **Repository:** [kiskolabs/pray](https://github.com/kiskolabs/pray)
12
12
 
13
+ **Package:** [rubygems.org/gems/pray-cli](https://rubygems.org/gems/pray-cli)
14
+
13
15
  **Community docs:** [CHANGELOG.md](CHANGELOG.md) · [LICENSE.md](LICENSE.md) · [SECURITY.md](SECURITY.md)
14
16
 
15
17
  ## Install
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pray
4
+ module ManifestMethods
5
+ module_function
6
+
7
+ PACKAGE_KEYWORDS = %w[pray use include agent package].freeze
8
+
9
+ def rewrite_constraint_on_line(line, constraint)
10
+ indent = line[/\A\s*/]
11
+ trimmed = line.lstrip
12
+ after_keyword = skip_package_keyword(trimmed)
13
+ raise Error.manifest("package declaration is missing a keyword") unless after_keyword
14
+
15
+ after_keyword = after_keyword.lstrip
16
+ parsed_name = parse_quoted(after_keyword)
17
+ raise Error.manifest("package declaration is missing a quoted name") unless parsed_name
18
+
19
+ name, after_name = parsed_name
20
+ quoted_constraint = "\"#{constraint}\""
21
+ keyword_and_name = trimmed[0, trimmed.length - after_name.length]
22
+ remainder = after_name.lstrip
23
+ return "#{indent}#{keyword_and_name}, #{quoted_constraint}" if remainder.empty?
24
+ unless remainder.start_with?(",")
25
+ raise Error.manifest("package #{name} declaration is missing a comma after the name")
26
+ end
27
+
28
+ after_comma = remainder[1..].lstrip
29
+ if after_comma.start_with?("\"", "'")
30
+ parsed_constraint = parse_quoted(after_comma)
31
+ unless parsed_constraint
32
+ raise Error.manifest("package #{name} declaration has an unclosed constraint")
33
+ end
34
+
35
+ return "#{indent}#{keyword_and_name}, #{quoted_constraint}#{parsed_constraint[1]}"
36
+ end
37
+
38
+ "#{indent}#{keyword_and_name}, #{quoted_constraint}, #{after_comma}"
39
+ end
40
+
41
+ def skip_package_keyword(input)
42
+ PACKAGE_KEYWORDS.each do |keyword|
43
+ next unless input.start_with?(keyword)
44
+
45
+ rest = input[keyword.length..]
46
+ next_character = rest[0]
47
+ whitespace_or_quote = next_character.nil? ||
48
+ next_character.match?(/\s/) ||
49
+ next_character == "\"" ||
50
+ next_character == "'"
51
+ return rest if whitespace_or_quote
52
+ end
53
+ nil
54
+ end
55
+
56
+ def parse_quoted(input)
57
+ quote = input[0]
58
+ return unless quote == "\"" || quote == "'"
59
+
60
+ rest = input[1..]
61
+ ending = rest.index(quote)
62
+ return unless ending
63
+
64
+ [rest[0, ending], rest[(ending + 1)..]]
65
+ end
66
+ end
67
+ end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "manifest_constraint"
4
+
3
5
  module Pray
4
6
  module ManifestMethods
5
7
  module_function
@@ -37,13 +39,15 @@ module Pray
37
39
  "package \"#{name}\"", "package '#{name}'"
38
40
  ]
39
41
  lines = text.lines.map(&:chomp)
40
- index = lines.index { |line|
41
- trimmed = line.lstrip
42
- prefixes.any? { |prefix| trimmed.start_with?(prefix) }
43
- }
44
- raise Error.manifest("package #{name} not found in manifest") unless index
42
+ replaced = 0
43
+ lines.each_index do |index|
44
+ trimmed = lines[index].lstrip
45
+ next unless prefixes.any? { |prefix| trimmed.start_with?(prefix) }
45
46
 
46
- lines[index] = format_package_declaration(package)
47
+ lines[index] = rewrite_constraint_on_line(lines[index], package.constraint)
48
+ replaced += 1
49
+ end
50
+ raise Error.manifest("package #{name} not found in manifest") if replaced.zero?
47
51
  output = lines.join("\n")
48
52
  output += "\n" if text.end_with?("\n") && !output.end_with?("\n")
49
53
  output
@@ -170,9 +170,16 @@ module Pray
170
170
 
171
171
  def parse_render_policy(rest)
172
172
  _, keywords = parse_call(rest)
173
+ conflict = keywords["conflict"]&.as_string || "fail"
174
+ unless conflict == "fail"
175
+ raise Error.unsupported(
176
+ "render conflict :#{conflict} is not implemented; only :fail is supported"
177
+ )
178
+ end
179
+
173
180
  RenderPolicy.new(
174
181
  mode: keywords["mode"]&.as_string || "managed",
175
- conflict: keywords["conflict"]&.as_string || "fail",
182
+ conflict: conflict,
176
183
  churn: keywords["churn"]&.as_string || "minimal",
177
184
  header: keyword_bool(keywords, "header", true),
178
185
  section_markers: keyword_bool(keywords, "section_markers", true),
data/lib/pray/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pray
4
- VERSION = "1.8.1"
5
- GENERATED_BY = "pray 1.8.1"
4
+ VERSION = "1.9.1"
5
+ GENERATED_BY = "pray 1.9.1"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pray-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 1.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Makarov
@@ -128,6 +128,7 @@ files:
128
128
  - lib/pray/lockfile.rb
129
129
  - lib/pray/lockfile_serialize.rb
130
130
  - lib/pray/manifest.rb
131
+ - lib/pray/manifest_constraint.rb
131
132
  - lib/pray/manifest_formatter.rb
132
133
  - lib/pray/manifest_json.rb
133
134
  - lib/pray/manifest_parser.rb