arguard 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 27e4042b803eb9eb476bccca2f95bec164e688e6
4
- data.tar.gz: 6538533cb54d5613f156ff4506ef08327b2f28d7
3
+ metadata.gz: b339c5c4e7efe5e57314c5d5e3a8f4523931c803
4
+ data.tar.gz: 42b67d7e8e33bab16c9b55c3cf9c18016f9e6ab9
5
5
  SHA512:
6
- metadata.gz: c5de8fe4fd027faa4e38415390a6a3b778a8d3bc1eb0deec42557e80168343e8e40d633061bec0aa478ad4ca445c433a63bfab9e654c7bf77f9e23be75f779fb
7
- data.tar.gz: e0b4832fa78170807be7893619e464d76ecbd6549d0e179b5727078f7864a6142063d9808b4c844fb6fa0d04125b429c52a7b6c1b72e77aecf7664b3022f75ed
6
+ metadata.gz: '076796418a5c1fd89e72b0cf15e0076d92cb8b1e6b22c362295ab738379b235f83ef204fe49a7eff3e84bef6a0dd6c1c744363582725c541d12d6ddf41b8798c'
7
+ data.tar.gz: 9ab109d37b797c02226ab4698929e993b98c318e7cd1f7b817c3f910e72a27b082dcf45319c0b3d2958e12fa9a41c569fac7f8f5ed3e01e118ace9630c964bc9
data/.gitignore CHANGED
@@ -9,4 +9,6 @@
9
9
  /tmp/
10
10
 
11
11
  .idea
12
- .DS_Store
12
+ .idea/**
13
+ .DS_Store
14
+ /arguard-*.gem
@@ -0,0 +1,25 @@
1
+ # This file is subject to the terms and conditions defined in
2
+ # file 'LICENSE.txt', which is part of this source code package.
3
+ module Arguard
4
+ module Guards
5
+ module CollectionsGuard
6
+ def not_nil!
7
+ self.each do |item|
8
+ item.not_nil!
9
+ end
10
+ self
11
+ end
12
+
13
+ def not_empty!
14
+ if self.size == 0
15
+ raise ArgumentError.new('Collection must not be empty.')
16
+ end
17
+ end
18
+
19
+ def not_nil_not_empty!
20
+ self.not_nil!.not_empty!
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,18 @@
1
+ # This file is subject to the terms and conditions defined in
2
+ # file 'LICENSE.txt', which is part of this source code package.
3
+ module Arguard
4
+ module Guards
5
+ module NumbersGuard
6
+
7
+ def odd!(message = nil)
8
+ unless odd?
9
+ exc_message = message.nil? ? 'Number must be odd.' : "Number must be odd. Message: '#{message}'"
10
+
11
+ raise ArgumentError.new(exc_message)
12
+ end
13
+ self
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,34 @@
1
+ # This file is subject to the terms and conditions defined in
2
+ # file 'LICENSE.txt', which is part of this source code package.
3
+ module Arguard
4
+ module Guards
5
+ module ObjectsGuard
6
+ def not_nil!(object_name = nil)
7
+ if self.nil?
8
+ exc_message = object_name.nil? ? "Object must not be nil. Class: '#{self.class.name}'" : "Object must not be nil. Class: '#{self.class.name}', Name: '#{object_name}'"
9
+
10
+ raise ArgumentError.new(exc_message)
11
+ end
12
+ self
13
+ end
14
+
15
+ def true!(message = nil)
16
+ unless self.class == TrueClass
17
+ exc_message = message.nil? ? 'Condition must be true.' : "Condition must be true. Message: '#{message}'"
18
+
19
+ raise ArgumentError.new(exc_message)
20
+ end
21
+ self
22
+ end
23
+
24
+ def false!(message = nil)
25
+ unless self.class == FalseClass
26
+ exc_message = message.nil? ? 'Condition must be false.' : "Condition must be false. Message: '#{message}'"
27
+
28
+ raise ArgumentError.new(exc_message)
29
+ end
30
+ self
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,11 @@
1
+ # This file is subject to the terms and conditions defined in
2
+ # file 'LICENSE.txt', which is part of this source code package.
3
+ module Arguard
4
+ module Guards
5
+ module StringsGuard
6
+
7
+
8
+
9
+ end
10
+ end
11
+ end
@@ -1,4 +1,4 @@
1
1
  module Arguard
2
- VERSION = '0.0.1'.freeze
2
+ VERSION = '0.0.2'.freeze
3
3
 
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arguard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Helmut Juskewycz - hemju
@@ -88,6 +88,10 @@ files:
88
88
  - bin/console
89
89
  - bin/setup
90
90
  - lib/arguard.rb
91
+ - lib/arguard/guards/collections_guard.rb
92
+ - lib/arguard/guards/numbers_guard.rb
93
+ - lib/arguard/guards/objects_guard.rb
94
+ - lib/arguard/guards/strings_guard.rb
91
95
  - lib/arguard/version.rb
92
96
  homepage: http://hemju.com
93
97
  licenses: