eitil 1.3.0 → 1.3.4

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
  SHA256:
3
- metadata.gz: aefe6597672c5fcabffbce60d0caffb14540331dfe9133d1c4ff01b5ef30c229
4
- data.tar.gz: 3dd8b83eb7dceaa7a1ad605a1adfc07963532c563a5df7d62f39183ae8a89c61
3
+ metadata.gz: 2249e8b19220f03df98daad2d625c434b46c3eb54982afce5b71098eb2ec7561
4
+ data.tar.gz: f651112c073d1263919418904359cbdb03c39f232a216754c78da910b610e7d0
5
5
  SHA512:
6
- metadata.gz: 025eb7fe3fe248483babaf55d49c7da4311edc9e4443681cc74b9c41ed39e444ed6f4d0453ed71a5e9191f84fd8bd16ed61f89c328e779d85e2d6cf41eab246a
7
- data.tar.gz: d83660005e68ebf2c4a5144679078070ef076f9f7f8f55f6df9e2bfd8e97ffa9928114c1607cfc5abf779b6a21eeea3ead5d4179c1447278d01d668a7d0db7be
6
+ metadata.gz: 851e8992abcf099c7cb23e2fed760a37278d606b6d328b4a20d0444b93986a4fef3760ea5cad242d9e6bedc15b7e71620070ec2d80ec6c32b6a44bc253cf789f
7
+ data.tar.gz: 1918147e3399a9a3e6fd363fb509bc55880f1dde592ef88cc072e2943ebb7f046db2ac312120cf48823338352a1cbe7bab06cdf5fed751419efba0581ddc5b75
data/eitil_core/README.md CHANGED
@@ -495,6 +495,37 @@ require "eitil_core/string"
495
495
 
496
496
  ```
497
497
 
498
+ ```ruby
499
+ # require "eitil_core/string/colorize"
500
+
501
+ # formats strings, so that they are styled when printed to the terminal.
502
+
503
+ 'hi'.black
504
+ 'hi'.red
505
+ 'hi'.green
506
+ 'hi'.brown
507
+ 'hi'.blue
508
+ 'hi'.magenta
509
+ 'hi'.cyan
510
+ 'hi'.gray
511
+
512
+ 'hi'.bg_black
513
+ 'hi'.bg_red
514
+ 'hi'.bg_green
515
+ 'hi'.bg_brown
516
+ 'hi'.bg_blue
517
+ 'hi'.bg_magenta
518
+ 'hi'.bg_cyan
519
+ 'hi'.bg_gray
520
+
521
+ 'hi'.bold
522
+ 'hi'.italic
523
+ 'hi'.underline
524
+ 'hi'.blink
525
+ 'hi'.reverse_color
526
+
527
+ ```
528
+
498
529
  ```ruby
499
530
  # require "eitil_core/string/strip_base64_header"
500
531
 
@@ -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,2 @@
1
+
2
+ require "eitil_core/kernel/always_require_relative"
@@ -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
@@ -1,5 +1,6 @@
1
1
 
2
2
  # require "eitil_core/string"
3
3
 
4
+ require "eitil_core/string/colorize"
4
5
  require "eitil_core/string/strip_base64_header"
5
6
  require "eitil_core/string/to_filename"
@@ -7,6 +7,7 @@ require "eitil_core/array"
7
7
  require "eitil_core/hash"
8
8
  require "eitil_core/float"
9
9
  require "eitil_core/datetime"
10
+ require "eitil_core/kernel"
10
11
 
11
12
  # multi class patches
12
13
  require "eitil_core/type_checkers"
@@ -22,6 +22,7 @@ module EitilIntegrate::RubyXL
22
22
  style_column_width
23
23
  style_first_row_bold
24
24
  style_first_column_bold
25
+ style_first_column_width
25
26
  end
26
27
 
27
28
  def style_custom
@@ -59,6 +60,10 @@ module EitilIntegrate::RubyXL
59
60
  base_style_x_columns_width (0...n_columns), width
60
61
  end
61
62
 
63
+ def style_first_column_width(width = 35)
64
+ style_first_x_columns_width 1, width
65
+ end
66
+
62
67
  alias_method :base_style_first_x_columns_width, :style_first_x_columns_width
63
68
 
64
69
  def style_x_columns_width(column_indices = [], width)
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Eitil
2
2
 
3
- VERSION = '1.3.0'
3
+ VERSION = '1.3.4'
4
4
 
5
5
  end
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.0
4
+ version: 1.3.4
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-10 00:00:00.000000000 Z
11
+ date: 2021-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -206,6 +206,8 @@ 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
209
211
  - eitil_core/lib/eitil_core/lookups.rb
210
212
  - eitil_core/lib/eitil_core/lookups/all_methods.rb
211
213
  - eitil_core/lib/eitil_core/lookups/gem_path.rb
@@ -221,6 +223,7 @@ files:
221
223
  - eitil_core/lib/eitil_core/setters.rb
222
224
  - eitil_core/lib/eitil_core/setters/set_ivars.rb
223
225
  - eitil_core/lib/eitil_core/string.rb
226
+ - eitil_core/lib/eitil_core/string/colorize.rb
224
227
  - eitil_core/lib/eitil_core/string/strip_base64_header.rb
225
228
  - eitil_core/lib/eitil_core/string/to_filename.rb
226
229
  - eitil_core/lib/eitil_core/type_checkers.rb
@@ -431,6 +434,7 @@ files:
431
434
  - spec/eitil_core/safe_executions/safe_call.rb
432
435
  - spec/eitil_core/safe_executions/safe_send.rb
433
436
  - spec/eitil_core/setters/set_ivars_spec.rb
437
+ - spec/eitil_core/string/colorize_spec.rb
434
438
  - spec/eitil_core/string/strip_base64_header_spec.rb
435
439
  - spec/eitil_core/string/to_filename_spec.rb
436
440
  - spec/eitil_core/type_checkers/is_num_or_nan_spec.rb