code-assertions 1.0
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 +7 -0
- data/lib/code-assertions.rb +23 -0
- metadata +43 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2804bd98e0251fcb8cc571796413909921b4f06eb89c4ff91eca395b127ca49a
|
4
|
+
data.tar.gz: b25bfce9824a17c3b5c0def39e5bd6005d60a386127014ac97bc5124bac873d0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 91a7f9f4fddb841b39e9b5e8eebba763442b510b8a339aca494e9a54654f9519d247b118453ade12b387f43eb0baf372f426a48b6e7fd9b88009b82996d7b25f
|
7
|
+
data.tar.gz: 9514483542a6b69fbd11a0caea40ddc4561247b8c6ce2b7c3997a4f275e5c68cdbcaf4aea9302b324f5c65a3a4d4316bd5c8f7de1eee6d4d2f2ed034cafce77b
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module CodeAssertions
|
2
|
+
class CodeAssertionFailed < StandardError; end
|
3
|
+
@@assertions_check = true
|
4
|
+
|
5
|
+
def assertions_off
|
6
|
+
@@assertions_check = false
|
7
|
+
end
|
8
|
+
|
9
|
+
def assert(message="Assertion failed", &block)
|
10
|
+
return unless @@assertions_check
|
11
|
+
|
12
|
+
raise CodeAssertionFailed, message unless block.call
|
13
|
+
end
|
14
|
+
|
15
|
+
def assert_not_nil(object)
|
16
|
+
assert("The result cannot be `nil` or `false`. #{object} given") { object }
|
17
|
+
end
|
18
|
+
|
19
|
+
def assert_type(type, object)
|
20
|
+
assert("`type` should be an instance of `Class`") { type.is_a?(Class) }
|
21
|
+
assert("Wrong type: expected #{type.name}, given #{object.class.name}") { object.is_a?(type) }
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: code-assertions
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.0'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Simone Scalabrino
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-10-18 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Provides a module that helps to make solid scripts for data analysis
|
14
|
+
email: s.scalabrino9@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/code-assertions.rb
|
20
|
+
homepage: ''
|
21
|
+
licenses: []
|
22
|
+
metadata: {}
|
23
|
+
post_install_message:
|
24
|
+
rdoc_options: []
|
25
|
+
require_paths:
|
26
|
+
- lib
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '0'
|
32
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
requirements: []
|
38
|
+
rubyforge_project:
|
39
|
+
rubygems_version: 2.7.7
|
40
|
+
signing_key:
|
41
|
+
specification_version: 4
|
42
|
+
summary: Simple code assertions toolkit for scripts
|
43
|
+
test_files: []
|