项目作者: DannyBen

项目描述 :
DSL for verifying file/folder content
高级语言: Ruby
项目地址: git://github.com/DannyBen/enforce.git
创建时间: 2018-02-03T10:51:29Z
项目社区:https://github.com/DannyBen/enforce

开源协议:MIT License

下载


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

  1. $ gem install 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:

  1. file 'filename'

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

  1. file 'filename' do
  2. text 'any content'
  3. no_text 'other content or regex'
  4. regex /any.regex/
  5. no_regex /any.regex/
  6. line 'line to match, leading and trailing spaces are ignored'
  7. no_line 'line to make sure is not in the file'
  8. end

Verify that a file does not exist:

  1. no_file 'filename'

Folder Commands

Verify that a folder exists:

  1. folder 'dirname'

Verify that a folder does not exist:

  1. no_folder 'dirname'

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

  1. folder 'dirname' do
  2. file 'file-inside-dirname'
  3. file 'another-file' do
  4. text 'some content'
  5. end
  6. end