tell_me_about_it 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tell_me_about_it.rb +23 -7
- data/lib/tell_me_about_it/version.rb +1 -1
- metadata +8 -8
data/lib/tell_me_about_it.rb
CHANGED
@@ -5,12 +5,13 @@ require 'tell_me_about_it/version'
|
|
5
5
|
|
6
6
|
module TellMeAboutIt
|
7
7
|
COLORS = { :count => '00a0b0',
|
8
|
-
:file => '
|
8
|
+
:file => '444',
|
9
9
|
:context => '999',
|
10
10
|
:self => '793A57',
|
11
11
|
:method => 'fff',
|
12
12
|
:args => 'EB6841',
|
13
13
|
:result => '2DE04D',
|
14
|
+
:result_yaml => '105023',
|
14
15
|
:time_good => 'EDC951',
|
15
16
|
:time_bad => 'CC333F' }
|
16
17
|
|
@@ -53,7 +54,7 @@ module TellMeAboutIt
|
|
53
54
|
end
|
54
55
|
|
55
56
|
def self.self_str passed_self
|
56
|
-
passed_self.
|
57
|
+
passed_self.to_s.color(COLORS[:self])
|
57
58
|
end
|
58
59
|
|
59
60
|
def self.file_str method_caller
|
@@ -73,7 +74,7 @@ module TellMeAboutIt
|
|
73
74
|
|
74
75
|
def self.method_str method_name, *args
|
75
76
|
name_str = "#{method_name}".bold
|
76
|
-
args_str = "(#{args.map
|
77
|
+
args_str = "(#{args.map {|a| a.inspect.size > 150 ? a.to_s : a.inspect}.map {|a| a.color(COLORS[:args])}.join(', ')})"
|
77
78
|
name_str + args_str
|
78
79
|
end
|
79
80
|
|
@@ -98,8 +99,14 @@ module TellMeAboutIt
|
|
98
99
|
seconds > 0.05 ? time_str.color(COLORS[:time_bad]) : time_str.color(COLORS[:time_good])
|
99
100
|
end
|
100
101
|
|
101
|
-
def self.result_str result
|
102
|
-
result.
|
102
|
+
def self.result_str result, indent_str
|
103
|
+
result.to_s.color(COLORS[:result]) + if result.instance_variables.any? && ENV['SHOW_YAML']
|
104
|
+
"\n" + indent_str + " " + result.to_yaml.each_line.map do |l|
|
105
|
+
l.gsub(/\n/,'').color(COLORS[:result_yaml])
|
106
|
+
end.join("\n").gsub(/\n/, "\n#{indent_str} ")
|
107
|
+
else
|
108
|
+
''
|
109
|
+
end
|
103
110
|
end
|
104
111
|
|
105
112
|
def tell_me_about(*method_names)
|
@@ -166,7 +173,7 @@ private
|
|
166
173
|
end
|
167
174
|
|
168
175
|
puts indent_str
|
169
|
-
puts start_indent_str + count_str + self_str + "." + method_str
|
176
|
+
puts start_indent_str + count_str + self_str + "." + method_str + " called"
|
170
177
|
puts "\#{cont_indent_str} \#{file_str}"
|
171
178
|
puts "\#{cont_indent_str} \#{context_str}"
|
172
179
|
|
@@ -174,7 +181,7 @@ private
|
|
174
181
|
result = nil
|
175
182
|
seconds = Benchmark.realtime { result = #{original_method}(*args, &blk) }
|
176
183
|
time_str = TellMeAboutIt.time_str(seconds)
|
177
|
-
result_str = TellMeAboutIt.result_str(result)
|
184
|
+
result_str = TellMeAboutIt.result_str(result, indent_str)
|
178
185
|
TellMeAboutIt.outdent
|
179
186
|
|
180
187
|
puts cont_indent_str if TellMeAboutIt.indent_changed?
|
@@ -201,11 +208,19 @@ class Fib
|
|
201
208
|
def no_args
|
202
209
|
5
|
203
210
|
end
|
211
|
+
tell_me_about :no_args
|
204
212
|
|
205
213
|
def fib x
|
206
214
|
return 1 if x <= 2
|
207
215
|
fib(x - 1) + fib(x - 2)
|
208
216
|
end
|
217
|
+
tell_me_about_instance_method :fib
|
218
|
+
|
219
|
+
def self.fib x
|
220
|
+
return 1 if x <= 2
|
221
|
+
fib(x - 1) + fib(x - 2)
|
222
|
+
end
|
223
|
+
tell_me_about :fib
|
209
224
|
|
210
225
|
def self.find x
|
211
226
|
return 1 if x <= 2
|
@@ -215,6 +230,7 @@ class Fib
|
|
215
230
|
def find x
|
216
231
|
x * 2
|
217
232
|
end
|
233
|
+
tell_me_about :find
|
218
234
|
|
219
235
|
def fib_block &blk
|
220
236
|
fib yield
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tell_me_about_it
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-08-
|
12
|
+
date: 2011-08-15 00:00:00.000000000 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
17
|
-
requirement: &
|
17
|
+
requirement: &2153694600 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2153694600
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: fuubar
|
28
|
-
requirement: &
|
28
|
+
requirement: &2153694180 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2153694180
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: colorful
|
39
|
-
requirement: &
|
39
|
+
requirement: &2153693760 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2153693760
|
48
48
|
description: Provides a simple interface for terminal output colors and effects
|
49
49
|
email:
|
50
50
|
- randland@gmail.com
|