mini-sharp-hub 0.0.1

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 (86) hide show
  1. checksums.yaml +7 -0
  2. data/mini-sharp-hub.gemspec +12 -0
  3. data/rack-mini-profiler-4.0.1/CHANGELOG.md +424 -0
  4. data/rack-mini-profiler-4.0.1/README.md +542 -0
  5. data/rack-mini-profiler-4.0.1/lib/enable_rails_patches.rb +5 -0
  6. data/rack-mini-profiler-4.0.1/lib/generators/rack_mini_profiler/USAGE +9 -0
  7. data/rack-mini-profiler-4.0.1/lib/generators/rack_mini_profiler/install_generator.rb +13 -0
  8. data/rack-mini-profiler-4.0.1/lib/generators/rack_mini_profiler/templates/rack_mini_profiler.rb +8 -0
  9. data/rack-mini-profiler-4.0.1/lib/generators/rack_profiler/USAGE +2 -0
  10. data/rack-mini-profiler-4.0.1/lib/generators/rack_profiler/install_generator.rb +16 -0
  11. data/rack-mini-profiler-4.0.1/lib/html/dot.1.1.2.min.js +2 -0
  12. data/rack-mini-profiler-4.0.1/lib/html/includes.css +474 -0
  13. data/rack-mini-profiler-4.0.1/lib/html/includes.js +1520 -0
  14. data/rack-mini-profiler-4.0.1/lib/html/includes.scss +698 -0
  15. data/rack-mini-profiler-4.0.1/lib/html/includes.tmpl +333 -0
  16. data/rack-mini-profiler-4.0.1/lib/html/pretty-print.js +810 -0
  17. data/rack-mini-profiler-4.0.1/lib/html/profile_handler.js +1 -0
  18. data/rack-mini-profiler-4.0.1/lib/html/rack-mini-profiler.css +3 -0
  19. data/rack-mini-profiler-4.0.1/lib/html/rack-mini-profiler.js +2 -0
  20. data/rack-mini-profiler-4.0.1/lib/html/share.html +10 -0
  21. data/rack-mini-profiler-4.0.1/lib/html/speedscope/LICENSE +21 -0
  22. data/rack-mini-profiler-4.0.1/lib/html/speedscope/README.md +3 -0
  23. data/rack-mini-profiler-4.0.1/lib/html/speedscope/demangle-cpp.1768f4cc.js +4 -0
  24. data/rack-mini-profiler-4.0.1/lib/html/speedscope/favicon-16x16.f74b3187.png +0 -0
  25. data/rack-mini-profiler-4.0.1/lib/html/speedscope/favicon-32x32.bc503437.png +0 -0
  26. data/rack-mini-profiler-4.0.1/lib/html/speedscope/file-format-schema.json +324 -0
  27. data/rack-mini-profiler-4.0.1/lib/html/speedscope/fonts/source-code-pro-regular.css +8 -0
  28. data/rack-mini-profiler-4.0.1/lib/html/speedscope/fonts/source-code-pro-v13-regular.woff +0 -0
  29. data/rack-mini-profiler-4.0.1/lib/html/speedscope/fonts/source-code-pro-v13-regular.woff2 +0 -0
  30. data/rack-mini-profiler-4.0.1/lib/html/speedscope/import.8ae8aa3d.js +123 -0
  31. data/rack-mini-profiler-4.0.1/lib/html/speedscope/index.html +2 -0
  32. data/rack-mini-profiler-4.0.1/lib/html/speedscope/release.txt +3 -0
  33. data/rack-mini-profiler-4.0.1/lib/html/speedscope/reset.8c46b7a1.css +2 -0
  34. data/rack-mini-profiler-4.0.1/lib/html/speedscope/source-map.438fa06b.js +24 -0
  35. data/rack-mini-profiler-4.0.1/lib/html/speedscope/speedscope.f27db165.js +193 -0
  36. data/rack-mini-profiler-4.0.1/lib/html/vendor.js +848 -0
  37. data/rack-mini-profiler-4.0.1/lib/mini_profiler/actions.rb +157 -0
  38. data/rack-mini-profiler-4.0.1/lib/mini_profiler/asset_version.rb +6 -0
  39. data/rack-mini-profiler-4.0.1/lib/mini_profiler/client_settings.rb +127 -0
  40. data/rack-mini-profiler-4.0.1/lib/mini_profiler/config.rb +146 -0
  41. data/rack-mini-profiler-4.0.1/lib/mini_profiler/context.rb +14 -0
  42. data/rack-mini-profiler-4.0.1/lib/mini_profiler/gc_profiler.rb +158 -0
  43. data/rack-mini-profiler-4.0.1/lib/mini_profiler/profiling_methods.rb +167 -0
  44. data/rack-mini-profiler-4.0.1/lib/mini_profiler/snapshots_transporter.rb +111 -0
  45. data/rack-mini-profiler-4.0.1/lib/mini_profiler/storage/abstract_store.rb +97 -0
  46. data/rack-mini-profiler-4.0.1/lib/mini_profiler/storage/file_store.rb +179 -0
  47. data/rack-mini-profiler-4.0.1/lib/mini_profiler/storage/memcache_store.rb +105 -0
  48. data/rack-mini-profiler-4.0.1/lib/mini_profiler/storage/memory_store.rb +233 -0
  49. data/rack-mini-profiler-4.0.1/lib/mini_profiler/storage/redis_store.rb +353 -0
  50. data/rack-mini-profiler-4.0.1/lib/mini_profiler/storage.rb +7 -0
  51. data/rack-mini-profiler-4.0.1/lib/mini_profiler/timer_struct/base.rb +39 -0
  52. data/rack-mini-profiler-4.0.1/lib/mini_profiler/timer_struct/client.rb +90 -0
  53. data/rack-mini-profiler-4.0.1/lib/mini_profiler/timer_struct/custom.rb +25 -0
  54. data/rack-mini-profiler-4.0.1/lib/mini_profiler/timer_struct/page.rb +146 -0
  55. data/rack-mini-profiler-4.0.1/lib/mini_profiler/timer_struct/request.rb +186 -0
  56. data/rack-mini-profiler-4.0.1/lib/mini_profiler/timer_struct/sql.rb +89 -0
  57. data/rack-mini-profiler-4.0.1/lib/mini_profiler/timer_struct.rb +8 -0
  58. data/rack-mini-profiler-4.0.1/lib/mini_profiler/version.rb +8 -0
  59. data/rack-mini-profiler-4.0.1/lib/mini_profiler/views.rb +198 -0
  60. data/rack-mini-profiler-4.0.1/lib/mini_profiler.rb +670 -0
  61. data/rack-mini-profiler-4.0.1/lib/mini_profiler_rails/railtie.rb +234 -0
  62. data/rack-mini-profiler-4.0.1/lib/mini_profiler_rails/railtie_methods.rb +61 -0
  63. data/rack-mini-profiler-4.0.1/lib/patches/db/activerecord.rb +44 -0
  64. data/rack-mini-profiler-4.0.1/lib/patches/db/mongo.rb +18 -0
  65. data/rack-mini-profiler-4.0.1/lib/patches/db/moped.rb +14 -0
  66. data/rack-mini-profiler-4.0.1/lib/patches/db/mysql2/alias_method.rb +30 -0
  67. data/rack-mini-profiler-4.0.1/lib/patches/db/mysql2/prepend.rb +34 -0
  68. data/rack-mini-profiler-4.0.1/lib/patches/db/mysql2.rb +7 -0
  69. data/rack-mini-profiler-4.0.1/lib/patches/db/neo4j.rb +16 -0
  70. data/rack-mini-profiler-4.0.1/lib/patches/db/nobrainer.rb +31 -0
  71. data/rack-mini-profiler-4.0.1/lib/patches/db/oracle_enhanced.rb +70 -0
  72. data/rack-mini-profiler-4.0.1/lib/patches/db/pg/alias_method.rb +121 -0
  73. data/rack-mini-profiler-4.0.1/lib/patches/db/pg/prepend.rb +115 -0
  74. data/rack-mini-profiler-4.0.1/lib/patches/db/pg.rb +7 -0
  75. data/rack-mini-profiler-4.0.1/lib/patches/db/plucky.rb +49 -0
  76. data/rack-mini-profiler-4.0.1/lib/patches/db/riak.rb +105 -0
  77. data/rack-mini-profiler-4.0.1/lib/patches/db/rsolr.rb +26 -0
  78. data/rack-mini-profiler-4.0.1/lib/patches/db/sequel.rb +12 -0
  79. data/rack-mini-profiler-4.0.1/lib/patches/net_patches.rb +27 -0
  80. data/rack-mini-profiler-4.0.1/lib/patches/sql_patches.rb +74 -0
  81. data/rack-mini-profiler-4.0.1/lib/prepend_mysql2_patch.rb +5 -0
  82. data/rack-mini-profiler-4.0.1/lib/prepend_net_http_patch.rb +5 -0
  83. data/rack-mini-profiler-4.0.1/lib/prepend_pg_patch.rb +5 -0
  84. data/rack-mini-profiler-4.0.1/lib/rack-mini-profiler.rb +13 -0
  85. data/rack-mini-profiler-4.0.1/rack-mini-profiler.gemspec +49 -0
  86. metadata +125 -0
