rubyception 0.1.1 → 0.2.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.
Files changed (39) hide show
  1. data/README.md +26 -6
  2. data/app/assets/images/rubyception/entry_collapse.png +0 -0
  3. data/app/assets/images/rubyception/entry_expand.png +0 -0
  4. data/app/assets/javascripts/rubyception/application.coffee +1 -3
  5. data/app/assets/javascripts/rubyception/routers/log.coffee +4 -2
  6. data/app/assets/javascripts/rubyception/syntax_highlighting.js +543 -0
  7. data/app/assets/javascripts/rubyception/views/backtrace_lines/index.coffee +0 -1
  8. data/app/assets/javascripts/rubyception/views/entries/entry.coffee +30 -11
  9. data/app/assets/stylesheets/rubyception/application.sass +1 -2
  10. data/app/assets/stylesheets/rubyception/entries.sass +54 -5
  11. data/app/assets/stylesheets/rubyception/lines.sass +10 -7
  12. data/app/assets/stylesheets/rubyception/syntax_highlighting.css +138 -0
  13. data/app/controllers/rubyception/templates_controller.rb +12 -0
  14. data/app/helpers/rubyception/application_helper.rb +19 -0
  15. data/app/models/rubyception/entry.rb +37 -2
  16. data/app/views/layouts/rubyception/application.haml +1 -0
  17. data/app/views/rubyception/entries/_entry.haml +14 -7
  18. data/app/views/rubyception/lines/action_view/_render_partial.haml +2 -2
  19. data/app/views/rubyception/lines/action_view/_render_template.haml +2 -2
  20. data/app/views/rubyception/lines/active_record/_identity.haml +2 -2
  21. data/app/views/rubyception/lines/active_record/_sql.haml +3 -3
  22. data/app/views/rubyception/templates/index.js.erb +4 -0
  23. data/config/initializers/sass.rb +1 -2
  24. data/config/initializers/templates.rb +5 -0
  25. data/config/routes.rb +1 -0
  26. data/config/{templating.yml → templates.yml} +7 -7
  27. data/lib/rubyception/engine.rb +27 -0
  28. data/lib/rubyception/version.rb +1 -1
  29. metadata +10 -13
  30. data/app/assets/javascripts/rubyception/shBrushSql.js +0 -66
  31. data/app/assets/javascripts/rubyception/shCore.js +0 -17
  32. data/app/assets/javascripts/rubyception/template.js +0 -1
  33. data/app/assets/stylesheets/rubyception/shCore.css +0 -226
  34. data/app/assets/stylesheets/rubyception/shThemeDefault.css +0 -117
  35. data/app/controllers/rubyception/templating_controller.rb +0 -22
  36. data/config/initializers/websocket_server.rb +0 -22
  37. data/lib/rubyception/templating.rb +0 -48
  38. data/lib/tasks/rubyception_tasks.rake +0 -4
  39. data/lib/tasks/templates.rake +0 -7
@@ -6,7 +6,6 @@ class App.Views.BacktraceLines.Index extends Backbone.View
6
6
  @name = @options.name
7
7
  @bind_render()
8
8
  render: =>
9
- console.log @options
10
9
  @collection.collect 'tbody',
11
10
  args:
12
11
  name: @name
@@ -1,11 +1,17 @@
1
1
  class App.Views.Entries.Entry extends Backbone.View
2
2
  className: 'entry'
3
3
  events:
4
+ 'click .toggle_params': 'toggle_params'
4
5
  'click': 'select_and_toggle'
5
6
  initialize: ->
6
7
  @model.bind 'notice', @notice
7
8
  @model.bind 'ignore', @ignore
8
9
  @render()
10
+ toggle_params: (e) =>
11
+ params = @$ '.params'
12
+ params.toggleClass 'nested'
13
+ e.preventDefault()
14
+ e.stopPropagation()
9
15
  select_and_toggle: (event) =>
10
16
  target = $ event.target
11
17
  # Return unless we clicked directory on .details, or .heading, or a child of .heading
@@ -20,20 +26,33 @@ class App.Views.Entries.Entry extends Backbone.View
20
26
  @color_marker()
21
27
  @params()
22
28
  @backtrace()
29
+ @nested_params @model.get 'parsed_nested_params'
23
30
  @lines()
