eitil 1.1.39 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/eitil_core/lib/eitil_core/argument_helpers/args_to_h.rb +1 -1
  4. data/eitil_core/lib/eitil_core/argument_helpers/args_to_h_bang.rb +1 -1
  5. data/lib/eitil/railtie.rb +1 -1
  6. data/lib/eitil/version.rb +1 -1
  7. data/spec/eitil_core/argument_helpers/all_args_to_ivars_bang_spec.rb +19 -0
  8. data/spec/eitil_core/argument_helpers/all_args_to_ivars_spec.rb +19 -0
  9. data/spec/eitil_core/argument_helpers/all_kwargs_to_ivars_bang_spec.rb +34 -0
  10. data/spec/eitil_core/argument_helpers/all_kwargs_to_ivars_spec.rb +34 -0
  11. data/spec/eitil_core/argument_helpers/args_to_h_bang_spec.rb +16 -0
  12. data/spec/eitil_core/argument_helpers/args_to_h_spec.rb +16 -0
  13. data/spec/eitil_core/argument_helpers/args_to_ivars_bang_spec.rb +49 -0
  14. data/spec/eitil_core/argument_helpers/args_to_ivars_spec.rb +49 -0
  15. data/spec/eitil_core/array/map_strings_spec.rb +24 -0
  16. data/spec/eitil_core/array/slice_hashes_spec.rb +13 -0
  17. data/spec/eitil_core/datetime/prettify_spec.rb +11 -0
  18. data/spec/eitil_core/errors/raise_error_spec.rb +33 -0
  19. data/spec/eitil_core/float/safe_to_i_spec.rb +24 -0
  20. data/spec/eitil_core/formatters/duck_set_spec.rb +139 -0
  21. data/spec/eitil_core/formatters/sql_spec.rb +90 -0
  22. data/spec/eitil_core/hash/auto_dig_spec.rb +17 -0
  23. data/spec/eitil_core/hash/transform_string_values_spec.rb +25 -0
  24. data/spec/eitil_core/safe_executions/safe_call.rb +23 -0
  25. data/spec/eitil_core/safe_executions/safe_send.rb +25 -0
  26. data/spec/eitil_core/setters/set_ivars_spec.rb +28 -0
  27. data/spec/eitil_core/string/strip_base64_header_spec.rb +22 -0
  28. data/spec/eitil_core/string/to_filename_spec.rb +34 -0
  29. data/spec/eitil_core/type_checkers/is_num_or_nan_spec.rb +146 -0
  30. data/spec/spec_helper.rb +55 -0
  31. metadata +69 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8baf9893cc66d802a9cfa257b9f7e9d9773454837b397684e2b30c188400d2b
4
- data.tar.gz: c0f9b000df38b13078bfdc5b348f5e6e5f4732bfabfa96c0d972bd764134e069
3
+ metadata.gz: 252b7b936a8660cdb93a57240420fcdc07daef6dde073234b24876b2e7561ff7
4
+ data.tar.gz: 493bf9edf78fcbadedce713da8a1e950fd29fe6435749ce7290d93ff106e6083
5
5
  SHA512:
6
- metadata.gz: 3207e89a489f0f5fca78f2647ef1624b476e2b410a0c7fd5a8b67aa13f4db8bc9f7985a54622af6039bd92ba3b713195d8f218af7fe6d8a35dc48dc5844e5e88
7
- data.tar.gz: 68368b42bd8a8cf2b9b93c19d070dbefa378d73377012959d189d57a45c03c99b85f608bbfd0dc680cee9fee8e7ed090a8b51301500b666651da8e3851fa9d4f
6
+ metadata.gz: f5df34c162f68e7678e8a28fce0b2eb69e4c2a8abed637f80dd6db3bf614738166f3216e4db524e55daddd8c0c0b966748306c6438a3cb4c9cf1f087b951537b
7
+ data.tar.gz: 1f7f4a60c35e4040b3e0299f76fedc3130f96f9eb76abddc894837d20339c05e67ea4dfff02bcd80ea2f3eec945b982e323d8712307d219fcf7988096339b45b
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
@@ -6,7 +6,7 @@ Kernel.module_eval do
6
6
  def args_to_h(local_binding, *local_vars)
7
7
 
8
8
  local_vars.reject { |lvar| lvar == local_binding }
9
- .reject { |lvar| lvar.to_s.starts_with?('_') }
9
+ .reject { |lvar| lvar.to_s.start_with?('_') }
10
10
  .map { |lvar| { "#{lvar}": local_binding.local_variable_get(lvar) } }
11
11
  .inject &:merge
12
12
 
@@ -8,7 +8,7 @@ Kernel.module_eval do
8
8
 
9
9
  def args_to_h!(*local_vars)
10
10
 
11
- local_vars.reject { |lvar| lvar.to_s.starts_with?('_') }
11
+ local_vars.reject { |lvar| lvar.to_s.start_with?('_') }
12
12
  .map { |lvar| { "#{lvar}": binding.of_caller(2).local_variable_get(lvar) } }
13
13
  .inject &:merge
14
14
 
data/lib/eitil/railtie.rb CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  module Eitil
7
7
 
8
- Root = Gem.loaded_specs['eitil'].full_gem_path
8
+ Root = Gem.loaded_specs['eitil']&.full_gem_path
9
9
  Layers = %w( eitil_core eitil_support eitil_wrapper eitil_store eitil_integrate )
