Sha256: a22fdd49345c6ca2029bd60eba649958353844f1d4edf102eef3a3701ffa503f

Contents?: true

Size: 975 Bytes

Versions: 5

Compression:

Stored size: 975 Bytes

Contents

# frozen_string_literal: true

require 'puppet-strings'
require 'tempfile'

namespace :strings do
  namespace :validate do
    desc 'Validate the reference is up to date'
    task :reference, [:patterns, :debug, :backtrace] do |_t, args|
      filename = 'REFERENCE.md'

      unless File.exist?(filename)
        warn "#{filename} does not exist"
        exit 1
      end

      patterns = args[:patterns]
      patterns = patterns.split if patterns
      patterns ||= PuppetStrings::DEFAULT_SEARCH_PATTERNS

      generated = Tempfile.create do |file|
        options = {
          debug: args[:debug] == 'true',
          backtrace: args[:backtrace] == 'true',
          json: false,
          markdown: true,
          path: file
        }
        PuppetStrings.generate(patterns, options)

        file.read
      end

      existing = File.read(filename)

      if generated != existing
        warn "#{filename} is outdated"
        exit 1
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
puppet-strings-4.1.2 lib/puppet-strings/tasks/validate.rb
puppet-strings-4.1.1 lib/puppet-strings/tasks/validate.rb
puppet-strings-4.1.0 lib/puppet-strings/tasks/validate.rb
puppet-strings-4.0.0 lib/puppet-strings/tasks/validate.rb
puppet-strings-4.0.0.rc.1 lib/puppet-strings/tasks/validate.rb