class PoiseFile::Resources::PoiseFile::Resource

A `poise_file` resource to write out a file with some nice helpers.

@provides poise_file @action create @action delete @action touch @action create_if_missing @example

poise_file '/etc/myapp.json' do
  content listen: 80, debug: false
end

Private Instance Methods

default_format() click to toggle source

Find the default format based on the file path.

@api private @return [String]

# File lib/poise_file/resources/poise_file.rb, line 87
def default_format
  # If we have a pattern, ignore the format system by default. If we
  # have string content, it's just raw content by default.
  return 'text' if pattern || content.is_a?(String)
  case path
  when /\.json$/
    'json'
  when /\.ya?ml$/
    'yaml'
  else
    'text'
  end
end