10
10
  ApplicationRecordModules = []
11
11
 
data/lib/eitil/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Eitil
2
2
 
3
- VERSION = '1.1.39'
3
+ VERSION = '1.2.3'
4
4
 
5
5
  end
@@ -0,0 +1,19 @@
1
+
2
+ RSpec.describe "Kernel#all_args_to_ivars!" do
3
+
4
+ it "should set all positional arguments as instance variables" do
5
+
6
+ def test_method(a, b, c)
7
+ all_args_to_ivars!
8
+ end
9
+
10
+ test_method(1, "two", :three)
11
+
12
+ expect(@a).to eq 1
13
+ expect(@b).to eq "two"
14
+ expect(@c).to eq :three
15
+ expect(@d).to be_nil
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,19 @@
1
+
2
+ RSpec.describe "Kernel#all_args_to_ivars" do
3
+
4
+ it "should set all positional arguments as instance variables" do
5
+
6
+ def test_method(a, b, c)
7
+ all_args_to_ivars binding
8
+ end
9
+
10
+ test_method(1, "two", :three)
11
+
12
+ expect(@a).to eq 1
13
+ expect(@b).to eq "two"
14
+ expect(@c).to eq :three
15
+ expect(@d).to be_nil
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,34 @@
1
+
2
+ RSpec.describe "Kernel#all_kwargs_to_ivars!" do
3
+
4
+ it "should set all hash keys, nested within a positional hash, to instance variables" do
5
+
6
+ def test_method(a, b, c, kwargs)
7
+ all_kwargs_to_ivars! :kwargs
8
+ end
9
+
10
+ test_method(1, "two", :three, {a: 0, b: "not_two", c: :not_three})
11
+
12
+ expect(@a).to eq 0
13
+ expect(@b).to eq "not_two"
14
+ expect(@c).to eq :not_three
15
+ expect(@d).to be_nil
16
+
17
+ end
18
+
19
+ it "should set all hash keys, nested within a keyword hash, to instance variables" do
20
+
21
+ def test_method(a, b, c, kwargs:)
22
+ all_kwargs_to_ivars! :kwargs
23
+ end
24
+
25
+ test_method(1, "two", :three, kwargs: {a: 0, b: "not_two", c: :not_three})
26
+
27
+ expect(@a).to eq 0
28
+ expect(@b).to eq "not_two"
29
+ expect(@c).to eq :not_three
30
+ expect(@d).to be_nil
31
+
32
+ end
33
+
34
+ end
@@ -0,0 +1,34 @@
1
+
2
+ RSpec.describe "Kernel#all_kwargs_to_ivars" do
3
+
4
+ it "should set all hash keys, nested within a positional hash, to instance variables" do
5
+
6
+ def test_method(a, b, c, kwargs)
7
+ all_kwargs_to_ivars binding, :kwargs
8
+ end
9
+
10
+ test_method(1, "two", :three, {a: 0, b: "not_two", c: :not_three})
11
+
12
+ expect(@a).to eq 0
13
+ expect(@b).to eq "not_two"
14
+ expect(@c).to eq :not_three
15
+ expect(@d).to be_nil
16
+
17
+ end
18
+
19
+ it "should set all hash keys, nested within a keyword hash, to instance variables" do
20
+
21
+ def test_method(a, b, c, kwargs:)
22
+ all_kwargs_to_ivars binding, :kwargs
23
+ end
24
+
25
+ test_method(1, "two", :three, kwargs: {a: 0, b: "not_two", c: :not_three})
26
+
27
+ expect(@a).to eq 0
28
+ expect(@b).to eq "not_two"
29
+ expect(@c).to eq :not_three
30
+ expect(@d).to be_nil
31
+
32
+ end
33
+
34
+ end
@@ -0,0 +1,16 @@
1
+
2
+ RSpec.describe "Kernel#args_to_h!" do
3
+
4
+ it "should create an hash, with the local variables as key / value pairs" do
5
+
6
+ a = 1
7
+ b = "two"
8
+ c = :three
9
+
10
+ created_hash = args_to_h! :a, :c
11
+ expected_hash = {a: 1, c: :three}
12
+
13
+ expect(created_hash).to eq expected_hash
14
+
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+
2
+ RSpec.describe "Kernel#args_to_h" do
3
+
4
+ it "should create an hash, with the local variables as key / value pairs" do
5
+
6
+ a = 1
7
+ b = "two"
8
+ c = :three
9
+
10
+ created_hash = args_to_h(binding, :a, :c)
11
+ expected_hash = {a: 1, c: :three}
12
+
13
+ expect(created_hash).to eq expected_hash
14
+
15
+ end
16
+ end
@@ -0,0 +1,49 @@
1
+
2
+ RSpec.describe "Kernel#args_to_ivars!" do
3
+
4
+ it "should set the given positional arguments to instance variables" do
5
+
6
+ def test_method(a, b, c)
7
+ args_to_ivars! :a, :c
8
+ end
9
+
10
+ test_method(1, "two", :three)
11
+
12
+ expect(@a).to eq 1
13
+ expect(@b).to be_nil
14
+ expect(@c).to eq :three
15
+ expect(@d).to be_nil
16
+
17
+ end
18
+
19
+ it "should set the given keyword arguments to instance variables" do
20
+
21
+ def test_method(a:, b:, c:)
22
+ args_to_ivars! :a, :c
23
+ end
24
+
25
+ test_method(a: 1, b: "two", c: :three)
26
+
27
+ expect(@a).to eq 1
28
+ expect(@b).to be_nil
29
+ expect(@c).to eq :three
30
+ expect(@d).to be_nil
31
+
32
+ end
33
+
34
+ it "should set the given local variables to instance variables" do
35
+
36
+ a = 1
37
+ b = "two"
38
+ c = :three
39
+
40
+ args_to_ivars! :a, :c
41
+
42
+ expect(@a).to eq 1
43
+ expect(@b).to be_nil
44
+ expect(@c).to eq :three
45
+ expect(@d).to be_nil
46
+
47
+ end
48
+
49
+ end
@@ -0,0 +1,49 @@
1
+
2
+ RSpec.describe "Kernel#args_to_ivars" do
3
+
4
+ it "should set the given positional arguments to instance variables" do
5
+
6
+ def test_method(a, b, c)
7
+ args_to_ivars binding, :a, :c
8
+ end
9
+
10
+ test_method(1, "two", :three)
11
+
12
+ expect(@a).to eq 1
13
+ expect(@b).to be_nil
14
+ expect(@c).to eq :three
15
+ expect(@d).to be_nil
16
+
17
+ end
18
+
19
+ it "should set the given keyword arguments to instance variables" do
20
+
21
+ def test_method(a:, b:, c:)
22
+ args_to_ivars binding, :a, :c
23
+ end
24
+
25
+ test_method(a: 1, b: "two", c: :three)
26
+
27
+ expect(@a).to eq 1
28
+ expect(@b).to be_nil
29
+ expect(@c).to eq :three
30
+ expect(@d).to be_nil
31
+
32
+ end
33
+
34
+ it "should set the given local variables to instance variables" do
35
+
36
+ a = 1
37
+ b = "two"
38
+ c = :three
39
+
40
+ args_to_ivars binding, :a, :c
41
+
42
+ expect(@a).to eq 1
43
+ expect(@b).to be_nil
44
+ expect(@c).to eq :three
45
+ expect(@d).to be_nil
46
+
47
+ end
48
+
49
+ end
@@ -0,0 +1,24 @@
1
+
2
+ RSpec.describe "Array#map_strings" do
3
+
4
+ it "should transforms all strings in infinite recursion" do
5
+
6
+ array = ["hey", ["hi", {a: "ho", b: {d: "he"}}]]
7
+ result = array.map_strings { |str| str.upcase }
8
+
9
+ expect(result).to eq ["HEY", ["HI", {a: "HO", b: {d: "HE"}}]]
10
+
11
+ end
12
+ end
13
+
14
+ RSpec.describe "Array#map_strings!" do
15
+
16
+ it "should transforms all strings in infinite recursion" do
17
+
18
+ array = ["hey", ["hi", {a: "ho", b: {d: "he"}}]]
19
+ array.map_strings! { |str| str.upcase }
20
+
21
+ expect(array).to eq ["HEY", ["HI", {a: "HO", b: {d: "HE"}}]]
22
+
23
+ end
24
+ end
@@ -0,0 +1,13 @@
1
+
2
+ RSpec.describe "Array#slice_hashes" do
3
+
4
+ it "should slice each hash in an array of hashes with the given keys" do
5
+
6
+ array = [{"a"=>1, "b"=>2, "c"=>3}, {"a"=>1, "b"=>2, "c"=>3}]
7
+ result = array.slice_hashes("a", "b")
8
+ expected = [{"a"=>1, "b"=>2}, {"a"=>1, "b"=>2}]
9
+
10
+ expect(result).to eq expected
11
+
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+
2
+ RSpec.describe "DateTime#prettify" do
3
+
4
+ it "should represent a DateTime instance in the '%Y-%m-%d.%H:%M:%S' format" do
5
+
6
+ datetime = DateTime.parse("01-01-2020, 10:00:00, +0200")
7
+
8
+ expect(datetime.prettify).to eq "2020-01-01.10:00:00"
9
+
10
+ end
11
+ end
@@ -0,0 +1,33 @@
1
+
2
+ RSpec.describe "Kernel#raise_error" do
3
+
4
+ # Call specs directly on Kernel, which you would usually do implicit
5
+ # instead of explicit, in order to escape the RSpec namespace, which has
6
+ # it's own effects for raised errors
7
+
8
+ it "should define a new constant, if the error class does not yet exist" do
9
+
10
+ begin
11
+ Kernel.raise_error "ThisErrorWillProbablyNotExistError"
12
+ rescue
13
+ end
14
+
15
+ expect(Kernel.const_defined?('ThisErrorWillProbablyNotExistError')).to eq true
16
+
17
+ end
18
+
19
+ it "should call an existing constant, if the error class already exists" do
20
+
21
+ expect(Kernel.const_defined?('StandardError'))
22
+ initial_const_count = Module.constants.count
23
+
24
+ begin
25
+ Kernel.raise_error "StandardError"
26
+ rescue
27
+ end
28
+
29
+ expect(Module.constants.count).to eq initial_const_count
30
+
31
+ end
32
+
33
+ end
@@ -0,0 +1,24 @@
1
+
2
+ RSpec.describe "Float#safe_to_i" do
3
+
4
+ it "should convert a float to an integer, if the float is rounded (e.g. 7.0)" do
5
+
6
+ float = 7.0
7
+ result = float.safe_to_i
8
+
9
+ expect(result).to eq 7
10
+ expect(result).to be_a Integer
11
+
12
+ end
13
+
14
+ it "should not convert a float to an integer, if the float is not rounded (e.g. 7.1)" do
15
+
16
+ float = 7.1
17
+ result = float.safe_to_i
18
+
19
+ expect(result).to eq 7.1
20
+ expect(result).to be_a Float
21
+
22
+ end
23
+
24
+ end
@@ -0,0 +1,139 @@
1
+
2
+ RSpec.describe "Date.duck_set(object)" do
3
+
4
+ let(:date) { Date.duck_set(@object) }
5
+
6
+ it "should return the object, if the object is a Date instance" do
7
+ @object = Date.today
8
+ expect(date).to eq @object
9
+ expect(date).to be_a Date
10
+ end
11
+
12
+ it "should return a Date instance, if the object is a String instance" do
13
+ @object = "2020-01-01"
14
+ expect(@object).to be_a String
15
+ expect(date).to be_a Date
16
+ end
17
+
18
+
19
+ it "should return a Date instance, if the object is a DateTime instance" do
20
+ @object = DateTime.now
21
+ expect(@object).to be_a DateTime
22
+ expect(date).to be_a Date
23
+ end
24
+
25
+
26
+ it "should return a Date instance, if the object is a Time instance" do
27
+ @object = Time.now
28
+ expect(@object).to be_a Time
29
+ expect(date).to be_a Date
30
+ end
31
+
32
+
33
+ it "should raise an error, if the object's class is not one of: String, Date, DateTime, Time" do
34
+ @object = 2020
35
+ expect(@object).to be_a Integer
36
+ begin
37
+ error_raised = false
38
+ date
39
+ rescue
40
+ error_raised = true
41
+ end
42
+ expect(error_raised).to eq true
43
+ end
44
+
45
+ end
46
+
47
+
48
+ RSpec.describe "DateTime.duck_set(object)" do
49
+
50
+ let(:datetime) { DateTime.duck_set(@object) }
51
+
52
+ it "should return the object, if the object is a DateTime instance" do
53
+ @object = DateTime.now
54
+ expect(datetime).to eq @object
55
+ expect(datetime).to be_a DateTime
56
+ end
57
+
58
+ it "should return a DateTime instance, if the object is a String instance" do
59
+ @object = "2020-01-01"
60
+ expect(@object).to be_a String
61
+ expect(datetime).to be_a DateTime
62
+ end
63
+
64
+
65
+ it "should return a DateTime instance, if the object is a Date instance" do
66
+ @object = Date.today
67
+ expect(@object).to be_a Date
68
+ expect(datetime).to be_a DateTime
69
+ end
70
+
71
+
72
+ it "should return a DateTime instance, if the object is a Time instance" do
73
+ @object = Time.now
74
+ expect(@object).to be_a Time
75
+ expect(datetime).to be_a DateTime
76
+ end
77
+
78
+
79
+ it "should raise an error, if the object's class is not one of: String, DateTime, Date, Time" do
80
+ @object = 2020
81
+ expect(@object).to be_a Integer
82
+ begin
83
+ error_raised = false
84
+ datetime
85
+ rescue
86
+ error_raised = true
87
+ end
88
+ expect(error_raised).to eq true
89
+ end
90
+
91
+ end
92
+
93
+
94
+
95
+ RSpec.describe "Time.duck_set(object)" do
96
+
97
+ let(:time) { Time.duck_set(@object) }
98
+
99
+ it "should return the object, if the object is a Time instance" do
100
+ @object = Time.now
101
+ expect(time).to eq @object
102
+ expect(time).to be_a Time
103
+ end
104
+
105
+ it "should return a Time instance, if the object is a String instance" do
106
+ @object = "20:00"
107
+ expect(@object).to be_a String
108
+ expect(time).to be_a Time
109
+ end
110
+
111
+
112
+ it "should return a Time instance, if the object is a Date instance" do
113
+ @object = Date.today
114
+ expect(@object).to be_a Date
115
+ expect(time).to be_a Time
116
+ end
117
+
118
+
119
+ it "should return a Time instance, if the object is a DateTime instance" do
120
+ @object = DateTime.now
121
+ expect(@object).to be_a DateTime
122
+ expect(time).to be_a Time
123
+ end
124
+
125
+
126
+ it "should raise an error, if the object's class is not one of: String, DateTime, Date, Time" do
127
+ @object = 2020
128
+ expect(@object).to be_a Integer
129
+ begin
130
+ error_raised = false
131
+ time
132
+ rescue
133
+ error_raised = true
134
+ end
135
+ expect(error_raised).to eq true
136
+ end
137
+
138
+ end
139
+
@@ -0,0 +1,90 @@
1
+
2
+ RSpec.describe "Date#strfsql(type)" do
3
+
4
+ let(:date) { Date.parse('01-01-2020').strfsql(@type) }
5
+
6
+ it "should by default format a Date instance to '%Y-%m-%d'" do
7
+ date = Date.parse('01-01-2020').strfsql
8
+ expect(date).to eq '2020-01-01'
9
+ end
10
+
11
+ it "should format a Date instance to '%Y-%m-%d', if :date is given as type" do
12
+ @type = :date
13
+ expect(date).to eq '2020-01-01'
14
+ end
15
+
16
+ it "should simply return nil if an invalid type is given" do
17
+ @type = 666
18
+ expect(date).to be_nil
19
+ end
20
+
21
+ end
22
+
23
+
24
+ RSpec.describe "DateTime#strfsql(type)" do
25
+
26
+ let(:datetime) { DateTime.parse('01-01-2020').strfsql(@type) }
27
+
28
+ it "should by default format a DateTime instance to '%Y-%m-%d %H:%M:%S.%6N'" do
29
+ datetime = DateTime.parse('01-01-2020').strfsql
30
+ expect(datetime).to eq "2020-01-01 00:00:00.000000"
31
+ end
32
+
33
+ it "should format a DateTime instance to '%Y-%m-%d %H:%M:%S.%6N', if :datetime is given as type" do
34
+ @type = :datetime
35
+ expect(datetime).to eq "2020-01-01 00:00:00.000000"
36
+ end
37
+
38
+
39
+ it "should format a DateTime instance to '%Y-%m-%d', if :date is given as type" do
40
+ @type = :date
41
+ expect(datetime).to eq "2020-01-01"
42
+ end
43
+
44
+
45
+ it "should format a DateTime instance to '%H:%M:%S', if :time is given as type" do
46
+ @type = :time
47
+ expect(datetime).to eq "00:00:00"
48
+ end
49
+
50
+ it "should simply return nil if an invalid type is given" do
51
+ @type = 666
52
+ expect(datetime).to be_nil
53
+ end
54
+
55
+ end
56
+
57
+
58
+
59
+ RSpec.describe "Time#strfsql(type)" do
60
+
61
+ let(:time) { Time.parse('01-01-2020 20:00:00 +0200').strfsql(@type) }
62
+
63
+ it "should by default format a Time instance to '%Y-%m-%d %H:%M:%S.%6N'" do
64
+ time = Time.parse('01-01-2020 20:00:00 +0200').strfsql
65
+ expect(time).to eq "20:00:00"
66
+ end
67
+
68
+ it "should format a Time instance to '%Y-%m-%d %H:%M:%S.%6N', if :datetime is given as type" do
69
+ @type = :datetime
70
+ expect(time).to eq "2020-01-01 20:00:00.000000"
71
+ end
72
+
73
+
74
+ it "should format a Time instance to '%Y-%m-%d', if :date is given as type" do
75
+ @type = :date
76
+ expect(time).to eq "2020-01-01"
77
+ end
78
+
79
+
80
+ it "should format a Time instance to '%H:%M:%S', if :time is given as type" do
81
+ @type = :time
82
+ expect(time).to eq "20:00:00"
83
+ end
84
+
85
+ it "should simply return nil if an invalid type is given" do
86
+ @type = 666
87
+ expect(time).to be_nil
88
+ end
89
+
90
+ end
@@ -0,0 +1,17 @@
1
+
2
+ RSpec.describe "Hash#auto_dig" do
3
+
4
+ it "should recursively find the value for the given hash key" do
5
+ hash = {a: 1, b: {c: 2, d: {e: 3}}}
6
+ result = hash.auto_dig :e
7
+ expect(result).to eq 3
8
+ end
9
+
10
+
11
+ it "should return nil if the given hash key is not present" do
12
+ hash = {a: 1, b: {c: 2, d: {e: 3}}}
13
+ result = hash.auto_dig :f
14
+ expect(result).to be_nil
15
+ end
16
+
17
+ end
@@ -0,0 +1,25 @@
1
+
2
+ RSpec.describe "Hash#transform_string_values" do
3
+
4
+ it "should transforms all strings in infinite recursion" do
5
+ hash = {a: "hey", b: {c: "hi", d: ["ho"]}}
6
+ expected = {a: "HEY", b: {c: "HI", d: ["HO"]}}
7
+ result = hash.transform_string_values { |str| str.upcase }
8
+
9
+ expect(result).to eq expected
10
+ end
11
+
12
+ end
13
+
14
+
15
+ RSpec.describe "Hash#transform_string_values!" do
16
+
17
+ it "should transforms all strings in infinite recursion" do
18
+ hash = {a: "hey", b: {c: "hi", d: ["ho"]}}
19
+ expected = {a: "HEY", b: {c: "HI", d: ["HO"]}}
20
+
21
+ hash.transform_string_values! { |str| str.upcase }
22
+ expect(hash).to eq expected
23
+ end
24
+
25
+ end
@@ -0,0 +1,23 @@
1
+
2
+ # For some reason, the Kernel patches – which ruby mixes into Object – are not
3
+ # available to the tests, therefore load the file manually.
4
+ load (Eitil::Root + "/eitil_core/lib/eitil_core/safe_executions/safe_call.rb")
5
+
6
+ RSpec.describe "Object#safe_call" do
7
+
8
+ it "should return the block's yield value, if no error is raised" do
9
+ result = Object.new.safe_call { 1 + 1 }
10
+ expect(result).to eq 2
11
+ end
12
+
13
+ it "should by default return nil, if an error is raised" do
14
+ result = Object.new.safe_call { raise(StandardError) }
15
+ expect(result).to be_nil
16
+ end
17
+
18
+ it "should return the specified :return_value, if an error is raised" do
19
+ result = Object.new.safe_call(return_value: :something_else) { raise(StandardError) }
20
+ expect(result).to eq :something_else
21
+ end
22
+
23
+ end
@@ -0,0 +1,25 @@
1
+
2
+ # For some reason, the Kernel patches – which ruby mixes into string – are not
3
+ # available to the tests, therefore load the file manually.
4
+ load (Eitil::Root + "/eitil_core/lib/eitil_core/safe_executions/safe_send.rb")
5
+
6
+ RSpec.describe "Object#safe_send" do
7
+
8
+ let(:string) { "Hiya, Cowboy!" }
9
+
10
+ it "should return the method's return value, if no error is raised" do
11
+ result = string.safe_send(:upcase)
12
+ expect(result).to eq "HIYA, COWBOY!"
13
+ end
14
+
15
+ it "should by default return nil, if an error is raised" do
16
+ result = string.safe_send(:this_method_does_probably_not_exist)
17
+ expect(result).to be_nil
18
+ end
19
+
20
+ it "should return the specified :return_value, if an error is raised" do
21
+ result = string.safe_send(:this_method_does_probably_not_exist, return_value: :something_else)
22
+ expect(result).to eq :something_else
23
+ end
24
+
25
+ end
@@ -0,0 +1,28 @@
1
+
2
+ RSpec.describe "Object#set_ivars" do
3
+
4
+ def set_ivar_one
5
+ :one
6
+ end
7
+
8
+ def set_ivar_two
9
+ 2
10
+ end
11
+
12
+ it 'should call a method .set_#{ivar_name}, for every :ivar_name passed' do
13
+ set_ivars :ivar_one, :ivar_two
14
+ expect(@ivar_one).to eq :one
15
+ expect(@ivar_two).to eq 2
16
+ end
17
+
18
+ it "should return an array of symbols, which the names of all ivars being set" do
19
+ return_value = set_ivars :ivar_one, :ivar_two
20
+ expect(return_value).to eq [:ivar_one, :ivar_two]
21
+ end
22
+
23
+ it "should return an empty array, if no arguments are passed" do
24
+ expect(set_ivars).to eq []
25
+ end
26
+
27
+
28
+ end
@@ -0,0 +1,22 @@
1
+
2
+ RSpec.describe "String#strip_base64_header" do
3
+
4
+ let(:regex) { EitilStore::Regex::LeadingBase64Data }
5
+ let(:b64_string) { "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfQAAADICAYAAAAeGRPoAAAgAElEQVR4Xu2dC8w0VXnH/8dLrfWKFbxHUYIGNICKVRuDWmxtWgumQoqXAKmIoSoUi6JNhS8mVnvhUm8VtYKp1UJbQIz3RDCNxIgCVrxQyk1Co2gBxVYRPc3/vGeGmX333Z3dnZmd3f2d5M33vbsz5/I7833/ec55zvMEzV3ie7ZuDcfNXQU3QgACEIAABCDQCoEwXy3xlZLen+89RgofmK8e7oIABCAAAQhAoA0C8wr6gyXdmjuwmxRua6Mz1AEBCEAAAhCAwHwE5hT0+RrjLghAAAIQgAAEui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5srr9Y0vZIu6fYpm8wFKItgU6L/Wnvswo2PNSTlaq2312tlB9rtrLzYUlfEm29t3AI7dWL0rr1ycA/Lut3eq4inH7i+rnxbJ9dfl+tOO20P9D0mslXSvpHvmCcRZ6Ydl7Cdz99u/XSLLvgLcPzHZSW9W2bcXbmnfxmL1Kk8c2L1vugwAEIACBUQIdCnqyzG3xthA0JlneFhALohO43Clp78pgrszLyRXx3jRHs74f7vhESY8YeSkoltr9sUXbL1DFy0HfHaQ9CEAAAhtFoCNBjxZx/2e+gJiXDlQ5NGyaF1uGFm0fdXJKTb8wYO1t1CPLYCEAAQhAYByBDgQ9WeY+ijXjPnJaRi8s8OLeQsC9/+4fCzhpVXmWIQABCEAAAiMEWhb0lM/cVrnjszcU3nSP98L9p0Xd5cy8ZLsEr3ieEQhAAAIQgMDqEWhR0JOF7WXwo6c7waXldIu4LXHfZ0s8W+FtO9Ct3qTQYwhAAAIQgMCsBNoUdFvY528FUBm1zmvL6VVL/Jws5Fjis84c10MAAhCAAAQqBNoUdHuiO/jIHZIuqxzPKgK7uFlb4nZiK6zxhsvyzBkEIAABCEAAApMItCjobia+TNJh+Vx40a6PLVnE/TOgsK88GBCAAAQgAIH1IdCyoK8PGEYCAQhAAAIQWCUCCPoqzRZ9hQAEIAABCOxAAEHn0YAABCAAAQisAQEEfQ0mkSFAAAIQgAAEEHSeAQhAAAIQgMAaEEDQ12ASGQIEIAABCEAAQecZgAAEIAABCKwBgf8HUo6dI5/5V1kAAAAASUVORK5CYII=" }
6
+ let(:normal_string) { "IAmJustANormalStringDoingNormalThings" }
7
+
8
+ it "should retrieve the Regexp LeadingBase64Data" do
9
+ expect(regex).to be_a Regexp
10
+ end
11
+
12
+ it "should detect a base_64 string" do
13
+ result = b64_string =~ regex
14
+ expect(result).to be_a Integer
15
+ end
16
+
17
+ it "should leave a normal string untouched" do
18
+ result = normal_string =~ regex
19
+ expect(result).to be_nil
20
+ end
21
+
22
+ end
@@ -0,0 +1,34 @@
1
+
2
+ RSpec.describe "String#to_filename(substitute='_')" do
3
+
4
+ it "should substitute all spaces with, by default, lowdashes" do
5
+ string = "this is a filename"
6
+ expect(string.to_filename).to eq "this_is_a_filename"
7
+ end
8
+
9
+ it "should substitute all spaces with, if given, the substitute argument" do
10
+ string = "this is a filename"
11
+ expect(string.to_filename('-')).to eq "this-is-a-filename"
12
+ end
13
+
14
+ it "should substitute all slashes with, by default, lowdashes" do
15
+ string = "this/is/a/filename"
16
+ expect(string.to_filename).to eq "this_is_a_filename"
17
+ end
18
+
19
+ it "should substitute all slashes with, if given, the substitute argument" do
20
+ string = "this/is/a/filename"
21
+ expect(string.to_filename('-')).to eq "this-is-a-filename"
22
+ end
23
+
24
+ it "should substitute all backslashes with, by default, lowdashes" do
25
+ string = 'this\is\a\filename'
26
+ expect(string.to_filename).to eq "this_is_a_filename"
27
+ end
28
+
29
+ it "should substitute all backslashes with, if given, the substitute argument" do
30
+ string = 'this\is\a\filename'
31
+ expect(string.to_filename('-')).to eq "this-is-a-filename"
32
+ end
33
+
34
+ end
@@ -0,0 +1,146 @@
1
+
2
+ RSpec.describe "#is_num? and #is_nan?" do
3
+
4
+ context "for String" do
5
+
6
+ it "#is_num? should return true for '5' (integers)" do
7
+ expect('5'.is_num?).to be_truthy
8
+ end
9
+
10
+ it "#is_num? should return true for '5.0' (floats) " do
11
+ expect('5.0'.is_num?).to be_truthy
12
+ end
13
+
14
+ it "#is_num? should return true for '5,0' (floats, separated by comma) " do
15
+ expect('5,0'.is_num?).to be_truthy
16
+ end
17
+
18
+ it "#is_num? should return false for valid values, '5a' (concatenated with additional letters)" do
19
+ expect('5a'.is_num?).to be_falsy
20
+ expect('5.0a'.is_num?).to be_falsy
21
+ expect('5,0a'.is_num?).to be_falsy
22
+ end
23
+
24
+ it "#is_nan? should return the opposite" do
25
+ expect('5'.is_nan?).to be_falsy
26
+ expect('5.0'.is_nan?).to be_falsy
27
+ expect('5,0'.is_nan?).to be_falsy
28
+ expect('5a'.is_nan?).to be_truthy
29
+ expect('5.0a'.is_nan?).to be_truthy
30
+ expect('5,0a'.is_nan?).to be_truthy
31
+ end
32
+
33
+ end
34
+
35
+ context "for Numeric" do
36
+
37
+ it "#is_num? should always return true" do
38
+ expect(1.is_num?).to be_truthy
39
+ expect(1.0.is_num?).to be_truthy
40
+ end
41
+
42
+ it "#is_nan? should always return false" do
43
+ expect(1.is_nan?).to be_falsy
44
+ expect(1.0.is_nan?).to be_falsy
45
+ end
46
+
47
+ end
48
+
49
+ context "for NilClass" do
50
+
51
+ it "#is_num? should always return false" do
52
+ expect(nil.is_num?).to be_falsy
53
+ end
54
+
55
+ it "#is_nan? should always return true" do
56
+ expect(nil.is_nan?).to be_truthy
57
+ end
58
+
59
+ end
60
+
61
+ context "for TrueClass" do
62
+
63
+ it "#is_num? should always return false" do
64
+ expect(true.is_num?).to be_falsy
65
+ end
66
+
67
+ it "#is_nan? should always return true" do
68
+ expect(true.is_nan?).to be_truthy
69
+ end
70
+
71
+ end
72
+
73
+ context "for FalseClass" do
74
+
75
+ it "#is_num? should always return false" do
76
+ expect(false.is_num?).to be_falsy
77
+ end
78
+
79
+ it "#is_nan? should always return true" do
80
+ expect(false.is_nan?).to be_truthy
81
+ end
82
+
83
+ end
84
+
85
+ context "for Hash" do
86
+
87
+ it "#is_num? should always return false" do
88
+ expect({}.is_num?).to be_falsy
89
+ end
90
+
91
+ it "#is_nan? should always return true" do
92
+ expect({}.is_nan?).to be_truthy
93
+ end
94
+
95
+ end
96
+
97
+ context "for Array" do
98
+
99
+ it "#is_num? should always return false" do
100
+ expect([].is_num?).to be_falsy
101
+ end
102
+
103
+ it "#is_nan? should always return true" do
104
+ expect([].is_nan?).to be_truthy
105
+ end
106
+
107
+ end
108
+
109
+ context "for Date" do
110
+
111
+ it "#is_num? should always return false" do
112
+ expect(Date.today.is_num?).to be_falsy
113
+ end
114
+
115
+ it "#is_nan? should always return true" do
116
+ expect(Date.today.is_nan?).to be_truthy
117
+ end
118
+
119
+ end
120
+
121
+ context "for Time" do
122
+
123
+ it "#is_num? should always return false" do
124
+ expect(Time.now.is_num?).to be_falsy
125
+ end
126
+
127
+ it "#is_nan? should always return true" do
128
+ expect(Time.now.is_nan?).to be_truthy
129
+ end
130
+
131
+ end
132
+
133
+ context "for DateTime" do
134
+
135
+ it "#is_num? should always return false" do
136
+ expect(DateTime.now.is_num?).to be_falsy
137
+ end
138
+
139
+ it "#is_nan? should always return true" do
140
+ expect(DateTime.now.is_nan?).to be_truthy
141
+ end
142
+
143
+ end
144
+
145
+ end
146
+
@@ -0,0 +1,55 @@
1
+
2
+ require 'pry'
3
+ require 'rails'
4
+
5
+ require 'eitil'
6
+
7
+ # Implement specs for other railties later on, start with eitil_core.
8
+
9
+ require "eitil_core/railtie"
10
+ # require "eitil_store/railtie"
11
+ # require "eitil_integrate/railtie"
12
+ # require "eitil_support/railtie"
13
+ # require "eitil_wrapper/railtie"
14
+
15
+ require "eitil_core"
16
+ # require "eitil_store"
17
+ # require "eitil_integrate"
18
+ # require "eitil_support"
19
+ # require "eitil_wrapper"
20
+
21
+ RSpec.configure do |config|
22
+
23
+ config.expect_with :rspec do |expectations|
24
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
25
+ end
26
+
27
+ config.mock_with :rspec do |mocks|
28
+ mocks.verify_partial_doubles = true
29
+ end
30
+
31
+ end
32
+
33
+ # This block is added by us: the new methods .pry_describe and .pry_it
34
+ # automatically start a pry session after running the spec, allowing
35
+ # you to inspect the application's post spec state.
36
+ RSpec.configure do |config|
37
+
38
+ config.alias_example_group_to :pry_describe, pry: true
39
+ config.alias_example_group_to :pry_context, pry: true
40
+ config.alias_example_to :pry_it, pry: true
41
+ config.alias_example_to :pry_example, pry: true
42
+ config.alias_example_to :pry_specify, pry: true
43
+
44
+ config.after(:example, pry: true) do |example|
45
+ require 'pry'
46
+ binding.pry
47
+ end
48
+
49
+ end
50
+
51
+ # This is added by us, in order to set the :documentation formatter,
52
+ # which gives quite a lot of information about the tests, as default
53
+ RSpec.configure do |config|
54
+ config.formatter = :documentation
55
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eitil
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.39
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jurriaan Schrofer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-03 00:00:00.000000000 Z
11
+ date: 2021-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -66,6 +66,48 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 5.0.2
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 5.0.2
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry-rails
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
69
111
  description: "Eitil (eitje utility) never stops increasing your life's efficacy and
