Sha256: baf49d2fbea61e0f290faa9d02507cf05c58f8368cb6129b5bada565893b2358

Contents?: true

Size: 641 Bytes

Versions: 4

Compression:

Stored size: 641 Bytes

Contents

module PoolParty    
=begin rdoc


== Line in File

Ensures that the line given is in the file

== Usage

  has_line_in_file('line', '/full/file/path.ext')

== Examples

  has_line_in_file("ENABLED=1", "/etc/default/haproxy")
=end

  class LineInFile
    
    plugin :line_in_file do
      dsl_methods :file, :line
      default_options(
        :line => ""
      )
      def loaded(opts={}, &block)
        has_exec "line_in_#{file}" do
          command "grep -q \'#{line.safe_quote}\' #{file} || echo \'#{line.safe_quote}\' >> #{file}"
          not_if "grep -q \'#{line.safe_quote}\' #{file}"
        end
      end
    end
    
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
auser-poolparty-1.2.3 lib/poolparty/plugins/line_in_file.rb
auser-poolparty-1.2.4 lib/poolparty/plugins/line_in_file.rb
auser-poolparty-1.2.7 lib/poolparty/plugins/line_in_file.rb
auser-poolparty-1.2.8 lib/poolparty/plugins/line_in_file.rb