Skip to content
DSL for verifying file/folder content
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
example
lib
spec
.bettercodehub.yml
.gitignore
.rspec
.travis.yml
Gemfile
LICENSE
README.md
Runfile
enforce.gemspec

README.md

Enforce - A DSL for verifying file/folder content

Gem Version Build Status Maintainability


Create globally available DSL scripts to verify the existence of files in a folder, and the contents of these files.


Install

$ gem install enforce

Or with bundler:

gem 'enforce'

Example

asciicast

Also see the example folder.

Usage

  1. Create a rules file containing any of the DSL commands below.
  2. Run $ enforce <rules file name> in the directory you want to test (without the .rb extension)

Rules files are ruby scripts that are located either in the current directory or in your home directory, under enforce subdirectory (~/enforce/*.rb).

If you wish to place your rules files elsewhere, set the ENFORCE_HOME environment variable.

DSL

File Commands

Verify that a file exists:

file 'filename'

Verify that a file exists, and has (or doesn't have) some content:

file 'filename' do
  text 'any content'
  no_text 'other content or regex'

  regex /any.regex/
  no_regex /any.regex/

  line 'line to match, leading and trailing spaces are ignored'
  no_line 'line to make sure is not in the file'
end

Verify that a file does not exist:

no_file 'filename'

Folder Commands

Verify that a folder exists:

folder 'dirname'

Verify that a folder does not exist:

no_folder 'dirname'

Verify that a folder exists, and run additional validations inside it:

folder 'dirname' do
  file 'file-inside-dirname'
  file 'another-file' do
    text 'some content'
  end
end
You can’t perform that action at this time.