simple-ui 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/simple/ui.rb +11 -24
- data/test/simple_ui_test.rb +1 -1
- data/test/test_helper.rb +1 -1
- metadata +5 -5
data/lib/simple/ui.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module UI
|
2
|
-
|
2
|
+
extend self
|
3
|
+
|
4
|
+
VERSION = "0.2.0"
|
3
5
|
|
4
6
|
def self.verbosity
|
5
7
|
@verbosity ||= 1
|
@@ -49,23 +51,23 @@ module UI
|
|
49
51
|
}
|
50
52
|
|
51
53
|
def debug(msg, *args)
|
52
|
-
UI.log
|
54
|
+
UI.log :debug, msg, *args
|
53
55
|
end
|
54
56
|
|
55
57
|
def info(msg, *args)
|
56
|
-
UI.log
|
58
|
+
UI.log :info, msg, *args
|
57
59
|
end
|
58
60
|
|
59
61
|
def warn(msg, *args)
|
60
|
-
UI.log
|
62
|
+
UI.log :warn, msg, *args
|
61
63
|
end
|
62
64
|
|
63
65
|
def error(msg, *args)
|
64
|
-
UI.log
|
66
|
+
UI.log :error, msg, *args
|
65
67
|
end
|
66
68
|
|
67
69
|
def success(msg, *args)
|
68
|
-
UI.log
|
70
|
+
UI.log :success, msg, *args
|
69
71
|
end
|
70
72
|
|
71
73
|
def benchmark(msg, *args, &block)
|
@@ -77,13 +79,13 @@ module UI
|
|
77
79
|
start = Time.now
|
78
80
|
yield.tap do
|
79
81
|
msg += ": #{(1000 * (Time.now - start)).to_i} msecs."
|
80
|
-
UI.log
|
82
|
+
UI.log severity, msg, *args
|
81
83
|
end
|
82
84
|
end
|
83
85
|
|
84
86
|
private
|
85
87
|
|
86
|
-
def self.log(
|
88
|
+
def self.log(sym, msg, *args)
|
87
89
|
rv = args.empty? ? msg : args.first
|
88
90
|
|
89
91
|
return rv unless verbosity >= MIN_VERBOSITY[sym]
|
@@ -94,11 +96,7 @@ module UI
|
|
94
96
|
|
95
97
|
timestamp = "[%3d msecs]" % (1000 * (Time.now - @@started_at))
|
96
98
|
|
97
|
-
|
98
|
-
sender_name = "[#{sender_name}] "
|
99
|
-
end
|
100
|
-
|
101
|
-
msg = "#{timestamp} #{sender_name}#{msg}"
|
99
|
+
msg = "#{timestamp} #{msg}"
|
102
100
|
|
103
101
|
if color = COLORS[MESSAGE_COLOR[sym]]
|
104
102
|
msg = "#{color}#{msg}#{COLORS[:clear]}"
|
@@ -108,15 +106,4 @@ module UI
|
|
108
106
|
|
109
107
|
rv
|
110
108
|
end
|
111
|
-
|
112
|
-
def log_inspect
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
class Object
|
117
|
-
include UI
|
118
|
-
end
|
119
|
-
|
120
|
-
class String
|
121
|
-
alias :log_inspect :to_s
|
122
109
|
end
|
data/test/simple_ui_test.rb
CHANGED
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple-ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-22 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Simple code for simple things in the console
|
15
15
|
email: eno@radiospiel.org
|
@@ -35,7 +35,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
35
35
|
version: '0'
|
36
36
|
segments:
|
37
37
|
- 0
|
38
|
-
hash:
|
38
|
+
hash: -1669227376838210990
|
39
39
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
@@ -44,10 +44,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
44
44
|
version: '0'
|
45
45
|
segments:
|
46
46
|
- 0
|
47
|
-
hash:
|
47
|
+
hash: -1669227376838210990
|
48
48
|
requirements: []
|
49
49
|
rubyforge_project:
|
50
|
-
rubygems_version: 1.8.
|
50
|
+
rubygems_version: 1.8.25
|
51
51
|
signing_key:
|
52
52
|
specification_version: 3
|
53
53
|
summary: Simple code for simple things in the console
|