eitil 1.3.1 → 1.3.5
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/eitil_core/README.md +60 -0
- data/eitil_core/lib/eitil_core/kernel/always_require_relative.rb +21 -0
- data/eitil_core/lib/eitil_core/kernel/loadquire.rb +25 -0
- data/eitil_core/lib/eitil_core/kernel/loadquire_bang.rb +26 -0
- data/eitil_core/lib/eitil_core/kernel.rb +3 -0
- data/eitil_core/lib/eitil_core/string/colorize.rb +30 -0
- data/eitil_core/lib/eitil_core/string.rb +1 -0
- data/eitil_core/lib/eitil_core.rb +1 -0
- data/eitil_wrapper/lib/eitil_wrapper/callbacks/helper_methods.rb +8 -1
- data/eitil_wrapper/lib/eitil_wrapper/scopes/default_scopes.rb +8 -1
- data/lib/eitil/version.rb +1 -1
- data/spec/dummy_app/db/test.sqlite3 +0 -0
- data/spec/eitil_core/string/colorize_spec.rb +91 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0a89a4609655c28ab6ee41d45b0c74d34b47d31cef1f494b0d942717cdf5371
|
4
|
+
data.tar.gz: 905882089b4723ee74710f4877eaecc612ac35c75b9ea954efd9edeb656d8cda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d395e454f20dffb4d7f4a5b9d77944fdbb4603013e5c562ad09d4768642a5df4b98fe8b2e6a10510535b0428aa6f506edab944a787954a8847cac27480df4da
|
7
|
+
data.tar.gz: c117f0a635d79282a6b7d54dd72a71de77d054c209f25b3c4cd76aae7469320af507c1f35f25b6770041b7b3fbfe3198b9c193c2bec8ed51acf6115a4f75ddcf
|
data/eitil_core/README.md
CHANGED
@@ -385,6 +385,35 @@ transform_string_values!(&block)
|
|
385
385
|
# bang variant of .transform_string_values, which recursively modifies all objects it is called on.
|
386
386
|
```
|
387
387
|
|
388
|
+
|
389
|
+
## Kernel
|
390
|
+
|
391
|
+
```ruby
|
392
|
+
|
393
|
+
require "eitil_core/kernel"
|
394
|
+
|
395
|
+
```
|
396
|
+
|
397
|
+
```ruby
|
398
|
+
# require "eitil_core/kernel/loadquire"
|
399
|
+
|
400
|
+
loadquire(current_path, *relative_paths, ext: '.rb')
|
401
|
+
# use .loadquire to pickup code changes on reload in development environment, while not creating overhead in production through 'load' usage
|
402
|
+
# call as: loadquire __dir__, 'user'
|
403
|
+
# => loads '../user.rb' in development environment, requires '../user.rb' in all other environments
|
404
|
+
```
|
405
|
+
|
406
|
+
```ruby
|
407
|
+
# require "eitil_core/kernel/loadquire_bang"
|
408
|
+
|
409
|
+
loadquire!(*relative_paths, ext: '.rb')
|
410
|
+
# use .loadquire! to pickup code changes on reload in development environment, while not creating overhead in production through 'load' usage
|
411
|
+
# call as: loadquire! 'user'
|
412
|
+
# => loads '../user.rb' in development environment, requires '../user.rb' in all other environments
|
413
|
+
|
414
|
+
```
|
415
|
+
|
416
|
+
|
388
417
|
## Lookups
|
389
418
|
|
390
419
|
```ruby
|
@@ -495,6 +524,37 @@ require "eitil_core/string"
|
|
495
524
|
|
496
525
|
```
|
497
526
|
|
527
|
+
```ruby
|
528
|
+
# require "eitil_core/string/colorize"
|
529
|
+
|
530
|
+
# formats strings, so that they are styled when printed to the terminal.
|
531
|
+
|
532
|
+
'hi'.black
|
533
|
+
'hi'.red
|
534
|
+
'hi'.green
|
535
|
+
'hi'.brown
|
536
|
+
'hi'.blue
|
537
|
+
'hi'.magenta
|
538
|
+
'hi'.cyan
|
539
|
+
'hi'.gray
|
540
|
+
|
541
|
+
'hi'.bg_black
|
542
|
+
'hi'.bg_red
|
543
|
+
'hi'.bg_green
|
544
|
+
'hi'.bg_brown
|
545
|
+
'hi'.bg_blue
|
546
|
+
'hi'.bg_magenta
|
547
|
+
'hi'.bg_cyan
|
548
|
+
'hi'.bg_gray
|
549
|
+
|
550
|
+
'hi'.bold
|
551
|
+
'hi'.italic
|
552
|
+
'hi'.underline
|
553
|
+
'hi'.blink
|
554
|
+
'hi'.reverse_color
|
555
|
+
|
556
|
+
```
|
557
|
+
|
498
558
|
```ruby
|
499
559
|
# require "eitil_core/string/strip_base64_header"
|
500
560
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
# require "eitil_core/kernel/always_require_relative"
|
3
|
+
|
4
|
+
Kernel.module_eval do
|
5
|
+
|
6
|
+
def always_require_relative(current_path, relative_path, extension = '.rb')
|
7
|
+
|
8
|
+
unless Object.const_defined?('Rails')
|
9
|
+
return require_relative(path)
|
10
|
+
end
|
11
|
+
|
12
|
+
absolute_path = File.expand_path(relative_path, current_path).concat(extension)
|
13
|
+
|
14
|
+
if Rails.env.development?
|
15
|
+
load(absolute_path)
|
16
|
+
else
|
17
|
+
require(absolute_path)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
# require "eitil_core/kernel/loadquire"
|
3
|
+
|
4
|
+
Kernel.module_eval do
|
5
|
+
|
6
|
+
def loadquire(current_path, *relative_paths, ext: '.rb')
|
7
|
+
|
8
|
+
file_paths = relative_paths.map do |relative_path|
|
9
|
+
File.expand_path(relative_path, current_path).concat(ext)
|
10
|
+
end
|
11
|
+
|
12
|
+
if Object.const_defined?('Rails') && Rails.env.development?
|
13
|
+
file_paths.each do |path|
|
14
|
+
load(path)
|
15
|
+
end
|
16
|
+
|
17
|
+
else
|
18
|
+
file_paths.each do |path|
|
19
|
+
require(path)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
# require "eitil_core/kernel/loadquire_bang"
|
3
|
+
|
4
|
+
Kernel.module_eval do
|
5
|
+
|
6
|
+
def loadquire!(*relative_paths, ext: '.rb')
|
7
|
+
|
8
|
+
current_path = caller.first.split('/')[0..-2].join('/')
|
9
|
+
file_paths = relative_paths.map do |relative_path|
|
10
|
+
File.expand_path(relative_path, current_path).concat(ext)
|
11
|
+
end
|
12
|
+
|
13
|
+
if Object.const_defined?('Rails') && Rails.env.development?
|
14
|
+
file_paths.each do |path|
|
15
|
+
load(path)
|
16
|
+
end
|
17
|
+
|
18
|
+
else
|
19
|
+
file_paths.each do |path|
|
20
|
+
require(path)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
# require "eitil_core/string/colorize"
|
3
|
+
|
4
|
+
class String
|
5
|
+
|
6
|
+
def black; "\e[30m#{self}\e[0m" end
|
7
|
+
def red; "\e[31m#{self}\e[0m" end
|
8
|
+
def green; "\e[32m#{self}\e[0m" end
|
9
|
+
def brown; "\e[33m#{self}\e[0m" end
|
10
|
+
def blue; "\e[34m#{self}\e[0m" end
|
11
|
+
def magenta; "\e[35m#{self}\e[0m" end
|
12
|
+
def cyan; "\e[36m#{self}\e[0m" end
|
13
|
+
def gray; "\e[37m#{self}\e[0m" end
|
14
|
+
|
15
|
+
def bg_black; "\e[40m#{self}\e[0m" end
|
16
|
+
def bg_red; "\e[41m#{self}\e[0m" end
|
17
|
+
def bg_green; "\e[42m#{self}\e[0m" end
|
18
|
+
def bg_brown; "\e[43m#{self}\e[0m" end
|
19
|
+
def bg_blue; "\e[44m#{self}\e[0m" end
|
20
|
+
def bg_magenta; "\e[45m#{self}\e[0m" end
|
21
|
+
def bg_cyan; "\e[46m#{self}\e[0m" end
|
22
|
+
def bg_gray; "\e[47m#{self}\e[0m" end
|
23
|
+
|
24
|
+
def bold; "\e[1m#{self}\e[22m" end
|
25
|
+
def italic; "\e[3m#{self}\e[23m" end
|
26
|
+
def underline; "\e[4m#{self}\e[24m" end
|
27
|
+
def blink; "\e[5m#{self}\e[25m" end
|
28
|
+
def reverse_color; "\e[7m#{self}\e[27m" end
|
29
|
+
|
30
|
+
end
|
@@ -14,8 +14,15 @@ module EitilWrapper
|
|
14
14
|
|
15
15
|
def inherited(subclass)
|
16
16
|
super
|
17
|
-
|
18
17
|
return if Eitil.skip_callback_helper_methods_for_models.include?(subclass.to_s.to_sym)
|
18
|
+
|
19
|
+
# Set the proper table_names for namespaced models. Without setting this,
|
20
|
+
# Rails run into problems due to the fact that the first call to the model's
|
21
|
+
# constant triggers this initializer first, and only thereafter the model file
|
22
|
+
# which sets the correct table_name through a macro.
|
23
|
+
namespaced_class = subclass.to_s.include?('::')
|
24
|
+
subclass.table_name = subclass.to_s.gsub('::', '_').downcase.pluralize if namespaced_class
|
25
|
+
|
19
26
|
subclass.use_eitil_callback_helper_methods
|
20
27
|
|
21
28
|
rescue => e
|
@@ -36,8 +36,15 @@ module EitilWrapper
|
|
36
36
|
|
37
37
|
def inherited(subclass)
|
38
38
|
super
|
39
|
-
|
40
39
|
return if Eitil.skip_default_scopes_for_models.include?(subclass.to_s.to_sym)
|
40
|
+
|
41
|
+
# Set the proper table_names for namespaced models. Without setting this,
|
42
|
+
# Rails run into problems due to the fact that the first call to the model's
|
43
|
+
# constant triggers this initializer first, and only thereafter the model file
|
44
|
+
# which sets the correct table_name through a macro.
|
45
|
+
namespaced_class = subclass.to_s.include?('::')
|
46
|
+
subclass.table_name = subclass.to_s.gsub('::', '_').downcase.pluralize if namespaced_class
|
47
|
+
|
41
48
|
subclass.use_eitil_scopes
|
42
49
|
|
43
50
|
rescue => e
|
data/lib/eitil/version.rb
CHANGED
Binary file
|
@@ -0,0 +1,91 @@
|
|
1
|
+
RSpec.describe "EitilCore String colorize methods" do
|
2
|
+
|
3
|
+
it "should not crash when multiple colors are chained" do
|
4
|
+
expect("hello world".black.blue.red.bg_green.bg_brown.underline.bold).to be_truthy
|
5
|
+
end
|
6
|
+
|
7
|
+
it "should color on .black" do
|
8
|
+
expect("hello world".black).to be_truthy
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should color on .red" do
|
12
|
+
expect("hello world".red).to be_truthy
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should color on .green" do
|
16
|
+
expect("hello world".green).to be_truthy
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should color on .brown" do
|
20
|
+
expect("hello world".brown).to be_truthy
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should color on .blue" do
|
24
|
+
expect("hello world".blue).to be_truthy
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should color on .magenta" do
|
28
|
+
expect("hello world".magenta).to be_truthy
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should color on .cyan" do
|
32
|
+
expect("hello world".cyan).to be_truthy
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should color on .gray" do
|
36
|
+
expect("hello world".gray).to be_truthy
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should color on .bg_black" do
|
40
|
+
expect("hello world".bg_black).to be_truthy
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should color on .bg_red" do
|
44
|
+
expect("hello world".bg_red).to be_truthy
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should color on .bg_green" do
|
48
|
+
expect("hello world".bg_green).to be_truthy
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should color on .bg_brown" do
|
52
|
+
expect("hello world".bg_brown).to be_truthy
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should color on .bg_blue" do
|
56
|
+
expect("hello world".bg_blue).to be_truthy
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should color on .bg_magenta" do
|
60
|
+
expect("hello world".bg_magenta).to be_truthy
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should color on .bg_cyan" do
|
64
|
+
expect("hello world".bg_cyan).to be_truthy
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should color on .bg_gray" do
|
68
|
+
expect("hello world".bg_gray).to be_truthy
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should color on .bold" do
|
72
|
+
expect("hello world".bold).to be_truthy
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should color on .italic" do
|
76
|
+
expect("hello world".italic).to be_truthy
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should color on .underline" do
|
80
|
+
expect("hello world".underline).to be_truthy
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should color on .blink" do
|
84
|
+
expect("hello world".blink).to be_truthy
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should color on .reverse_color" do
|
88
|
+
expect("hello world".reverse_color).to be_truthy
|
89
|
+
end
|
90
|
+
|
91
|
+
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.3.
|
4
|
+
version: 1.3.5
|
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-
|
11
|
+
date: 2021-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -206,6 +206,10 @@ files:
|
|
206
206
|
- eitil_core/lib/eitil_core/hash.rb
|
207
207
|
- eitil_core/lib/eitil_core/hash/auto_dig.rb
|
208
208
|
- eitil_core/lib/eitil_core/hash/transform_string_values.rb
|
209
|
+
- eitil_core/lib/eitil_core/kernel.rb
|
210
|
+
- eitil_core/lib/eitil_core/kernel/always_require_relative.rb
|
211
|
+
- eitil_core/lib/eitil_core/kernel/loadquire.rb
|
212
|
+
- eitil_core/lib/eitil_core/kernel/loadquire_bang.rb
|
209
213
|
- eitil_core/lib/eitil_core/lookups.rb
|
210
214
|
- eitil_core/lib/eitil_core/lookups/all_methods.rb
|
211
215
|
- eitil_core/lib/eitil_core/lookups/gem_path.rb
|
@@ -221,6 +225,7 @@ files:
|
|
221
225
|
- eitil_core/lib/eitil_core/setters.rb
|
222
226
|
- eitil_core/lib/eitil_core/setters/set_ivars.rb
|
223
227
|
- eitil_core/lib/eitil_core/string.rb
|
228
|
+
- eitil_core/lib/eitil_core/string/colorize.rb
|
224
229
|
- eitil_core/lib/eitil_core/string/strip_base64_header.rb
|
225
230
|
- eitil_core/lib/eitil_core/string/to_filename.rb
|
226
231
|
- eitil_core/lib/eitil_core/type_checkers.rb
|
@@ -431,6 +436,7 @@ files:
|
|
431
436
|
- spec/eitil_core/safe_executions/safe_call.rb
|
432
437
|
- spec/eitil_core/safe_executions/safe_send.rb
|
433
438
|
- spec/eitil_core/setters/set_ivars_spec.rb
|
439
|
+
- spec/eitil_core/string/colorize_spec.rb
|
434
440
|
- spec/eitil_core/string/strip_base64_header_spec.rb
|
435
441
|
- spec/eitil_core/string/to_filename_spec.rb
|
436
442
|
- spec/eitil_core/type_checkers/is_num_or_nan_spec.rb
|