abide_dev_utils 0.14.0 → 0.14.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa840c23e0e5ab5d978e04b6c3192bd473fa7d3886033be49c20124f33964c8b
4
- data.tar.gz: 6d8d44b81c393907052d1cd70907b31e8e339ee7519080152ba3f2b5da3cd420
3
+ metadata.gz: b6af74f2a0eea495b7bf71fd843c668f556ee83cf45e3b6ebfafe4242278dcee
4
+ data.tar.gz: 6e9f6f60bc30f135bd4f2c6f35962626e81db410fc0c17631761c84e4551e1db
5
5
  SHA512:
6
- metadata.gz: b18c4a042ae47492d235a3778f3b50a3589940af256cd0407ea38c170766fcaade5d8ead74c9baa47490c407bc9c375703356640e8f1e393a230055ddd099798
7
- data.tar.gz: c2578428399f77596809838daa1adae12aa76e0f34298c3695bd9058a9da1a6c6e3a4e9120542dad9a6b2eda473581196e40df3467a8ff706332ce52824f2707
6
+ metadata.gz: d61f39d043c94ab0ee2db46bd0374c99803fc720022606361f319e3b245c429700bffec7e9157ef11045cc7f5e25b21833b8bdc820ca1dcb32e7022ae7c89e3c
7
+ data.tar.gz: c2463568c53de7d0e0dfa0e4950484db5df6965888d2cae2b145f4dfba2816105f41aa413da4c07c9642da33c2a6b264a5cfd6504874db1de0f6de0eeef51675
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- abide_dev_utils (0.14.0)
4
+ abide_dev_utils (0.14.2)
5
5
  amatch (~> 0.4)
6
6
  cmdparse (~> 3.0)
7
7
  facterdb (>= 1.21)
@@ -61,7 +61,7 @@ GEM
61
61
  diff-lcs (1.5.0)
62
62
  digest-crc (0.6.4)
63
63
  rake (>= 12.0.0, < 14.0.0)
64
- facter (4.2.14)
64
+ facter (4.3.0)
65
65
  hocon (~> 1.3)
66
66
  thor (>= 1.0.1, < 2.0)
67
67
  facterdb (1.21.0)
@@ -85,7 +85,7 @@ GEM
85
85
  octokit (~> 4.6)
86
86
  rainbow (>= 2.2.1)
87
87
  rake (>= 10.0)
88
- google-apis-core (0.10.0)
88
+ google-apis-core (0.11.0)
89
89
  addressable (~> 2.5, >= 2.5.1)
90
90
  googleauth (>= 0.16.2, < 2.a)
91
91
  httpclient (>= 2.8.1, < 3.a)
@@ -94,8 +94,8 @@ GEM
94
94
  retriable (>= 2.0, < 4.a)
95
95
  rexml
96
96
  webrick
97
- google-apis-iamcredentials_v1 (0.16.0)
98
- google-apis-core (>= 0.9.1, < 2.a)
97
+ google-apis-iamcredentials_v1 (0.17.0)
98
+ google-apis-core (>= 0.11.0, < 2.a)
99
99
  google-apis-storage_v1 (0.19.0)
100
100
  google-apis-core (>= 0.9.0, < 2.a)
101
101
  google-cloud-core (1.6.0)
@@ -103,7 +103,7 @@ GEM
103
103
  google-cloud-errors (~> 1.0)
104
104
  google-cloud-env (1.6.0)
105
105
  faraday (>= 0.17.3, < 3.0)
106
- google-cloud-errors (1.3.0)
106
+ google-cloud-errors (1.3.1)
107
107
  google-cloud-storage (1.44.0)
108
108
  addressable (~> 2.8)
109
109
  digest-crc (~> 0.4)
@@ -121,7 +121,7 @@ GEM
121
121
  signet (>= 0.16, < 2.a)
122
122
  hashdiff (1.0.1)
123
123
  hashie (5.0.0)
124
- hiera (3.11.0)
124
+ hiera (3.12.0)
125
125
  hocon (1.3.1)
126
126
  httpclient (2.8.3)
127
127
  i18n (1.12.0)
@@ -143,7 +143,7 @@ GEM
143
143
  multi_json (1.15.0)
144
144
  multipart-post (2.3.0)
145
145
  nio4r (2.5.8)
146
- nokogiri (1.14.1-x86_64-darwin)
146
+ nokogiri (1.14.2-x86_64-darwin)
147
147
  racc (~> 1.4)
148
148
  oauth (0.6.2)
149
149
  snaky_hash (~> 2.0)
@@ -168,7 +168,7 @@ GEM
168
168
  coderay (~> 1.1)
169
169
  method_source (~> 1.0)
170
170
  public_suffix (4.0.7)
171
- puppet (7.22.0-universal-darwin)
171
+ puppet (7.23.0-universal-darwin)
172
172
  CFPropertyList (~> 2.2)
173
173
  concurrent-ruby (~> 1.0, < 1.2.0)
174
174
  deep_merge (~> 1.0)
@@ -182,8 +182,8 @@ GEM
182
182
  semantic_puppet (~> 1.0)
183
183
  puppet-resource_api (1.8.14)
184
184
  hocon (>= 1.0)
