aqui 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +27 -10
- data/Rakefile +1 -1
- data/lib/aqui/colorizer.rb +6 -1
- data/lib/aqui/parser.rb +11 -1
- data/lib/aqui/version.rb +1 -1
- data/script/demo.rb +15 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4283d1f8b3d32fb240f29e7bbfa16b5a379fd80e
|
4
|
+
data.tar.gz: a814cecd825e3898898933a8fdd20708b4632444
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5ebf64ef29f2bdb9b0b93d8c208a426c06ee9f3ea063976be5774587f5b53ef07afb0f29354fcef4d91766c5602a6c0f59eb369b80cffde638c59fc7d43712b
|
7
|
+
data.tar.gz: 18bcc4d4d41528a2c69f7d4e4e3ef690bc4ef135d433b8a0b438a9883041b28817af79de33b4c11c402305b302a633fff4308ccf450d7b8398ca62db08a615c0
|
data/README.md
CHANGED
@@ -8,13 +8,24 @@ A gem for making sure some code is running.
|
|
8
8
|
|
9
9
|
Sometimes when coding, you run into a situation where you want to make sure
|
10
10
|
a bit of code is being executed by your application. You might end up
|
11
|
-
typing something like
|
11
|
+
typing something like the following, where you aren't positive if the code about `@noises_made` being run
|
12
12
|
|
13
13
|
~~~ruby
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
class Animal
|
15
|
+
def make_noise
|
16
|
+
@noises_made ||= 0
|
17
|
+
@noises_made += 1
|
18
|
+
puts 'noises are being made!'
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class Dog < Animal
|
24
|
+
def make_noise
|
25
|
+
super
|
26
|
+
'bark'
|
27
|
+
end
|
28
|
+
end
|
18
29
|
~~~
|
19
30
|
|
20
31
|
This way, you can run your code and check your logs to see if the `put`
|
@@ -22,15 +33,21 @@ methods were called. If this short and simple effective method works for you,
|
|
22
33
|
then give `aqui` a shot next time. It looks like this:
|
23
34
|
|
24
35
|
~~~ruby
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
36
|
+
class Animal
|
37
|
+
def make_noise
|
38
|
+
@noises_made ||= 0
|
39
|
+
@noises_made += 1
|
40
|
+
aqui # <= add this!
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
end
|
29
44
|
~~~
|
30
45
|
|
31
46
|
This time, the output is colorized and contains information about where the code is running:
|
32
47
|
|
33
|
-
![screenshot](http://i.imgur.com/
|
48
|
+
![screenshot](http://i.imgur.com/M1ULD9O.png)
|
49
|
+
|
50
|
+
Handy, huh?
|
34
51
|
|
35
52
|
## Installation
|
36
53
|
|
data/Rakefile
CHANGED
data/lib/aqui/colorizer.rb
CHANGED
@@ -26,13 +26,18 @@ module Aqui
|
|
26
26
|
@object.class.to_s.colorize(:light_white)
|
27
27
|
end
|
28
28
|
|
29
|
+
def method
|
30
|
+
"##{@parser.method}".colorize(:light_green)
|
31
|
+
end
|
32
|
+
|
29
33
|
def message
|
30
34
|
[
|
31
35
|
file,
|
32
36
|
line_break,
|
33
37
|
line_number,
|
34
38
|
spacer,
|
35
|
-
object_class
|
39
|
+
object_class,
|
40
|
+
method
|
36
41
|
].join('')
|
37
42
|
end
|
38
43
|
end
|
data/lib/aqui/parser.rb
CHANGED
@@ -7,7 +7,7 @@ module Aqui
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def parts
|
10
|
-
@parts ||= @caller_message[0
|
10
|
+
@parts ||= @caller_message[0..method_index].split(':')
|
11
11
|
end
|
12
12
|
|
13
13
|
def file
|
@@ -17,5 +17,15 @@ module Aqui
|
|
17
17
|
def line_number
|
18
18
|
parts[1]
|
19
19
|
end
|
20
|
+
|
21
|
+
def method
|
22
|
+
@caller_message[method_index + 5..-2]
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def method_index
|
28
|
+
@caller_message.index(':in `')
|
29
|
+
end
|
20
30
|
end
|
21
31
|
end
|
data/lib/aqui/version.rb
CHANGED
data/script/demo.rb
CHANGED
@@ -1,13 +1,22 @@
|
|
1
1
|
require "bundler/setup"
|
2
2
|
Bundler.require
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
# Animal
|
5
|
+
class Animal
|
6
|
+
def make_noise
|
7
|
+
@noises_made ||= 0
|
8
|
+
@noises_made += 1
|
9
9
|
aqui
|
10
|
+
nil
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# Dog
|
15
|
+
class Dog < Animal
|
16
|
+
def make_noise
|
17
|
+
super
|
18
|
+
'bark'
|
10
19
|
end
|
11
20
|
end
|
12
21
|
|
13
|
-
|
22
|
+
Dog.new.make_noise
|