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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4f0f43d49e308c9c65fb2b0dd8dda636f357158140dcce83c003ba6c19d30f1
4
- data.tar.gz: fa414dce653faafb66fb4701250c8de8914dfd4992901aa51156b99c144d68d1
3
+ metadata.gz: fba167c2d1b56afae8d64a75f4f3993ce5b7e6b817bfe2709fa65161e08f7648
4
+ data.tar.gz: ae0c51df861ea89e80a147684038c9e8535ff5613e1e3033d0489331c13a67fd
5
5
  SHA512:
6
- metadata.gz: ae03e8d2b4c8d0b60be8522b720c0f64f7bea0766759fb951cf763e192ff000b2fea036f9bb0b739a305ff964ca3e64c9b01908e029c30793425e6a7c73eca0c
7
- data.tar.gz: f3ddde5fb021c84b1df97fca4cf0443a3982a3be63f053c2533370eff1bd666450ae265e6745f643a6f372d574cdc25e40a110e44426fd73b5a31e8e39368ff2
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
- [![asciicast](https://asciinema.org/a/YqUrRMXdUXVGh7KqJpvy5DVBm.png)](https://asciinema.org/a/YqUrRMXdUXVGh7KqJpvy5DVBm)
32
+ [![asciicast](https://asciinema.org/a/bGvwdnrAzrUeHeGvY4UYfIdFZ.png)](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
- with 'any content'
66
- with /any.regex/
67
- without 'other content or regex'
68
- with_line 'line to match, leading and trailing spaces are ignored'
69
- without_line 'line to make sure is not in the file'
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
- with 'some content'
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 with(content)
32
- content_as_string = content.is_a?(String) ? content : content.inspect
33
- add_result message: "with `#{content_as_string}`",
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 without(content)
38
- content_as_string = content.is_a?(String) ? content : content.inspect
39
- add_result message: "without `#{content_as_string}`",
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 with_line(content)
44
- add_result message: "with line `#{content}`",
45
- pass: File.readlines(last_file).map(&:strip).include?(content)
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 without_line(content)
49
- add_result message: "without line `#{content}`",
50
- pass: !File.readlines(last_file).map(&:strip).include?(content)
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
@@ -1,3 +1,3 @@
1
1
  module Enforce
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enforce
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit