gg 0.9.10 → 0.9.11
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/.gitignore +4 -4
- data/Gemfile +4 -4
- data/README.md +93 -93
- data/Rakefile +49 -49
- data/gg.gemspec +28 -28
- data/lib/gg.rb +38 -37
- data/lib/gg/core.rb +102 -101
- data/lib/gg/demo_app.rb +93 -76
- data/lib/gg/history.rb +20 -0
- data/lib/gg/logger.rb +40 -40
- data/lib/gg/public/gg.css +122 -122
- data/lib/gg/rack_plugin.rb +85 -85
- data/lib/gg/slim/_logger.slim +7 -7
- data/lib/gg/slim/array.slim +8 -8
- data/lib/gg/slim/hash.slim +11 -11
- data/lib/gg/slim/history.slim +11 -11
- data/lib/gg/slim/index.slim +18 -12
- data/lib/gg/slim/logger_with_multiple_variables.slim +11 -11
- data/lib/gg/slim/object.slim +2 -2
- data/lib/gg/slim/object_with_instance_variables.slim +9 -9
- data/lib/gg/slim/string.slim +3 -3
- data/lib/gg/version.rb +3 -3
- metadata +2 -1
data/lib/gg/demo_app.rb
CHANGED
@@ -1,77 +1,94 @@
|
|
1
|
-
class GG::DemoApp
|
2
|
-
|
3
|
-
class Custom
|
4
|
-
|
5
|
-
def initialize(shape, size, color)
|
6
|
-
@shape = shape
|
7
|
-
@size = size
|
8
|
-
@color = color
|
9
|
-
end
|
10
|
-
|
11
|
-
attr_reader :shape, :size, :color
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
def call(env)
|
16
|
-
case env[ 'PATH_INFO' ]
|
17
|
-
when '/'
|
18
|
-
response = Rack::Response.new
|
19
|
-
response.write GG.render( 'slim/index.slim' )
|
20
|
-
response
|
21
|
-
when '/demo'
|
22
|
-
log_stuff
|
23
|
-
[ 200, { 'Content-Type' => 'text/html' }, [ "<h1>GG</h1><p>This is a demo of GG</p>"] ]
|
24
|
-
when '/inline_demo'
|
25
|
-
log_stuff
|
26
|
-
[ 200, { 'Content-Type' => 'text/html' }, [ %q{
|
27
|
-
<head>
|
28
|
-
</head>
|
29
|
-
<body>
|
30
|
-
<h1>GG</h1>
|
31
|
-
<p>This is a demo of GG</p>
|
32
|
-
<div style="border:1px dotted silver;padding: 10px;background-color:#F0F0F0;">
|
33
|
-
<!--gg-->
|
34
|
-
</div>
|
35
|
-
<p>This is a footer</p>
|
36
|
-
</body>
|
37
|
-
} ] ]
|
38
|
-
when '/demo.txt'
|
39
|
-
log_stuff
|
40
|
-
[ 200, { 'Content-Type' => 'text/plain' }, [ "This is a demo of GG (output goes to console using awesome_print gem)"] ]
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
gg
|
68
|
-
|
69
|
-
gg
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
1
|
+
class GG::DemoApp
|
2
|
+
|
3
|
+
class Custom
|
4
|
+
|
5
|
+
def initialize(shape, size, color)
|
6
|
+
@shape = shape
|
7
|
+
@size = size
|
8
|
+
@color = color
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_reader :shape, :size, :color
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
def call(env)
|
16
|
+
case env[ 'PATH_INFO' ]
|
17
|
+
when '/'
|
18
|
+
response = Rack::Response.new
|
19
|
+
response.write GG.render( 'slim/index.slim' )
|
20
|
+
response
|
21
|
+
when '/demo'
|
22
|
+
log_stuff
|
23
|
+
[ 200, { 'Content-Type' => 'text/html' }, [ "<h1>GG</h1><p>This is a demo of GG</p>"] ]
|
24
|
+
when '/inline_demo'
|
25
|
+
log_stuff
|
26
|
+
[ 200, { 'Content-Type' => 'text/html' }, [ %q{
|
27
|
+
<head>
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<h1>GG</h1>
|
31
|
+
<p>This is a demo of GG</p>
|
32
|
+
<div style="border:1px dotted silver;padding: 10px;background-color:#F0F0F0;">
|
33
|
+
<!--gg-->
|
34
|
+
</div>
|
35
|
+
<p>This is a footer</p>
|
36
|
+
</body>
|
37
|
+
} ] ]
|
38
|
+
when '/demo.txt'
|
39
|
+
log_stuff
|
40
|
+
[ 200, { 'Content-Type' => 'text/plain' }, [ "This is a demo of GG (output goes to console using awesome_print gem)"] ]
|
41
|
+
when '/env'
|
42
|
+
gg env
|
43
|
+
[ 200, { 'Content-Type' => 'text/html' }, [ "<h1>GG</h1><p>This is a dump of request.env and should contain some recursion</p><!--gg-->"] ]
|
44
|
+
when '/limit'
|
45
|
+
hash = (1..10).inject({}) do |memo, value|
|
46
|
+
memo[value] = (1..20).inject({}) do |memo, value|
|
47
|
+
memo[value] = rand(1..10)
|
48
|
+
memo
|
49
|
+
end
|
50
|
+
memo
|
51
|
+
end
|
52
|
+
gg hash
|
53
|
+
[ 200, { 'Content-Type' => 'text/html' }, [ "<h1>GG</h1><p>This is a dump of request.env and should contain some recursion</p><!--gg-->"] ]
|
54
|
+
else
|
55
|
+
[ 404, { 'Content-Type' => 'text/html' }, [ "<h1>Page Not Found</h1>" ] ]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def log_stuff
|
60
|
+
gg Object.new
|
61
|
+
gg 123
|
62
|
+
gg 12.5
|
63
|
+
gg Object.new, true, :symbol, 'String'
|
64
|
+
gg true
|
65
|
+
gg false
|
66
|
+
gg nil
|
67
|
+
gg /^http[:]/
|
68
|
+
gg "Hello World <Escaped>"
|
69
|
+
gg [ 1, "two", :three, [ 4, 5, 6 ] ]
|
70
|
+
hash = {
|
71
|
+
make: 'Lamborghini',
|
72
|
+
model: 'Aventador',
|
73
|
+
color: 'yellow',
|
74
|
+
tags: [ 'car', 'exotic' ],
|
75
|
+
wheels: {
|
76
|
+
front: 22,
|
77
|
+
rear: 24
|
78
|
+
}
|
79
|
+
}
|
80
|
+
gg hash
|
81
|
+
custom = Custom.new( 'cube', [ 5, 3 ], 'yellow' )
|
82
|
+
gg custom
|
83
|
+
recursive_hash = { a: 'alpha', b: 'bravo' }
|
84
|
+
recursive_array = [ :a, :b, recursive_hash ]
|
85
|
+
recursive_hash[ :array ] = recursive_array
|
86
|
+
recursive_object = Object.new
|
87
|
+
recursive_object.instance_variable_set :@hash, recursive_hash
|
88
|
+
recursive_object.instance_variable_set :@array, recursive_array
|
89
|
+
gg recursive_hash
|
90
|
+
gg recursive_array
|
91
|
+
gg recursive_object
|
92
|
+
end
|
93
|
+
|
77
94
|
end
|
data/lib/gg/history.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
class GG::History < Hash
|
2
|
+
|
3
|
+
# SHOW_LIMIT = 15
|
4
|
+
#
|
5
|
+
# def initialize
|
6
|
+
# @show_count = 0
|
7
|
+
# super
|
8
|
+
# end
|
9
|
+
#
|
10
|
+
# attr_accessor :show_count
|
11
|
+
#
|
12
|
+
# def inc
|
13
|
+
# @show_count += 1
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# def continue?
|
17
|
+
# @show_count <= SHOW_LIMIT
|
18
|
+
# end
|
19
|
+
|
20
|
+
end
|
data/lib/gg/logger.rb
CHANGED
@@ -1,41 +1,41 @@
|
|
1
|
-
require 'forwardable'
|
2
|
-
|
3
|
-
class GG::Logger
|
4
|
-
|
5
|
-
extend Forwardable
|
6
|
-
|
7
|
-
def initialize( env )
|
8
|
-
@env = env
|
9
|
-
@time = Time.now
|
10
|
-
@html_array = []
|
11
|
-
@console_array = []
|
12
|
-
@is_empty = true
|
13
|
-
end
|
14
|
-
|
15
|
-
attr_reader :env, :time, :html_array, :console_array
|
16
|
-
attr_accessor :response
|
17
|
-
|
18
|
-
def request
|
19
|
-
Rack::Request.new( env )
|
20
|
-
end
|
21
|
-
|
22
|
-
def response
|
23
|
-
Rack::Response.new( env )
|
24
|
-
end
|
25
|
-
|
26
|
-
# Adds the given HTML to the HTML array storing all logging information
|
27
|
-
def <<( html )
|
28
|
-
@is_empty = false
|
29
|
-
html_array << html
|
30
|
-
end
|
31
|
-
|
32
|
-
# Returns a String that represent all the HTML sent to the logger via #<<
|
33
|
-
def html
|
34
|
-
html_array.join
|
35
|
-
end
|
36
|
-
|
37
|
-
def empty?
|
38
|
-
@is_empty
|
39
|
-
end
|
40
|
-
|
1
|
+
require 'forwardable'
|
2
|
+
|
3
|
+
class GG::Logger
|
4
|
+
|
5
|
+
extend Forwardable
|
6
|
+
|
7
|
+
def initialize( env )
|
8
|
+
@env = env
|
9
|
+
@time = Time.now
|
10
|
+
@html_array = []
|
11
|
+
@console_array = []
|
12
|
+
@is_empty = true
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :env, :time, :html_array, :console_array
|
16
|
+
attr_accessor :response
|
17
|
+
|
18
|
+
def request
|
19
|
+
Rack::Request.new( env )
|
20
|
+
end
|
21
|
+
|
22
|
+
def response
|
23
|
+
Rack::Response.new( env )
|
24
|
+
end
|
25
|
+
|
26
|
+
# Adds the given HTML to the HTML array storing all logging information
|
27
|
+
def <<( html )
|
28
|
+
@is_empty = false
|
29
|
+
html_array << html
|
30
|
+
end
|
31
|
+
|
32
|
+
# Returns a String that represent all the HTML sent to the logger via #<<
|
33
|
+
def html
|
34
|
+
html_array.join
|
35
|
+
end
|
36
|
+
|
37
|
+
def empty?
|
38
|
+
@is_empty
|
39
|
+
end
|
40
|
+
|
41
41
|
end
|
data/lib/gg/public/gg.css
CHANGED
@@ -1,122 +1,122 @@
|
|
1
|
-
/* LAYOUT */
|
2
|
-
|
3
|
-
.hi-rounded-corners {
|
4
|
-
-moz-border-radius: 15px;
|
5
|
-
-webkit-border-radius: 15px;
|
6
|
-
-khtml-border-radius: 15px;
|
7
|
-
border-radius: 15px;
|
8
|
-
}
|
9
|
-
|
10
|
-
.hi-logger {
|
11
|
-
border: 1px dotted #CCC;
|
12
|
-
padding: 10px;
|
13
|
-
background-color: #F8F8F8;
|
14
|
-
font: 13px arial;
|
15
|
-
margin-bottom: 10px;
|
16
|
-
color: #888;
|
17
|
-
}
|
18
|
-
|
19
|
-
.hi-logger-header {
|
20
|
-
color: black;
|
21
|
-
margin-bottom: 10px;
|
22
|
-
}
|
23
|
-
|
24
|
-
.hi-code-info {
|
25
|
-
color: #808080;
|
26
|
-
font: 11px arial;
|
27
|
-
margin-bottom: 3px;
|
28
|
-
}
|
29
|
-
|
30
|
-
.hi-code-line {
|
31
|
-
font: 12px consolas, monospace;
|
32
|
-
background-color: #FFFFF0;
|
33
|
-
padding: 5px;
|
34
|
-
-moz-border-radius: 10px;
|
35
|
-
-webkit-border-radius: 10px;
|
36
|
-
-khtml-border-radius: 10px;
|
37
|
-
border-radius: 10px;
|
38
|
-
border: 1px dotted #C0C0C0;
|
39
|
-
float: left;
|
40
|
-
margin-bottom: 4px;
|
41
|
-
}
|
42
|
-
|
43
|
-
.hi-logger-body {
|
44
|
-
clear: both;
|
45
|
-
}
|
46
|
-
|
47
|
-
.hi-logger-section {
|
48
|
-
float: left;
|
49
|
-
padding: 5px;
|
50
|
-
border: 1px dotted #CCC;
|
51
|
-
margin-right: 5px;
|
52
|
-
-moz-border-radius: 10px;
|
53
|
-
-webkit-border-radius: 10px;
|
54
|
-
-khtml-border-radius: 10px;
|
55
|
-
border-radius: 10px;
|
56
|
-
background-color: white;
|
57
|
-
}
|
58
|
-
|
59
|
-
/* OBJECT LAYOUT */
|
60
|
-
|
61
|
-
.hi-indent {
|
62
|
-
margin-left: 20px
|
63
|
-
}
|
64
|
-
|
65
|
-
/* OBJECTS */
|
66
|
-
|
67
|
-
.hi-string {
|
68
|
-
color: #048;
|
69
|
-
}
|
70
|
-
|
71
|
-
.hi-Numeric {
|
72
|
-
color: #080;
|
73
|
-
}
|
74
|
-
|
75
|
-
.hi-NilClass {
|
76
|
-
color: #888;
|
77
|
-
}
|
78
|
-
|
79
|
-
.hi-TrueClass, .hi-FalseClass {
|
80
|
-
color: #A0A020;
|
81
|
-
}
|
82
|
-
|
83
|
-
.hi-Symbol {
|
84
|
-
color: #900;
|
85
|
-
}
|
86
|
-
|
87
|
-
|
88
|
-
.hi-instance-variable {
|
89
|
-
color: #808;
|
90
|
-
}
|
91
|
-
|
92
|
-
/* HISTORY VIEW */
|
93
|
-
|
94
|
-
.hi-history-heading {
|
95
|
-
font: bold 24px arial;
|
96
|
-
margin: 0px;
|
97
|
-
clear: both;
|
98
|
-
}
|
99
|
-
.hi-history-subheading {
|
100
|
-
font: 16px arial;
|
101
|
-
margin-top: 5px;
|
102
|
-
margin-bottom: 20px;
|
103
|
-
}
|
104
|
-
.hi-history-pagination {
|
105
|
-
padding: 6px 0px;
|
106
|
-
}
|
107
|
-
.hi-history-pagination a {
|
108
|
-
font: 13px arial;
|
109
|
-
float: left;
|
110
|
-
display: block;
|
111
|
-
border: 1px solid silver;
|
112
|
-
padding: 5px 10px;
|
113
|
-
margin-right: 5px;
|
114
|
-
margin-bottom: 20px;
|
115
|
-
text-decoration: none;
|
116
|
-
color: #404040;
|
117
|
-
background-color: #F0F0F0;
|
118
|
-
}
|
119
|
-
.hi-history-pagination a:hover {
|
120
|
-
background-color: #D0D0FF;
|
121
|
-
}
|
122
|
-
|
1
|
+
/* LAYOUT */
|
2
|
+
|
3
|
+
.hi-rounded-corners {
|
4
|
+
-moz-border-radius: 15px;
|
5
|
+
-webkit-border-radius: 15px;
|
6
|
+
-khtml-border-radius: 15px;
|
7
|
+
border-radius: 15px;
|
8
|
+
}
|
9
|
+
|
10
|
+
.hi-logger {
|
11
|
+
border: 1px dotted #CCC;
|
12
|
+
padding: 10px;
|
13
|
+
background-color: #F8F8F8;
|
14
|
+
font: 13px arial;
|
15
|
+
margin-bottom: 10px;
|
16
|
+
color: #888;
|
17
|
+
}
|
18
|
+
|
19
|
+
.hi-logger-header {
|
20
|
+
color: black;
|
21
|
+
margin-bottom: 10px;
|
22
|
+
}
|
23
|
+
|
24
|
+
.hi-code-info {
|
25
|
+
color: #808080;
|
26
|
+
font: 11px arial;
|
27
|
+
margin-bottom: 3px;
|
28
|
+
}
|
29
|
+
|
30
|
+
.hi-code-line {
|
31
|
+
font: 12px consolas, monospace;
|
32
|
+
background-color: #FFFFF0;
|
33
|
+
padding: 5px;
|
34
|
+
-moz-border-radius: 10px;
|
35
|
+
-webkit-border-radius: 10px;
|
36
|
+
-khtml-border-radius: 10px;
|
37
|
+
border-radius: 10px;
|
38
|
+
border: 1px dotted #C0C0C0;
|
39
|
+
float: left;
|
40
|
+
margin-bottom: 4px;
|
41
|
+
}
|
42
|
+
|
43
|
+
.hi-logger-body {
|
44
|
+
clear: both;
|
45
|
+
}
|
46
|
+
|
47
|
+
.hi-logger-section {
|
48
|
+
float: left;
|
49
|
+
padding: 5px;
|
50
|
+
border: 1px dotted #CCC;
|
51
|
+
margin-right: 5px;
|
52
|
+
-moz-border-radius: 10px;
|
53
|
+
-webkit-border-radius: 10px;
|
54
|
+
-khtml-border-radius: 10px;
|
55
|
+
border-radius: 10px;
|
56
|
+
background-color: white;
|
57
|
+
}
|
58
|
+
|
59
|
+
/* OBJECT LAYOUT */
|
60
|
+
|
61
|
+
.hi-indent {
|
62
|
+
margin-left: 20px
|
63
|
+
}
|
64
|
+
|
65
|
+
/* OBJECTS */
|
66
|
+
|
67
|
+
.hi-string {
|
68
|
+
color: #048;
|
69
|
+
}
|
70
|
+
|
71
|
+
.hi-Numeric {
|
72
|
+
color: #080;
|
73
|
+
}
|
74
|
+
|
75
|
+
.hi-NilClass {
|
76
|
+
color: #888;
|
77
|
+
}
|
78
|
+
|
79
|
+
.hi-TrueClass, .hi-FalseClass {
|
80
|
+
color: #A0A020;
|
81
|
+
}
|
82
|
+
|
83
|
+
.hi-Symbol {
|
84
|
+
color: #900;
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
.hi-instance-variable {
|
89
|
+
color: #808;
|
90
|
+
}
|
91
|
+
|
92
|
+
/* HISTORY VIEW */
|
93
|
+
|
94
|
+
.hi-history-heading {
|
95
|
+
font: bold 24px arial;
|
96
|
+
margin: 0px;
|
97
|
+
clear: both;
|
98
|
+
}
|
99
|
+
.hi-history-subheading {
|
100
|
+
font: 16px arial;
|
101
|
+
margin-top: 5px;
|
102
|
+
margin-bottom: 20px;
|
103
|
+
}
|
104
|
+
.hi-history-pagination {
|
105
|
+
padding: 6px 0px;
|
106
|
+
}
|
107
|
+
.hi-history-pagination a {
|
108
|
+
font: 13px arial;
|
109
|
+
float: left;
|
110
|
+
display: block;
|
111
|
+
border: 1px solid silver;
|
112
|
+
padding: 5px 10px;
|
113
|
+
margin-right: 5px;
|
114
|
+
margin-bottom: 20px;
|
115
|
+
text-decoration: none;
|
116
|
+
color: #404040;
|
117
|
+
background-color: #F0F0F0;
|
118
|
+
}
|
119
|
+
.hi-history-pagination a:hover {
|
120
|
+
background-color: #D0D0FF;
|
121
|
+
}
|
122
|
+
|