Skip to content
Development repository for the line cookbook
Branch: master
Clone or download
MarkGibbons Merge pull request #148 from sous-chefs/supermarket_links
Change the links to absolute so they work on supermarket
Latest commit 966ff6f Apr 19, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Add dokken workflow in circleci & remove travis (#127) Oct 17, 2018
.delivery Working tests for Ubuntu platform for all resources. May 17, 2017
.github
documentation/resources Change the links to absolute so they work on supermarket Apr 18, 2019
libraries
recipes
resources Add explicit tests for input files missing and empty Apr 6, 2019
spec Add a test to verify that the linked files exist Apr 18, 2019
test Add explicit tests for input files missing and empty Apr 6, 2019
.gitignore
.kitchen.dokken.yml Add dokken workflow in circleci & remove travis (#127) Oct 17, 2018
.kitchen.yml
.rubocop.yml
Berksfile Fix the missing file test. May 23, 2018
CHANGELOG.md Change the links to absolute so they work on supermarket Apr 18, 2019
CONTRIBUTING.md
Dangerfile Add a test to verify that the linked files exist Apr 18, 2019
Gemfile
LICENSE initial commit Dec 8, 2012
README.md
TESTING.md Add CONTRIBUTING.md and TESTING.md May 26, 2018
appveyor.yml Add CircleCI Support (Danger) May 19, 2018
chefignore
metadata.rb Add a test to verify that the linked files exist Apr 18, 2019

README.md

line cookbook

Cookbook Version Build Status pullreminders

Motivation

Quite often, the need arises to do line editing instead of managing an entire file with a template resource. This cookbook supplies various resources that will help you do this.

Limitations

  • The line resources processes the entire target file in memory. Trying to edit large files may fail.

  • The end of line processing was only tested using \n and \r\n. Using other line endings very well may not work.

  • The end of line string used needs to match the actual end of line used in the file \n and \r\n are used as the defaults but if they don't match the actual end of line used in the file the results will be weird.

  • Adding a line implies there is a separator on the previous line. Adding a line differs from appending characters.

  • Lines to be added should not contain EOL characters. The providers do not do multiline regex checks.

  • Missing file processing is the way it is by intention

    • add_to_list do nothing, list not found so there is nothing to add to.
    • append_if_no_line create file, add the line.
    • delete_from_list do nothing, the list was not found which implies there is nothing to delete
    • delete_lines do nothing, the line isn't there which implies there is nothing to delete
    • replace_or_add create file, add the line
    • filter_lines create file if the file changes
  • Chef client version 13 or greater is expected.

Resources

For more detailed information see the matching resource documentation:

  • append_if_no_line - Add a missing line

  • replace_or_add - Replace a line that matches a pattern or add a missing line

  • delete_lines - Delete an item from a list

  • add_to_list - Add an item to a list

  • delete_from_list - Delete lines that match a pattern

  • filter_lines - Supply a ruby proc or use a sample filter to edit lines. The filter_lines resource supports multiple line modfications.

    Sample filters:

    • after: Insert lines after a matched line
    • before: Insert lines before a matched lined
    • between: Insert lines between matched lines
    • comment: Change lines to comments
    • delete_between: Delete the lines found between two patterns
    • missing: Add missing lines to a file
    • replace: Replace each instance of matched lines
    • stanza: Insert or change keys in files formatted in stanzas
    • substitute: Substitute text in lines matching a pattern

Authors

  • Contributor: Mark Gibbons
  • Contributor: Dan Webb
  • Contributor: Sean OMeara
  • Contributor: Antek S. Baranski
You can’t perform that action at this time.