70
112
  productivity, yay!\n Our gem currently exists of five seperate
71
113
  layers (Railties), which can be integrated as standalone gems. \n This
@@ -77,6 +119,7 @@ executables: []
77
119
  extensions: []
78
120
  extra_rdoc_files: []
79
121
  files:
122
+ - ".rspec"
80
123
  - MIT-LICENSE
81
124
  - README.md
82
125
  - Rakefile
@@ -205,6 +248,30 @@ files:
205
248
  - lib/eitil/all.rb
206
249
  - lib/eitil/railtie.rb
207
250
  - lib/eitil/version.rb
251
+ - spec/eitil_core/argument_helpers/all_args_to_ivars_bang_spec.rb
252
+ - spec/eitil_core/argument_helpers/all_args_to_ivars_spec.rb
253
+ - spec/eitil_core/argument_helpers/all_kwargs_to_ivars_bang_spec.rb
254
+ - spec/eitil_core/argument_helpers/all_kwargs_to_ivars_spec.rb
255
+ - spec/eitil_core/argument_helpers/args_to_h_bang_spec.rb
256
+ - spec/eitil_core/argument_helpers/args_to_h_spec.rb
257
+ - spec/eitil_core/argument_helpers/args_to_ivars_bang_spec.rb
258
+ - spec/eitil_core/argument_helpers/args_to_ivars_spec.rb
259
+ - spec/eitil_core/array/map_strings_spec.rb
260
+ - spec/eitil_core/array/slice_hashes_spec.rb
261
+ - spec/eitil_core/datetime/prettify_spec.rb
262
+ - spec/eitil_core/errors/raise_error_spec.rb
263
+ - spec/eitil_core/float/safe_to_i_spec.rb
264
+ - spec/eitil_core/formatters/duck_set_spec.rb
265
+ - spec/eitil_core/formatters/sql_spec.rb
266
+ - spec/eitil_core/hash/auto_dig_spec.rb
267
+ - spec/eitil_core/hash/transform_string_values_spec.rb
268
+ - spec/eitil_core/safe_executions/safe_call.rb
269
+ - spec/eitil_core/safe_executions/safe_send.rb
270
+ - spec/eitil_core/setters/set_ivars_spec.rb
271
+ - spec/eitil_core/string/strip_base64_header_spec.rb
272
+ - spec/eitil_core/string/to_filename_spec.rb
273
+ - spec/eitil_core/type_checkers/is_num_or_nan_spec.rb
274
+ - spec/spec_helper.rb
208
275
  homepage: https://github.com/eitje-app/eitil_engine
209
276
  licenses:
210
277
  - MIT