@@ -0,0 +1,198 @@
1
+ # frozen_string_literal: true
2
+ module Rack
3
+ class MiniProfiler
4
+ module Views
5
+ def resources_root
6
+ @resources_root ||= ::File.expand_path("../../html", __FILE__)
7
+ end
8
+
9
+ def share_template
10
+ @share_template ||= ERB.new(::File.read(::File.expand_path("../html/share.html", ::File.dirname(__FILE__))))
11
+ end
12
+
13
+ def generate_html(page_struct, env, result_json = page_struct.to_json)
14
+ # double-assigning to suppress "assigned but unused variable" warnings
15
+ path = path = "#{env['RACK_MINI_PROFILER_ORIGINAL_SCRIPT_NAME']}#{@config.base_url_path}"
16
+ version = version = MiniProfiler::ASSET_VERSION
17
+ json = json = result_json
18
+ includes = includes = get_profile_script(env)
19
+ name = name = page_struct[:name]
20
+ duration = duration = page_struct.duration_ms.round(1).to_s
21
+
22
+ share_template.result(binding)
23
+ end
24
+
25
+ # get_profile_script returns script to be injected inside current html page
26
+ # By default, profile_script is appended to the end of all html requests automatically.
27
+ # Calling get_profile_script cancels automatic append for the current page
28
+ # Use it when:
29
+ # * you have disabled auto append behaviour throught :auto_inject => false flag
30
+ # * you do not want script to be automatically appended for the current page. You can also call cancel_auto_inject
31
+ def get_profile_script(env, response_headers = {})
32
+ path = public_base_path(env)
33
+ version = MiniProfiler::ASSET_VERSION
34
+ if @config.assets_url
35
+ url = @config.assets_url.call('rack-mini-profiler.js', version, env)
36
+ css_url = @config.assets_url.call('rack-mini-profiler.css', version, env)
37
+ end
38
+
39
+ url = "#{path}includes.js?v=#{version}" if !url
40
+ css_url = "#{path}includes.css?v=#{version}" if !css_url
41
+
42
+ configured_nonce = @config.content_security_policy_nonce
43
+ if configured_nonce && !configured_nonce.is_a?(String)
44
+ configured_nonce = configured_nonce.call(env, response_headers)
45
+ end
46
+
47
+ content_security_policy_nonce = configured_nonce ||
48
+ env["action_dispatch.content_security_policy_nonce"] ||
49
+ env["secure_headers_content_security_policy_nonce"]
50
+
51
+ settings = {
52
+ path: path,
53
+ url: url,
54
+ cssUrl: css_url,
55
+ version: version,
56
+ verticalPosition: @config.vertical_position,
57
+ horizontalPosition: @config.horizontal_position,
58
+ showTrivial: @config.show_trivial,
59
+ showChildren: @config.show_children,
60
+ maxTracesToShow: @config.max_traces_to_show,
61
+ showControls: @config.show_controls,
62
+ showTotalSqlCount: @config.show_total_sql_count,
63
+ authorized: true,
64
+ toggleShortcut: @config.toggle_shortcut,
65
+ startHidden: @config.start_hidden,
66
+ collapseResults: @config.collapse_results,
67
+ htmlContainer: @config.html_container,
68
+ hiddenCustomFields: @config.snapshot_hidden_custom_fields.join(','),
69
+ cspNonce: content_security_policy_nonce,
70
+ hotwireTurboDriveSupport: @config.enable_hotwire_turbo_drive_support,
71
+ }
72
+
73
+ if current && current.page_struct
74
+ settings[:ids] = ids_comma_separated(env)
75
+ settings[:currentId] = current.page_struct[:id]
76
+ else
77
+ settings[:ids] = []
78
+ settings[:currentId] = ""
79
+ end
80
+
81
+ # TODO : cache this snippet
82
+ script = ::File.read(::File.expand_path('../html/profile_handler.js', ::File.dirname(__FILE__)))
83
+ # replace the variables
84
+ settings.each do |k, v|
85
+ regex = Regexp.new("\\{#{k}\\}")
86
+ script.gsub!(regex, v.to_s)
87
+ end
88
+
89
+ current.inject_js = false if current
90
+ script
91
+ end
92
+
93
+ BLANK_PAGE = <<~HTML
94
+ <!DOCTYPE html>
95
+ <html>
96
+ <head>
97
+ <title>Rack::MiniProfiler Requests</title>
98
+ </head>
99
+ <body>
100
+ </body>
101
+ </html>
102
+ HTML
103
+ def blank_page_html
104
+ BLANK_PAGE
105
+ end
106
+
107
+ def make_link(postfix, env)
108
+ link = env["PATH_INFO"] + "?" + env["QUERY_STRING"].sub("#{@config.profile_parameter}=help", "#{@config.profile_parameter}=#{postfix}")
109
+ "#{@config.profile_parameter}=<a href='#{ERB::Util.html_escape(link)}'>#{postfix}</a>"
110
+ end
111
+
112
+ def flamegraph(graph, path, env)
113
+ headers = { 'content-type' => 'text/html' }
114
+ iframe_src = "#{public_base_path(env)}speedscope/index.html"
115
+ html = <<~HTML
116
+ <!DOCTYPE html>
117
+ <html>
118
+ <head>
119
+ <title>Rack::MiniProfiler Flamegraph</title>
120
+ <style>
121
+ body { margin: 0; height: 100vh; }
122
+ #speedscope-iframe { width: 100%; height: 100%; border: none; }
123
+ </style>
124
+ </head>
125
+ <body>
126
+ <script type="text/javascript">
127
+ var graph = #{JSON.generate(graph)};
128
+ var json = JSON.stringify(graph);
129
+ var blob = new Blob([json], { type: 'text/plain' });
130
+ var objUrl = encodeURIComponent(URL.createObjectURL(blob));
131
+ var iframe = document.createElement('IFRAME');
132
+ iframe.setAttribute('id', 'speedscope-iframe');
133
+ document.body.appendChild(iframe);
134
+ var iframeUrl = '#{iframe_src}#profileURL=' + objUrl + '&title=' + 'Flamegraph for #{CGI.escape(path)}';
135
+ iframe.setAttribute('src', iframeUrl);
136
+ </script>
137
+ </body>
138
+ </html>
139
+ HTML
140
+ [200, headers, [html]]
141
+ end
142
+
143
+ def help(client_settings, env)
144
+ headers = { 'content-type' => 'text/html' }
145
+ html = <<~HTML
146
+ <!DOCTYPE html>
147
+ <html>
148
+ <head>
149
+ <title>Rack::MiniProfiler Help</title>
150
+ </head>
151
+ <body>
152
+ <pre style='line-height: 30px; font-size: 16px'>
153
+ This is the help menu of the <a href='#{Rack::MiniProfiler::SOURCE_CODE_URI}'>rack-mini-profiler</a> gem, append the following to your query string for more options:
154
+
155
+ #{make_link "help", env} : display this screen
156
+ #{make_link "env", env} : display the rack environment
157
+ #{make_link "skip", env} : skip mini profiler for this request
158
+ #{make_link "no-backtrace", env} #{"(*) " if client_settings.backtrace_none?}: don't collect stack traces from all the SQL executed (sticky, use #{@config.profile_parameter}=normal-backtrace to enable)
159
+ #{make_link "normal-backtrace", env} #{"(*) " if client_settings.backtrace_default?}: collect stack traces from all the SQL executed and filter normally
160
+ #{make_link "full-backtrace", env} #{"(*) " if client_settings.backtrace_full?}: enable full backtraces for SQL executed (use #{@config.profile_parameter}=normal-backtrace to disable)
161
+ #{make_link "disable", env} : disable profiling for this session
162
+ #{make_link "enable", env} : enable profiling for this session (if previously disabled)
163
+ #{make_link "profile-gc", env} : perform gc profiling on this request, analyzes ObjectSpace generated by request
164
+ #{make_link "profile-memory", env} : requires the memory_profiler gem, new location based report
165
+ #{make_link "flamegraph", env} : a graph representing sampled activity (requires the stackprof gem).
166
+ #{make_link "async-flamegraph", env} : store flamegraph data for this page and all its AJAX requests. Flamegraph links will be available in the mini-profiler UI (requires the stackprof gem).
167
+ #{make_link "flamegraph&flamegraph_sample_rate=1", env}: creates a flamegraph with the specified sample rate (in ms). Overrides value set in config
168
+ #{make_link "flamegraph&flamegraph_mode=cpu", env}: creates a flamegraph with the specified mode (one of cpu, wall, object, or custom). Overrides value set in config
169
+ #{make_link "flamegraph&flamegraph_ignore_gc=true", env}: ignore garbage collection frames in flamegraphs. Overrides value set in config
170
+ #{make_link "flamegraph_embed", env} : a graph representing sampled activity (requires the stackprof gem), embedded resources for use on an intranet.
171
+ #{make_link "trace-exceptions", env} : will return all the spots where your application raises exceptions
172
+ #{make_link "analyze-memory", env} : will perform basic memory analysis of heap
173
+
174
+ All features can also be accessed by adding the X-Rack-Mini-Profiler header to the request, with any of the values above (e.g. 'X-Rack-Mini-Profiler: flamegraph')
175
+ </pre>
176
+ </body>
177
+ </html>
178
+ HTML
179
+
180
+ [200, headers, [html]]
181
+ end
182
+
183
+ def url_for_snapshots_group(group_name)
184
+ qs = Rack::Utils.build_query({ group_name: group_name })
185
+ "/#{@config.base_url_path.gsub('/', '')}/snapshots?#{qs}"
186
+ end
187
+
188
+ def url_for_snapshot(id, group_name)
189
+ qs = Rack::Utils.build_query({ id: id, group: group_name })
190
+ "/#{@config.base_url_path.gsub('/', '')}/results?#{qs}"
191
+ end
192
+
193
+ def public_base_path(env)
194
+ "#{env['RACK_MINI_PROFILER_ORIGINAL_SCRIPT_NAME']}#{@config.base_url_path}"
195
+ end
196
+ end
197
+ end
198
+ end