24
- params:->
25
- params = @model.get 'params'
26
- html = _.map params, (v,k)->
27
- boolean = v is true or v is false
28
- number = !isNaN(parseFloat(v)) && isFinite(v)
29
- kind = if boolean then 'boolean'
30
- else if number then 'number'
31
+ _.defer window.sh_highlightDocument
32
+ escape_html: (text) =>
33
+ text = text.replace /&/g, '&'
34
+ text = text.replace /</g, '&lt;'
35
+ text = text.replace />/g, '&gt;'
36
+ text
37
+ nested_params: (params)=>
38
+ inner_html = _.map params, (v,k) =>
39
+ name = k
40
+ if typeof v != 'string'
41
+ definition = @nested_params(v).html()
31
42
  else
32
- v = "'#{v}'"
33
- 'string'
43
+ definition = "<span class='value string'>#{@escape_html v}</span>"
44
+ "<dt class='key'>#{@escape_html k}<span class='colon'>:</span></dt><dd>#{definition}</dt>"
45
+ html = "<dl>#{inner_html.join('')}</dl>"
46
+ $(@el).find('.params .nested').html html
34
47
 
35
- "<span class='param'><span class='key'>#{k}</span><span class='colon'>:</span> <span class='value #{kind}'>#{v}</span></span>"
36
- $(@el).find('.params').html html.join('')
48
+ params:->
49
+ if $.isEmptyObject @model.get('parsed_params')
50
+ @$('.params').hide()
51
+ return
52
+ params = @model.get 'parsed_params'
53
+ html = _.map params, (v,k)=>
54
+ "<span class='param'><span class='key'>#{@escape_html k}</span><span class='colon'>:</span> <span class='value string'>#{@escape_html v}</span></span>"
55
+ $(@el).find('.params .basic').append html.join('')
37
56
  backtrace:->
38
57
  backtrace = @model.get 'backtrace'
39
58
  if backtrace
@@ -2,5 +2,4 @@
2
2
  @import entries
3
3
  @import lines
4
4
  @import backtrace_lines
5
- @import shCore.css
6
- @import shThemeDefault.css
5
+ @import syntax_highlighting
@@ -1,3 +1,5 @@
1
+ body
2
+ :width 100%
1
3
  .entry
2
4
  :position relative
3
5
  :-webkit-box-shadow rgba(255, 255, 255, 0.07) 0px 1px 0
@@ -27,14 +29,33 @@
27
29
  :background rgb(250,50,0)
28
30
  .details
29
31
  :padding 0 10px
32
+ .method
33
+ :width 70px
34
+ .controller
35
+ :width 200px
36
+ .format
37
+ :width 50px
38
+ .datetime
39
+ :width 70px
40
+ .ms
41
+ :width 80px
30
42
  .method, .format
31
43
  :text-transform uppercase
32
- .heading
44
+ .heading_wrapper
33
45
  :padding 10px 0 10px 0
34
- div
35
- :display inline-block
46
+ .heading
47
+ :overflow auto
48
+ :table-layout fixed
49
+ :border-collapse collapse
50
+ :width 100%
51
+ td
52
+ :padding-right 5px
53
+ :white-space nowrap
54
+ :overflow hidden
55
+ :text-overflow ellipsis
56
+ td:last-child
57
+ :padding-right 0
36
58
  .ms, .datetime
37
- :float right
38
59
  :margin
39
60
  :left 10px
40
61
  .ms.slow
@@ -60,7 +81,7 @@
60
81
  :height 2px
61
82
  :margin 2px 0
62
83
 
63
- .params
84
+ .params, .nested_params
64
85
  :padding 5px
65
86
  :top 0px
66
87
  :font-size 12px
@@ -92,3 +113,31 @@ body.pretty_params
92
113
  //:display table-cell
93
114
  //.key, .colon
94
115
  //:width 1%
116
+ .params
117
+ .nested
118
+ :display none
119
+ a.toggle_params
120
+ :display block
121
+ :float left
122
+ :width 15px
123
+ :height 15px
124
+ :background image-url('rubyception/entry_collapse.png') no-repeat center center
125
+
126
+ .params.nested
127
+ a.toggle_params
128
+ :background image-url('rubyception/entry_expand.png') no-repeat center center
129
+ .basic
130
+ :display none
131
+ .nested
132
+ :display block
133
+ .nested
134
+ :clear both
135
+ dt
136
+ :clear both
137
+ :margin-right 10px
138
+ :text-align right
139
+ :width 120px
140
+ :word-wrap break-word
141
+ dt, dd
142
+ :float left
143
+
@@ -1,5 +1,6 @@
1
1
  .lines
2
- :font-family 'Menlo'
2
+ tr, td, pre, div, span
3
+ :font-family monospace
3
4
  :margin
4
5
  :top 5px
5
6
  :background rgb(32, 32, 32)