185
- puppet-strings (2.9.0)
186
- rgen
185
+ puppet-strings (3.0.1)
186
+ rgen (~> 0.9.0)
187
187
  yard (~> 0.9.5)
188
188
  racc (1.6.2)
189
189
  rainbow (3.1.1)
@@ -229,7 +229,7 @@ GEM
229
229
  rubocop (~> 1.19)
230
230
  ruby-progressbar (1.11.0)
231
231
  ruby2_keywords (0.0.5)
232
- ruby_parser (3.19.2)
232
+ ruby_parser (3.20.0)
233
233
  sexp_processor (~> 4.16)
234
234
  rubyzip (2.3.2)
235
235
  sawyer (0.9.2)
@@ -485,8 +485,6 @@ module AbideDevUtils
485
485
  raise AbideDevUtils::Errors::ResourceDataNotFoundError, facts if rdata_files.nil? || rdata_files.empty?
486
486
 
487
487
  YAML.load_file(rdata_files[0].path)
488
- rescue StandardError => e
489
- require 'pry'; binding.pry
490
488
  end
491
489
  end
492
490
  end
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'tempfile'
4
+ require 'fileutils'
5
+
3
6
  module AbideDevUtils
4
7
  # Formats text for output in markdown
5
8
  class Markdown
@@ -14,11 +17,17 @@ module AbideDevUtils
14
17
  def to_markdown
15
18
  toc = @toc.join("\n")
16
19
  body = @body.join("\n")
17
- "#{@title}\n#{toc}\n\n#{body}"
20
+ "#{@title}\n#{toc}\n\n#{body}".encode(universal_newline: true)
18
21
  end
22
+ alias to_s to_markdown
19
23
 
20
24
  def to_file
21
- File.write(@file, to_markdown)
25
+ this_markdown = to_markdown
26
+ Tempfile.create('markdown') do |f|
27
+ f.write(this_markdown)
28
+ check_file_content(f.path, this_markdown)
29
+ FileUtils.mv(f.path, @file)
30
+ end
22
31
  end
23
32
 
24
33
  def method_missing(name, *args, &block)
@@ -88,6 +97,14 @@ module AbideDevUtils
88
97
 
89
98
  private
90
99
 
100
+ def check_file_content(file, content)
101
+ raise "File #{file} not found! Not saving to #{@file}" unless File.exist?(file)
102
+ raise "File #{file} is empty! Not saving to #{@file}" if File.zero?(file)
103
+ return if File.read(file).include?(content)
104
+
105
+ raise "File #{file} does not contain correct content! Not saving to #{@file}"
106
+ end
107
+
91
108
  def add(type, text, *args, **kwargs)
92
109
  @toc << ul(link(text, text, anchor: true), indent: 0) if @with_toc && type == :h1
93
110
 
@@ -236,12 +236,14 @@ module AbideDevUtils
236
236
  new_paths = []
237
237
  possible_fact_values.each do |pfv|
238
238
  new_path = path.dup
239
+ values = []
239
240
  pfv.each do |v|
240
241
  next unless v
241
242
 
243
+ values << v if v
242
244
  new_path.sub!(FACT_PATTERN, v)
243
245
  end
244
- new_paths << EntryPathLocalFile.new(new_path, facts, possible_fact_values)
246
+ new_paths << EntryPathLocalFile.new(new_path, facts, values)
245
247
  end
246
248
  new_paths.uniq(&:path).select(&:exist?)
247
249
  end
@@ -249,16 +251,13 @@ module AbideDevUtils
249
251
 
250
252
  # Represents a local file derived from a Hiera path
251
253
  class EntryPathLocalFile
252
- attr_reader :path, :facts
254
+ attr_reader :path, :facts, :values, :fact_values
253
255
 
254
- def initialize(path, facts, possible_fact_values)
256
+ def initialize(path, facts, values)
255
257
  @path = File.expand_path(File.join(AbideDevUtils::Ppt::Hiera.default_datadir, path))
256
258
  @facts = facts
257
- @possible_fact_values = possible_fact_values
258
- end
259
-
260
- def fact_values
261
- @fact_values ||= fact_values_for_path
259
+ @values = values
260
+ @fact_values = @facts.zip(@values).to_h
262
261
  end
263
262
 
264
263
  def path_parts
@@ -279,22 +278,6 @@ module AbideDevUtils
279
278
  facts: facts
280
279
  }
281
280
  end
282
-
283
- private
284
-
285
- def fact_values_for_path
286
- no_fext_path_parts = path_parts.map { |part| File.basename(part, '.yaml') }
287
- valid_fact_values = @possible_fact_values.select do |pfv|
288
- pfv.all? { |v| no_fext_path_parts.include?(v) }
289
- end
290
- valid_fact_values.uniq! # Removes duplicate arrays, not duplicate fact values
291
- valid_fact_values.flatten!
292
- return {} if valid_fact_values.empty?
293
-
294
- fact_vals = {}
295
- facts.each_index { |idx| fact_vals[facts[idx]] = valid_fact_values[idx] }
296
- fact_vals
297
- end
298
281
  end
299
282
  end
300
283
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AbideDevUtils
4
- VERSION = "0.14.0"
4
+ VERSION = "0.14.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abide_dev_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.14.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - abide-team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-28 00:00:00.000000000 Z
11
+ date: 2023-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri