enforce 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +16 -7
- data/lib/enforce/dsl.rb +27 -14
- data/lib/enforce/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fba167c2d1b56afae8d64a75f4f3993ce5b7e6b817bfe2709fa65161e08f7648
|
4
|
+
data.tar.gz: ae0c51df861ea89e80a147684038c9e8535ff5613e1e3033d0489331c13a67fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35c48455f34fbae355a47c64abcec6a91da1323c82fe98c7d7a24fe84ee7ae69c86aaa970fb81f5ca3f9c8116b8e23f297b679af85d6d331a074156db446f9ee
|
7
|
+
data.tar.gz: e4236b773b652c18771bd7524ca9bf1c2679509c020aa779e9a0985158c56d5fe94016c5eb67cb2dc0413b5c0d7db7834c244cd51e0c616ab9073743b06fb26f
|
data/README.md
CHANGED
@@ -29,7 +29,7 @@ gem 'enforce'
|
|
29
29
|
Example
|
30
30
|
--------------------------------------------------
|
31
31
|
|
32
|
-
[](https://asciinema.org/a/bGvwdnrAzrUeHeGvY4UYfIdFZ)
|
33
33
|
|
34
34
|
Also see the [example folder](/example).
|
35
35
|
|
@@ -62,11 +62,14 @@ Verify that a file exists, and has (or doesn't have) some content:
|
|
62
62
|
|
63
63
|
```ruby
|
64
64
|
file 'filename' do
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
65
|
+
text 'any content'
|
66
|
+
no_text 'other content or regex'
|
67
|
+
|
68
|
+
regex /any.regex/
|
69
|
+
no_regex /any.regex/
|
70
|
+
|
71
|
+
line 'line to match, leading and trailing spaces are ignored'
|
72
|
+
no_line 'line to make sure is not in the file'
|
70
73
|
end
|
71
74
|
```
|
72
75
|
|
@@ -85,13 +88,19 @@ Verify that a folder exists:
|
|
85
88
|
folder 'dirname'
|
86
89
|
```
|
87
90
|
|
91
|
+
Verify that a folder does not exist:
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
no_folder 'dirname'
|
95
|
+
```
|
96
|
+
|
88
97
|
Verify that a folder exists, and run additional validations inside it:
|
89
98
|
|
90
99
|
```ruby
|
91
100
|
folder 'dirname' do
|
92
101
|
file 'file-inside-dirname'
|
93
102
|
file 'another-file' do
|
94
|
-
|
103
|
+
text 'some content'
|
95
104
|
end
|
96
105
|
end
|
97
106
|
```
|
data/lib/enforce/dsl.rb
CHANGED
@@ -28,26 +28,39 @@ module Enforce
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
32
|
-
|
33
|
-
add_result message: "
|
34
|
-
pass: File.read(last_file).match?(content)
|
31
|
+
def no_folder(name)
|
32
|
+
pass = !Dir.exist?(name)
|
33
|
+
add_result message: "no folder `#{name}`", pass: pass
|
35
34
|
end
|
36
35
|
|
37
|
-
def
|
38
|
-
|
39
|
-
add_result message: "
|
40
|
-
pass: !File.read(last_file).match?(content)
|
36
|
+
def text(content)
|
37
|
+
pass = File.read(last_file).include?(content)
|
38
|
+
add_result message: "text `#{content}`", pass: pass
|
41
39
|
end
|
42
40
|
|
43
|
-
def
|
44
|
-
|
45
|
-
|
41
|
+
def no_text(content)
|
42
|
+
pass = !File.read(last_file).include?(content)
|
43
|
+
add_result message: "no_text `#{content}`", pass: pass
|
46
44
|
end
|
47
45
|
|
48
|
-
def
|
49
|
-
|
50
|
-
|
46
|
+
def regex(content)
|
47
|
+
pass = File.read(last_file).match?(content)
|
48
|
+
add_result message: "regex `#{content.inspect}`", pass: pass
|
49
|
+
end
|
50
|
+
|
51
|
+
def no_regex(content)
|
52
|
+
pass = !File.read(last_file).match?(content)
|
53
|
+
add_result message: "no_regex `#{content.inspect}`", pass: pass
|
54
|
+
end
|
55
|
+
|
56
|
+
def line(content)
|
57
|
+
pass = File.readlines(last_file).map(&:strip).include?(content)
|
58
|
+
add_result message: "line `#{content}`", pass: pass
|
59
|
+
end
|
60
|
+
|
61
|
+
def no_line(content)
|
62
|
+
pass = !File.readlines(last_file).map(&:strip).include?(content)
|
63
|
+
add_result message: "no line `#{content}`", pass: pass
|
51
64
|
end
|
52
65
|
|
53
66
|
def results
|
data/lib/enforce/version.rb
CHANGED