@@ -13,24 +14,26 @@
13
14
  :vertical-align bottom
14
15
  .line
15
16
  :font-size 11px
17
+ .name, .duration, .msg, .layout
18
+ :white-space nowrap
19
+ .num,.msg
20
+ :padding 1px 5px
16
21
  .duration
17
22
  :text-align right
18
23
  :color rgb(50,250,100)
19
- .num,.msg
20
- :display inline-block
21
- :padding 1px 5px
22
- .msg
23
- :padding
24
- :left 1px
25
24
  .num
26
25
  :text-align right
27
26
  :background rgb(0,0,0)
28
27
  td:first-child
28
+ :background rgb(10,10,10)
29
29
  :padding
30
+ :right 5px
30
31
  :left 5px
31
32
  td:last-child
32
33
  :padding
33
34
  :right 5px
35
+ .max
36
+ :width 100%
34
37
  .line:first-child
35
38
  td
36
39
  :padding
@@ -0,0 +1,138 @@
1
+ pre.sh_sourceCode {
2
+ color: #ffffff;
3
+ font-weight: normal;
4
+ font-style: normal;
5
+ }
6
+
7
+ pre.sh_sourceCode .sh_keyword {
8
+ color: #B26818;
9
+ font-weight: normal;
10
+ font-style: normal;
11
+ }
12
+
13
+ pre.sh_sourceCode .sh_type {
14
+ color: #00ff00;
15
+ font-weight: normal;
16
+ font-style: normal;
17
+ }
18
+
19
+ pre.sh_sourceCode .sh_string {
20
+ color: #ff0000;
21
+ font-weight: normal;
22
+ font-style: normal;
23
+ }
24
+
25
+ pre.sh_sourceCode .sh_regexp {
26
+ color: #ff0000;
27
+ font-weight: normal;
28
+ font-style: normal;
29
+ }
30
+
31
+ pre.sh_sourceCode .sh_specialchar {
32
+ color: #ff22ff;
33
+ font-weight: normal;
34
+ font-style: normal;
35
+ }
36
+
37
+ pre.sh_sourceCode .sh_comment {
38
+ color: #0000ff;
39
+ font-weight: normal;
40
+ font-style: normal;
41
+ }
42
+
43
+ pre.sh_sourceCode .sh_number {
44
+ color: #ff0000;
45
+ font-weight: normal;
46
+ font-style: normal;
47
+ }
48
+
49
+ pre.sh_sourceCode .sh_preproc {
50
+ color: #ff22ff;
51
+ font-weight: normal;
52
+ font-style: normal;
53
+ }
54
+
55
+ pre.sh_sourceCode .sh_function {
56
+ color: #ffffff;
57
+ font-weight: normal;
58
+ font-style: normal;
59
+ }
60
+
61
+ pre.sh_sourceCode .sh_url {
62
+ color: #ff0000;
63
+ font-weight: normal;
64
+ font-style: normal;
65
+ }
66
+
67
+ pre.sh_sourceCode .sh_date {
68
+ color: #B26818;
69
+ font-weight: normal;
70
+ font-style: normal;
71
+ }
72
+
73
+ pre.sh_sourceCode .sh_time {
74
+ color: #B26818;
75
+ font-weight: normal;
76
+ font-style: normal;
77
+ }
78
+
79
+ pre.sh_sourceCode .sh_file {
80
+ color: #B26818;
81
+ font-weight: normal;
82
+ font-style: normal;
83
+ }
84
+
85
+ pre.sh_sourceCode .sh_ip {
86
+ color: #ff0000;
87
+ font-weight: normal;
88
+ font-style: normal;
89
+ }
90
+
91
+ pre.sh_sourceCode .sh_name {
92
+ color: #ff0000;
93
+ font-weight: normal;
94
+ font-style: normal;
95
+ }
96
+
97
+ pre.sh_sourceCode .sh_variable {
98
+ color: #B26818;
99
+ font-weight: normal;
100
+ font-style: normal;
101
+ }
102
+
103
+ pre.sh_sourceCode .sh_oldfile {
104
+ color: #ff22ff;
105
+ font-weight: normal;
106
+ font-style: normal;
107
+ }
108
+
109
+ pre.sh_sourceCode .sh_newfile {
110
+ color: #ff0000;
111
+ font-weight: normal;
112
+ font-style: normal;
113
+ }
114
+
115
+ pre.sh_sourceCode .sh_difflines {
116
+ color: #B26818;
117
+ font-weight: normal;
118
+ font-style: normal;
119
+ }
120
+
121
+ pre.sh_sourceCode .sh_selector {
122
+ color: #B26818;
123
+ font-weight: normal;
124
+ font-style: normal;
125
+ }
126
+
127
+ pre.sh_sourceCode .sh_property {
128
+ color: #B26818;
129
+ font-weight: normal;
130
+ font-style: normal;
131
+ }
132
+
133
+ pre.sh_sourceCode .sh_value {
134
+ color: #ff0000;
135
+ font-weight: normal;
136
+ font-style: normal;
137
+ }
138
+
@@ -0,0 +1,12 @@
1
+ class Rubyception::TemplatesController < ApplicationController
2
+ layout false
3
+
4
+ helper :all
5
+
6
+ def index
7
+ @templates = {}
8
+ respond_to do |f|
9
+ f.js
10
+ end
11
+ end
12
+ end
@@ -5,5 +5,24 @@ module Rubyception
5
5
  class: 'show_rails',
