lll 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +58 -0
- data/Rakefile +18 -0
- data/VERSION +1 -0
- data/doc/README_rdoc.html +139 -0
- data/lib/lll.rb +37 -0
- metadata +122 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Mark Wilden
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
= lll
|
2
|
+
|
3
|
+
lll() is used in debugging to display an expression and its value.
|
4
|
+
|
5
|
+
=== Motivation
|
6
|
+
|
7
|
+
One of the most basic tools in debugging is printing out the values of
|
8
|
+
variables (or other expressions) during program execution:
|
9
|
+
|
10
|
+
puts user_name
|
11
|
+
|
12
|
+
Sometimes you need to label these values so you know what they're
|
13
|
+
referring to, especially if you're outputting a lot of them:
|
14
|
+
|
15
|
+
puts "user_name = #{message}"
|
16
|
+
|
17
|
+
lll() does the labelling automatically:
|
18
|
+
|
19
|
+
lll{'user_name'}
|
20
|
+
|
21
|
+
The expression is passed as a string inside a block. It's useful to
|
22
|
+
create a text editor macro that outputs <tt>lll{''}</tt> and leaves the
|
23
|
+
cursor inside the apostrophes.
|
24
|
+
|
25
|
+
=== Other benefits
|
26
|
+
|
27
|
+
Output goes to standard output and the Rails log (if available).
|
28
|
+
|
29
|
+
Output is displayed in reverse video, so it's easy to pick out from the
|
30
|
+
log or console.
|
31
|
+
|
32
|
+
lll() uses #inspect to output the expression. It outputs Enumerable
|
33
|
+
members (except strings) on separate lines.
|
34
|
+
|
35
|
+
Output is tagged with the file and line number where it appears, so
|
36
|
+
you can easily find lll's that you forgot to take out. The time of
|
37
|
+
day (but not the date) is also printed, so you don't waste time
|
38
|
+
looking at old output.
|
39
|
+
|
40
|
+
=== Outputting additional text
|
41
|
+
|
42
|
+
Sometimes you want to include some other string, along with the label
|
43
|
+
and value like this:
|
44
|
+
|
45
|
+
puts "After polling the queue, user_name = #{user_name}"
|
46
|
+
|
47
|
+
You can pass a string to lll() to print a string:
|
48
|
+
|
49
|
+
lll("After polling the queue"){'user_name'}
|
50
|
+
|
51
|
+
And because lll() outputs in reverse video, and to the Rails log, it can
|
52
|
+
be useful to simply print a string without an expression:
|
53
|
+
|
54
|
+
lll "After read_user"
|
55
|
+
|
56
|
+
=== Copyright
|
57
|
+
|
58
|
+
Copyright (c) 2009 Mark Wilden. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "lll"
|
8
|
+
gem.summary = %Q{Output labeled data when debugging}
|
9
|
+
gem.email = "mark@mwilden.com"
|
10
|
+
gem.homepage = "http://github.com/mwilden/lll"
|
11
|
+
gem.authors = ["Mark Wilden"]
|
12
|
+
gem.description = File.read(File.join(File.dirname(__FILE__),'README.rdoc'))
|
13
|
+
end
|
14
|
+
Jeweler::GemcutterTasks.new
|
15
|
+
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
18
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
@@ -0,0 +1,139 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
6
|
+
<head>
|
7
|
+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
8
|
+
|
9
|
+
<title>File: README.rdoc [RDoc Documentation]</title>
|
10
|
+
|
11
|
+
<link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet" />
|
12
|
+
|
13
|
+
<script src="./js/jquery.js" type="text/javascript"
|
14
|
+
charset="utf-8"></script>
|
15
|
+
<script src="./js/thickbox-compressed.js" type="text/javascript"
|
16
|
+
charset="utf-8"></script>
|
17
|
+
<script src="./js/quicksearch.js" type="text/javascript"
|
18
|
+
charset="utf-8"></script>
|
19
|
+
<script src="./js/darkfish.js" type="text/javascript"
|
20
|
+
charset="utf-8"></script>
|
21
|
+
</head>
|
22
|
+
|
23
|
+
<body class="file">
|
24
|
+
<div id="metadata">
|
25
|
+
<div id="project-metadata">
|
26
|
+
|
27
|
+
|
28
|
+
<div id="fileindex-section" class="section project-section">
|
29
|
+
<h3 class="section-header">Files</h3>
|
30
|
+
<ul>
|
31
|
+
|
32
|
+
<li class="file"><a href="./README_rdoc.html">README.rdoc</a></li>
|
33
|
+
|
34
|
+
</ul>
|
35
|
+
</div>
|
36
|
+
|
37
|
+
|
38
|
+
<div id="classindex-section" class="section project-section">
|
39
|
+
<h3 class="section-header">Class Index
|
40
|
+
<span class="search-toggle"><img src="./images/find.png"
|
41
|
+
height="16" width="16" alt="[+]"
|
42
|
+
title="show/hide quicksearch" /></span></h3>
|
43
|
+
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
44
|
+
<fieldset>
|
45
|
+
<legend>Quicksearch</legend>
|
46
|
+
<input type="text" name="quicksearch" value=""
|
47
|
+
class="quicksearch-field" />
|
48
|
+
</fieldset>
|
49
|
+
</form>
|
50
|
+
|
51
|
+
<ul class="link-list">
|
52
|
+
|
53
|
+
</ul>
|
54
|
+
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
55
|
+
</div>
|
56
|
+
|
57
|
+
|
58
|
+
</div>
|
59
|
+
</div>
|
60
|
+
|
61
|
+
<div id="documentation">
|
62
|
+
<h1>lll</h1>
|
63
|
+
<p>
|
64
|
+
lll() is used in debugging to display an expression and its value.
|
65
|
+
</p>
|
66
|
+
<h3>Motivation</h3>
|
67
|
+
<p>
|
68
|
+
One of the most basic tools in debugging is printing out the values of
|
69
|
+
variables (or other expressions) during program execution:
|
70
|
+
</p>
|
71
|
+
<pre>
|
72
|
+
puts user_name
|
73
|
+
</pre>
|
74
|
+
<p>
|
75
|
+
Sometimes you need to label these values so you know what they’re
|
76
|
+
referring to, especially if you’re outputting a lot of them:
|
77
|
+
</p>
|
78
|
+
<pre>
|
79
|
+
puts "user_name = #{message}"
|
80
|
+
</pre>
|
81
|
+
<p>
|
82
|
+
lll() does the labelling automatically:
|
83
|
+
</p>
|
84
|
+
<pre>
|
85
|
+
lll{'user_name'}
|
86
|
+
</pre>
|
87
|
+
<p>
|
88
|
+
The expression is passed as a string inside a block. It’s useful to
|
89
|
+
create a text editor macro that outputs <tt>lll{''}</tt> and leaves the
|
90
|
+
cursor inside the apostrophes.
|
91
|
+
</p>
|
92
|
+
<h3>Other benefits</h3>
|
93
|
+
<p>
|
94
|
+
Output goes to standard output and the Rails log (if available).
|
95
|
+
</p>
|
96
|
+
<p>
|
97
|
+
Output is displayed in reverse video, so it’s easy to pick out from
|
98
|
+
the log or console.
|
99
|
+
</p>
|
100
|
+
<p>
|
101
|
+
lll() uses inspect to output the expression. It outputs Enumerable members
|
102
|
+
(except strings) on separate lines.
|
103
|
+
</p>
|
104
|
+
<h3>Outputting additional text</h3>
|
105
|
+
<p>
|
106
|
+
Sometimes you need to include some other string, along with the label and
|
107
|
+
value:
|
108
|
+
</p>
|
109
|
+
<pre>
|
110
|
+
puts "After polling the queue, user_name = #{user_name}"
|
111
|
+
</pre>
|
112
|
+
<p>
|
113
|
+
You can pass a string to lll() to print a string:
|
114
|
+
</p>
|
115
|
+
<pre>
|
116
|
+
lll("After polling the queue"){'user_name'}
|
117
|
+
</pre>
|
118
|
+
<p>
|
119
|
+
And because lll() outputs in reverse video, and to the Rails log, it can be
|
120
|
+
useful to simply print a string without an expression:
|
121
|
+
</p>
|
122
|
+
<pre>
|
123
|
+
lll "After read_user"
|
124
|
+
</pre>
|
125
|
+
<h3>Copyright</h3>
|
126
|
+
<p>
|
127
|
+
Copyright © 2009 Mark Wilden. See LICENSE for details.
|
128
|
+
</p>
|
129
|
+
|
130
|
+
</div>
|
131
|
+
|
132
|
+
<div id="validator-badges">
|
133
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
134
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
135
|
+
Rdoc Generator</a> 1.1.6</small>.</p>
|
136
|
+
</div>
|
137
|
+
</body>
|
138
|
+
</html>
|
139
|
+
|
data/lib/lll.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Used in debugging to display an expression and its value. Examples:
|
2
|
+
# x = 1
|
3
|
+
# lll{'x'} #=> x = 1
|
4
|
+
# lll("a message"){'x'} #=> a message: x = 1
|
5
|
+
# lll "a message" #=> a message
|
6
|
+
# Enumerable members are output on separate lines
|
7
|
+
|
8
|
+
def lll msg = nil, &block
|
9
|
+
s = " "
|
10
|
+
expression_string = ''
|
11
|
+
expression_value = 0
|
12
|
+
if block_given?
|
13
|
+
s << msg + ': ' if msg
|
14
|
+
expression_string = block.call
|
15
|
+
expression_value = eval(expression_string, block)
|
16
|
+
s << expression_string + ' = '
|
17
|
+
if expression_value.respond_to?(:each) && !expression_value.is_a?(String)
|
18
|
+
s << " \n"
|
19
|
+
expression_value.each { |e| s << ' ' << e.inspect << " \n" }
|
20
|
+
else
|
21
|
+
s << expression_value.inspect << " \n"
|
22
|
+
end
|
23
|
+
else
|
24
|
+
s << msg if msg
|
25
|
+
s << " \n"
|
26
|
+
end
|
27
|
+
|
28
|
+
color_code_for_value = "\e[7m"
|
29
|
+
color_code_for_location = ""
|
30
|
+
stop_color_code = "\e[0m"
|
31
|
+
|
32
|
+
s = color_code_for_value + s + stop_color_code
|
33
|
+
s << color_code_for_location + ' ' + caller.first.to_s + ' ' + Time.now.strftime('%X') + ' ' + stop_color_code
|
34
|
+
|
35
|
+
Kernel.puts s
|
36
|
+
Rails.logger.debug s if defined?(Rails) && Rails.logger
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lll
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mark Wilden
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-01-17 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: |
|
17
|
+
= lll
|
18
|
+
|
19
|
+
lll() is used in debugging to display an expression and its value.
|
20
|
+
|
21
|
+
=== Motivation
|
22
|
+
|
23
|
+
One of the most basic tools in debugging is printing out the values of
|
24
|
+
variables (or other expressions) during program execution:
|
25
|
+
|
26
|
+
puts user_name
|
27
|
+
|
28
|
+
Sometimes you need to label these values so you know what they're
|
29
|
+
referring to, especially if you're outputting a lot of them:
|
30
|
+
|
31
|
+
puts "user_name = #{message}"
|
32
|
+
|
33
|
+
lll() does the labelling automatically:
|
34
|
+
|
35
|
+
lll{'user_name'}
|
36
|
+
|
37
|
+
The expression is passed as a string inside a block. It's useful to
|
38
|
+
create a text editor macro that outputs <tt>lll{''}</tt> and leaves the
|
39
|
+
cursor inside the apostrophes.
|
40
|
+
|
41
|
+
=== Other benefits
|
42
|
+
|
43
|
+
Output goes to standard output and the Rails log (if available).
|
44
|
+
|
45
|
+
Output is displayed in reverse video, so it's easy to pick out from the
|
46
|
+
log or console.
|
47
|
+
|
48
|
+
lll() uses #inspect to output the expression. It outputs Enumerable
|
49
|
+
members (except strings) on separate lines.
|
50
|
+
|
51
|
+
Output is tagged with the file and line number where it appears, so
|
52
|
+
you can easily find lll's that you forgot to take out. The time of
|
53
|
+
day (but not the date) is also printed, so you don't waste time
|
54
|
+
looking at old output.
|
55
|
+
|
56
|
+
=== Outputting additional text
|
57
|
+
|
58
|
+
Sometimes you want to include some other string, along with the label
|
59
|
+
and value like this:
|
60
|
+
|
61
|
+
puts "After polling the queue, user_name = #{user_name}"
|
62
|
+
|
63
|
+
You can pass a string to lll() to print a string:
|
64
|
+
|
65
|
+
lll("After polling the queue"){'user_name'}
|
66
|
+
|
67
|
+
And because lll() outputs in reverse video, and to the Rails log, it can
|
68
|
+
be useful to simply print a string without an expression:
|
69
|
+
|
70
|
+
lll "After read_user"
|
71
|
+
|
72
|
+
=== Copyright
|
73
|
+
|
74
|
+
Copyright (c) 2009 Mark Wilden. See LICENSE for details.
|
75
|
+
|
76
|
+
email: mark@mwilden.com
|
77
|
+
executables: []
|
78
|
+
|
79
|
+
extensions: []
|
80
|
+
|
81
|
+
extra_rdoc_files:
|
82
|
+
- LICENSE
|
83
|
+
- README.rdoc
|
84
|
+
files:
|
85
|
+
- .document
|
86
|
+
- .gitignore
|
87
|
+
- LICENSE
|
88
|
+
- README.rdoc
|
89
|
+
- Rakefile
|
90
|
+
- VERSION
|
91
|
+
- doc/README_rdoc.html
|
92
|
+
- lib/lll.rb
|
93
|
+
has_rdoc: true
|
94
|
+
homepage: http://github.com/mwilden/lll
|
95
|
+
licenses: []
|
96
|
+
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options:
|
99
|
+
- --charset=UTF-8
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: "0"
|
107
|
+
version:
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: "0"
|
113
|
+
version:
|
114
|
+
requirements: []
|
115
|
+
|
116
|
+
rubyforge_project:
|
117
|
+
rubygems_version: 1.3.5
|
118
|
+
signing_key:
|
119
|
+
specification_version: 3
|
120
|
+
summary: Output labeled data when debugging
|
121
|
+
test_files: []
|
122
|
+
|