Class: Pindo::Funlog
- Inherits:
-
Object
- Object
- Pindo::Funlog
- Defined in:
- lib/pindo/base/funlog.rb
Defined Under Namespace
Modules: Mixin
Singleton collapse
Singleton collapse
- .error(*args) ⇒ Object
- .fancyinfo_error(*args) ⇒ Object
-
.fancyinfo_start(*args) ⇒ Object
类方法委托,简化调用方式 使用 Funlog.info(“消息”) 代替 Funlog.instance.info(“消息”).
- .fancyinfo_success(*args) ⇒ Object
- .fancyinfo_update(*args) ⇒ Object
- .fancyinfo_warning(*args) ⇒ Object
- .info(*args) ⇒ Object
-
.reload_instance ⇒ Config
The current config instance creating one if needed.
- .warning(*args) ⇒ Object
Instance Method Summary collapse
- #create_spinner(info_key: nil) ⇒ Object
-
#error(*args) ⇒ Object
输出静态错误信息(不使用spinner,对应 fancyinfo_error).
- #fancyinfo_error(*args) ⇒ Object
- #fancyinfo_start(*args) ⇒ Object
- #fancyinfo_success(*args) ⇒ Object
- #fancyinfo_update(*args) ⇒ Object
-
#fancyinfo_warning(*args) ⇒ Object
输出警告信息(使用spinner,黄色警告标记).
-
#info(*args) ⇒ Object
输出静态成功信息(不使用spinner,对应 fancyinfo_success).
- #spinner_log_handle ⇒ Object
-
#warning(*args) ⇒ Object
输出静态警告信息(不使用spinner).
Class Attribute Details
.instance ⇒ Object
92 93 94 |
# File 'lib/pindo/base/funlog.rb', line 92 def self.instance @instance ||= new end |
Class Method Details
.error(*args) ⇒ Object
137 138 139 |
# File 'lib/pindo/base/funlog.rb', line 137 def error(*args) instance.error(*args) end |
.fancyinfo_error(*args) ⇒ Object
121 122 123 |
# File 'lib/pindo/base/funlog.rb', line 121 def (*args) instance.(*args) end |
.fancyinfo_start(*args) ⇒ Object
类方法委托,简化调用方式使用 Funlog.info(“消息”) 代替 Funlog.instance.info(“消息”)
109 110 111 |
# File 'lib/pindo/base/funlog.rb', line 109 def (*args) instance.(*args) end |
.fancyinfo_success(*args) ⇒ Object
117 118 119 |
# File 'lib/pindo/base/funlog.rb', line 117 def (*args) instance.(*args) end |
.fancyinfo_update(*args) ⇒ Object
113 114 115 |
# File 'lib/pindo/base/funlog.rb', line 113 def (*args) instance.(*args) end |
.fancyinfo_warning(*args) ⇒ Object
125 126 127 |
# File 'lib/pindo/base/funlog.rb', line 125 def (*args) instance.(*args) end |
.info(*args) ⇒ Object
129 130 131 |
# File 'lib/pindo/base/funlog.rb', line 129 def info(*args) instance.info(*args) end |
.reload_instance ⇒ Config
Returns the current config instance creating one if needed.
88 89 90 |
# File 'lib/pindo/base/funlog.rb', line 88 def self.reload_instance @instance = new end |
.warning(*args) ⇒ Object
133 134 135 |
# File 'lib/pindo/base/funlog.rb', line 133 def warning(*args) instance.warning(*args) end |
Instance Method Details
#create_spinner(info_key: nil) ⇒ Object
8 9 10 11 12 |
# File 'lib/pindo/base/funlog.rb', line 8 def create_spinner(info_key:nil) # spinner = TTY::Spinner.new("[:spinner] :#{info_key}", format: :dots_2, error_mark: "❌", success_mark: "✅") spinner = TTY::Spinner.new("[:spinner] :#{info_key}", format: :dots_2, error_mark: "❌") spinner end |
#error(*args) ⇒ Object
输出静态错误信息(不使用spinner,对应 fancyinfo_error)
77 78 79 80 |
# File 'lib/pindo/base/funlog.rb', line 77 def error(*args) = args.join(" ") puts "\e[31m ✗ #{}\e[0m" end |
#fancyinfo_error(*args) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/pindo/base/funlog.rb', line 45 def (*args) = args.join(" ") spinner_log_handle.update(title:) spinner_log_handle.error @spinner_log =nil end |
#fancyinfo_start(*args) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/pindo/base/funlog.rb', line 23 def (*args) = args.join(" ") spinner_log_handle.update(title:) spinner_log_handle.auto_spin @spinner_log end |
#fancyinfo_success(*args) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/pindo/base/funlog.rb', line 38 def (*args) = args.join(" ") spinner_log_handle.update(title:) spinner_log_handle.success @spinner_log =nil end |
#fancyinfo_update(*args) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/pindo/base/funlog.rb', line 31 def (*args) = args.join(" ") spinner_log_handle.update(title:) spinner_log_handle.spin @spinner_log end |
#fancyinfo_warning(*args) ⇒ Object
输出警告信息(使用spinner,黄色警告标记)
54 55 56 57 58 59 |
# File 'lib/pindo/base/funlog.rb', line 54 def (*args) = args.join(" ") spinner_log_handle.update(title:) spinner_log_handle.stop("\e[33m⚠\e[0m") @spinner_log = nil end |
#info(*args) ⇒ Object
输出静态成功信息(不使用spinner,对应 fancyinfo_success)
63 64 65 66 |
# File 'lib/pindo/base/funlog.rb', line 63 def info(*args) = args.join(" ") puts " ✓ #{}" end |
#spinner_log_handle ⇒ Object
14 15 16 17 18 19 |
# File 'lib/pindo/base/funlog.rb', line 14 def spinner_log_handle if @spinner_log.nil? @spinner_log = create_spinner(info_key:"title") end @spinner_log end |
#warning(*args) ⇒ Object
输出静态警告信息(不使用spinner)
70 71 72 73 |
# File 'lib/pindo/base/funlog.rb', line 70 def warning(*args) = args.join(" ") puts "\e[33m ⚠ #{}\e[0m" end |