6
6
  onclick: 'return false'
7
7
  end
8
+ def parse_tree tree, parents=[], result={}
9
+ if tree.is_a?(String)
10
+ item = result
11
+ parents.each do |parent|
12
+ item[parent] ||= {}
13
+ item = item[parent]
14
+ end
15
+ item[tree] = render(partial: "rubyception/#{parents.join('/')}/#{tree}")
16
+ elsif tree.is_a?(Hash)
17
+ tree.each do |key, val|
18
+ parse_tree val, parents + [key], result
19
+ end
20
+ elsif tree.is_a?(Array)
21
+ tree.each do |val|
22
+ parse_tree val, parents, result
23
+ end
24
+ end
25
+ result
26
+ end
8
27
  end
9
28
  end
@@ -32,8 +32,41 @@ class Rubyception::Entry
32
32
  params.delete 'controller'
33
33
  params.delete 'action'
34
34
  self.params = params
35
- self.start_time = event.time.to_s :entry
36
- self.end_time = event.end.to_s :entry
35
+ self.start_time = event.time.strftime('%H:%M:%S')
36
+ self.end_time = event.end.strftime('%H:%M:%S')
37
+ end
38
+
39
+
40
+ def parsed_params
41
+ result = {}
42
+ jsonified = params.collect do |key,val|
43
+ [key, val.to_json]
44
+ end
45
+ Hash[jsonified]
46
+ end
47
+
48
+ def deep_clone_hash hash
49
+ result = {}
50
+ hash.each do |k,v|
51
+ if v.is_a? Hash
52
+ result[k] = deep_clone_hash v
53
+ else
54
+ result[k] = v
55
+ end
56
+ end
57
+ result
58
+ end
59
+
60
+ def parsed_nested_params params=nil
61
+ params ||= deep_clone_hash(self.params)
62
+ if params.kind_of? Hash
63
+ params.each do |key,val|
64
+ params[key] = parsed_nested_params(params[key])
65
+ end
66
+ else
67
+ return params.inspect
68
+ end
69
+ params
37
70
  end
38
71
 
39
72
  def error?; error; end
@@ -97,6 +130,8 @@ class Rubyception::Entry
97
130
  backtrace
98
131
  finished
99
132
  start_time
133
+ parsed_params
134
+ parsed_nested_params
100
135
  end_time}
101
136
  result = {}
102
137
  methods.each do |method|
@@ -3,6 +3,7 @@
3
3
  %head
4
4
  %title Rubyception
5
5
  = stylesheet_link_tag 'rubyception/application', :media => 'all'
6
+ = javascript_include_tag '/rubyception/templates'
6
7
  = javascript_include_tag 'rubyception/application'
7
8
  = csrf_meta_tags
8
9
  %body
@@ -1,13 +1,20 @@
1
1
  .marker
2
2
  .details
3
- .heading
4
- .method {{method}}
5
- .format {{format}}
6
- = '{{controller}}#{{action}}'
7
- .path {{path}}
8
- .datetime {{start_time}}
9
- .ms {{duration}}ms
3
+ .heading_wrapper
4
+ %table.heading
5
+ %tr
6
+ %td.method {{method}}
7
+ %td.controller{title: '{{controller}}#{{action}}'}
8
+ = '{{controller}}#{{action}}'
9
+ %td.format {{format}}
10
+ %td.path{title: '{{path}}'} {{path}}
11
+ %td.datetime {{start_time}}
12
+ %td.ms {{duration}}ms
10
13
  .params
14
+ %a.toggle_params{href: '#'}
15
+ .basic
16
+ %dl.nested
17
+ .clear
11
18
  .lines
12
19
  .backtrace_lines
13
20
  .clear