power_trace 0.2.2 → 0.3.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 (130) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +3 -18
  3. data/Gemfile +5 -0
  4. data/Gemfile.lock +124 -1
  5. data/README.md +70 -19
  6. data/examples/rails-6/.browserslistrc +1 -0
  7. data/examples/rails-6/.gitignore +41 -0
  8. data/examples/rails-6/.ruby-version +1 -0
  9. data/examples/rails-6/Gemfile +55 -0
  10. data/examples/rails-6/Gemfile.lock +233 -0
  11. data/examples/rails-6/README.md +24 -0
  12. data/examples/rails-6/Rakefile +6 -0
  13. data/examples/rails-6/app/assets/config/manifest.js +2 -0
  14. data/examples/rails-6/app/assets/images/.keep +0 -0
  15. data/examples/rails-6/app/assets/stylesheets/application.css +15 -0
  16. data/examples/rails-6/app/assets/stylesheets/posts.scss +3 -0
  17. data/examples/rails-6/app/assets/stylesheets/scaffolds.scss +65 -0
  18. data/examples/rails-6/app/channels/application_cable/channel.rb +4 -0
  19. data/examples/rails-6/app/channels/application_cable/connection.rb +4 -0
  20. data/examples/rails-6/app/controllers/application_controller.rb +2 -0
  21. data/examples/rails-6/app/controllers/concerns/.keep +0 -0
  22. data/examples/rails-6/app/controllers/posts_controller.rb +75 -0
  23. data/examples/rails-6/app/helpers/application_helper.rb +2 -0
  24. data/examples/rails-6/app/helpers/posts_helper.rb +2 -0
  25. data/examples/rails-6/app/javascript/channels/consumer.js +6 -0
  26. data/examples/rails-6/app/javascript/channels/index.js +5 -0
  27. data/examples/rails-6/app/javascript/packs/application.js +17 -0
  28. data/examples/rails-6/app/jobs/application_job.rb +7 -0
  29. data/examples/rails-6/app/mailers/application_mailer.rb +4 -0
  30. data/examples/rails-6/app/models/application_record.rb +3 -0
  31. data/examples/rails-6/app/models/concerns/.keep +0 -0
  32. data/examples/rails-6/app/models/post.rb +2 -0
  33. data/examples/rails-6/app/views/layouts/application.html.erb +15 -0
  34. data/examples/rails-6/app/views/layouts/mailer.html.erb +13 -0
  35. data/examples/rails-6/app/views/layouts/mailer.text.erb +1 -0
  36. data/examples/rails-6/app/views/posts/_form.html.erb +27 -0
  37. data/examples/rails-6/app/views/posts/_post.json.jbuilder +2 -0
  38. data/examples/rails-6/app/views/posts/edit.html.erb +6 -0
  39. data/examples/rails-6/app/views/posts/index.html.erb +29 -0
  40. data/examples/rails-6/app/views/posts/index.json.jbuilder +1 -0
  41. data/examples/rails-6/app/views/posts/new.html.erb +5 -0
  42. data/examples/rails-6/app/views/posts/show.html.erb +14 -0
  43. data/examples/rails-6/app/views/posts/show.json.jbuilder +1 -0
  44. data/examples/rails-6/babel.config.js +72 -0
  45. data/examples/rails-6/bin/bundle +114 -0
  46. data/examples/rails-6/bin/rails +9 -0
  47. data/examples/rails-6/bin/rake +9 -0
  48. data/examples/rails-6/bin/setup +36 -0
  49. data/examples/rails-6/bin/webpack +18 -0
  50. data/examples/rails-6/bin/webpack-dev-server +18 -0
  51. data/examples/rails-6/bin/yarn +11 -0
  52. data/examples/rails-6/config.ru +5 -0
  53. data/examples/rails-6/config/application.rb +19 -0
  54. data/examples/rails-6/config/boot.rb +4 -0
  55. data/examples/rails-6/config/cable.yml +10 -0
  56. data/examples/rails-6/config/credentials.yml.enc +1 -0
  57. data/examples/rails-6/config/database.yml +25 -0
  58. data/examples/rails-6/config/environment.rb +5 -0
  59. data/examples/rails-6/config/environments/development.rb +62 -0
  60. data/examples/rails-6/config/environments/production.rb +112 -0
  61. data/examples/rails-6/config/environments/test.rb +49 -0
  62. data/examples/rails-6/config/initializers/application_controller_renderer.rb +8 -0
  63. data/examples/rails-6/config/initializers/assets.rb +14 -0
  64. data/examples/rails-6/config/initializers/backtrace_silencers.rb +7 -0
  65. data/examples/rails-6/config/initializers/content_security_policy.rb +30 -0
  66. data/examples/rails-6/config/initializers/cookies_serializer.rb +5 -0
  67. data/examples/rails-6/config/initializers/filter_parameter_logging.rb +4 -0
  68. data/examples/rails-6/config/initializers/inflections.rb +16 -0
  69. data/examples/rails-6/config/initializers/mime_types.rb +4 -0
  70. data/examples/rails-6/config/initializers/power_trace.rb +3 -0
  71. data/examples/rails-6/config/initializers/wrap_parameters.rb +14 -0
  72. data/examples/rails-6/config/locales/en.yml +33 -0
  73. data/examples/rails-6/config/puma.rb +38 -0
  74. data/examples/rails-6/config/routes.rb +5 -0
  75. data/examples/rails-6/config/storage.yml +34 -0
  76. data/examples/rails-6/config/webpack/development.js +5 -0
  77. data/examples/rails-6/config/webpack/environment.js +3 -0
  78. data/examples/rails-6/config/webpack/production.js +5 -0
  79. data/examples/rails-6/config/webpack/test.js +5 -0
  80. data/examples/rails-6/config/webpacker.yml +96 -0
  81. data/examples/rails-6/db/migrate/20200829063653_create_posts.rb +10 -0
  82. data/examples/rails-6/db/seeds.rb +7 -0
  83. data/examples/rails-6/lib/assets/.keep +0 -0
  84. data/examples/rails-6/lib/tasks/.keep +0 -0
  85. data/examples/rails-6/log/.keep +0 -0
  86. data/examples/rails-6/package.json +15 -0
  87. data/examples/rails-6/postcss.config.js +12 -0
  88. data/examples/rails-6/public/404.html +67 -0
  89. data/examples/rails-6/public/422.html +67 -0
  90. data/examples/rails-6/public/500.html +66 -0
  91. data/examples/rails-6/public/apple-touch-icon-precomposed.png +0 -0
  92. data/examples/rails-6/public/apple-touch-icon.png +0 -0
  93. data/examples/rails-6/public/favicon.ico +0 -0
  94. data/examples/rails-6/public/robots.txt +1 -0
  95. data/examples/rails-6/storage/.keep +0 -0
  96. data/examples/rails-6/test/application_system_test_case.rb +5 -0
  97. data/examples/rails-6/test/channels/application_cable/connection_test.rb +11 -0
  98. data/examples/rails-6/test/controllers/.keep +0 -0
  99. data/examples/rails-6/test/controllers/posts_controller_test.rb +48 -0
  100. data/examples/rails-6/test/fixtures/.keep +0 -0
  101. data/examples/rails-6/test/fixtures/files/.keep +0 -0
  102. data/examples/rails-6/test/fixtures/posts.yml +9 -0
  103. data/examples/rails-6/test/helpers/.keep +0 -0
  104. data/examples/rails-6/test/integration/.keep +0 -0
  105. data/examples/rails-6/test/mailers/.keep +0 -0
  106. data/examples/rails-6/test/models/.keep +0 -0
  107. data/examples/rails-6/test/models/post_test.rb +7 -0
  108. data/examples/rails-6/test/system/.keep +0 -0
  109. data/examples/rails-6/test/system/posts_test.rb +45 -0
  110. data/examples/rails-6/test/test_helper.rb +13 -0
  111. data/examples/rails-6/tmp/.keep +0 -0
  112. data/examples/rails-6/tmp/pids/.keep +0 -0
  113. data/examples/rails-6/vendor/.keep +0 -0
  114. data/examples/rails-6/yarn.lock +7593 -0
  115. data/images/normal_minitest_error.png +0 -0
  116. data/images/normal_rails_error.png +0 -0
  117. data/images/power_minitest_error.png +0 -0
  118. data/images/power_rails_error.png +0 -0
  119. data/lib/power_trace.rb +24 -7
  120. data/lib/power_trace/entry.rb +75 -10
  121. data/lib/power_trace/exception_patch.rb +1 -1
  122. data/lib/power_trace/integrations/minitest.rb +14 -0
  123. data/lib/power_trace/integrations/rails.rb +2 -0
  124. data/lib/power_trace/integrations/rspec.rb +11 -0
  125. data/lib/power_trace/rails/action_dispatch/debug_exceptions.rb +28 -0
  126. data/lib/power_trace/rails/action_dispatch/exception_wrapper.rb +28 -0
  127. data/lib/power_trace/version.rb +1 -1
  128. data/power_trace.gemspec +1 -0
  129. metadata +134 -3
  130. data/lib/power_trace/rspec_patch.rb +0 -15
@@ -0,0 +1,24 @@
1
+ # README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative 'config/application'
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,2 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../stylesheets .css
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
6
+ * vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,3 @@
1
+ // Place all the styles related to the Posts controller here.
2
+ // They will automatically be included in application.css.
3
+ // You can use Sass (SCSS) here: https://sass-lang.com/
@@ -0,0 +1,65 @@
1
+ body {
2
+ background-color: #fff;
3
+ color: #333;
4
+ margin: 33px; }
5
+
6
+ body, p, ol, ul, td {
7
+ font-family: verdana, arial, helvetica, sans-serif;
8
+ font-size: 13px;
9
+ line-height: 18px; }
10
+
11
+ pre {
12
+ background-color: #eee;
13
+ padding: 10px;
14
+ font-size: 11px; }
15
+
16
+ a {
17
+ color: #000; }
18
+
19
+ a:visited {
20
+ color: #666; }
21
+
22
+ a:hover {
23
+ color: #fff;
24
+ background-color: #000; }
25
+
26
+ th {
27
+ padding-bottom: 5px; }
28
+
29
+ td {
30
+ padding: 0 5px 7px; }
31
+
32
+ div.field,
33
+ div.actions {
34
+ margin-bottom: 10px; }
35
+
36
+ #notice {
37
+ color: green; }
38
+
39
+ .field_with_errors {
40
+ padding: 2px;
41
+ background-color: red;
42
+ display: table; }
43
+
44
+ #error_explanation {
45
+ width: 450px;
46
+ border: 2px solid red;
47
+ padding: 7px 7px 0;
48
+ margin-bottom: 20px;
49
+ background-color: #f0f0f0; }
50
+
51
+ #error_explanation h2 {
52
+ text-align: left;
53
+ font-weight: bold;
54
+ padding: 5px 5px 5px 15px;
55
+ font-size: 12px;
56
+ margin: -7px -7px 0;
57
+ background-color: #c00;
58
+ color: #fff; }
59
+
60
+ #error_explanation ul li {
61
+ font-size: 12px;
62
+ list-style: square; }
63
+
64
+ label {
65
+ display: block; }
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Channel < ActionCable::Channel::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Connection < ActionCable::Connection::Base
3
+ end
4
+ end
@@ -0,0 +1,2 @@
1
+ class ApplicationController < ActionController::Base
2
+ end
@@ -0,0 +1,75 @@
1
+ class PostsController < ApplicationController
2
+ before_action :set_post, only: [:show, :edit, :update, :destroy]
3
+
4
+ # GET /posts
5
+ # GET /posts.json
6
+ def index
7
+ @posts = Post.all
8
+ raise "foo"
9
+ end
10
+
11
+ # GET /posts/1
12
+ # GET /posts/1.json
13
+ def show
14
+ end
15
+
16
+ # GET /posts/new
17
+ def new
18
+ @post = Post.new
19
+ end
20
+
21
+ # GET /posts/1/edit
22
+ def edit
23
+ end
24
+
25
+ # POST /posts
26
+ # POST /posts.json
27
+ def create
28
+ @post = Post.new(post_params)
29
+
30
+ respond_to do |format|
31
+ if @post.save
32
+ format.html { redirect_to @post, notice: 'Post was successfully created.' }
33
+ format.json { render :show, status: :created, location: @post }
34
+ else
35
+ format.html { render :new }
36
+ format.json { render json: @post.errors, status: :unprocessable_entity }
37
+ end
38
+ end
39
+ end
40
+
41
+ # PATCH/PUT /posts/1
42
+ # PATCH/PUT /posts/1.json
43
+ def update
44
+ respond_to do |format|
45
+ if @post.update(post_params)
46
+ format.html { redirect_to @post, notice: 'Post was successfully updated.' }
47
+ format.json { render :show, status: :ok, location: @post }
48
+ else
49
+ format.html { render :edit }
50
+ format.json { render json: @post.errors, status: :unprocessable_entity }
51
+ end
52
+ end
53
+ end
54
+
55
+ # DELETE /posts/1
56
+ # DELETE /posts/1.json
57
+ def destroy
58
+ @post.destroy
59
+ respond_to do |format|
60
+ format.html { redirect_to posts_url, notice: 'Post was successfully destroyed.' }
61
+ format.json { head :no_content }
62
+ end
63
+ end
64
+
65
+ private
66
+ # Use callbacks to share common setup or constraints between actions.
67
+ def set_post
68
+ @post = Post.find(params[:id])
69
+ end
70
+
71
+ # Only allow a list of trusted parameters through.
72
+ def post_params
73
+ params.require(:post).permit(:title, :context)
74
+ end
75
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module PostsHelper
2
+ end
@@ -0,0 +1,6 @@
1
+ // Action Cable provides the framework to deal with WebSockets in Rails.
2
+ // You can generate new channels where WebSocket features live using the `rails generate channel` command.
3
+
4
+ import { createConsumer } from "@rails/actioncable"
5
+
6
+ export default createConsumer()
@@ -0,0 +1,5 @@
1
+ // Load all the channels within this directory and all subdirectories.
2
+ // Channel files must be named *_channel.js.
3
+
4
+ const channels = require.context('.', true, /_channel\.js$/)
5
+ channels.keys().forEach(channels)
@@ -0,0 +1,17 @@
1
+ // This file is automatically compiled by Webpack, along with any other files
2
+ // present in this directory. You're encouraged to place your actual application logic in
3
+ // a relevant structure within app/javascript and only use these pack files to reference
4
+ // that code so it'll be compiled.
5
+
6
+ require("@rails/ujs").start()
7
+ require("turbolinks").start()
8
+ require("@rails/activestorage").start()
9
+ require("channels")
10
+
11
+
12
+ // Uncomment to copy all static images under ../images to the output folder and reference
13
+ // them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
14
+ // or the `imagePath` JavaScript helper below.
15
+ //
16
+ // const images = require.context('../images', true)
17
+ // const imagePath = (name) => images(name, true)
@@ -0,0 +1,7 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ # Automatically retry jobs that encountered a deadlock
3
+ # retry_on ActiveRecord::Deadlocked
4
+
5
+ # Most jobs are safe to ignore if the underlying records are no longer available
6
+ # discard_on ActiveJob::DeserializationError
7
+ end
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: 'from@example.com'
3
+ layout 'mailer'
4
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -0,0 +1,2 @@
1
+ class Post < ApplicationRecord
2
+ end
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Rails6</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
9
+ <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
10
+ </head>
11
+
12
+ <body>
13
+ <%= yield %>
14
+ </body>
15
+ </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1,27 @@
1
+ <%= form_with(model: post, local: true) do |form| %>
2
+ <% if post.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(post.errors.count, "error") %> prohibited this post from being saved:</h2>
5
+
6
+ <ul>
7
+ <% post.errors.full_messages.each do |message| %>
8
+ <li><%= message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= form.label :title %>
16
+ <%= form.text_field :title %>
17
+ </div>
18
+
19
+ <div class="field">
20
+ <%= form.label :context %>
21
+ <%= form.text_area :context %>
22
+ </div>
23
+
24
+ <div class="actions">
25
+ <%= form.submit %>
26
+ </div>
27
+ <% end %>
@@ -0,0 +1,2 @@
1
+ json.extract! post, :id, :title, :context, :created_at, :updated_at
2
+ json.url post_url(post, format: :json)
@@ -0,0 +1,6 @@
1
+ <h1>Editing Post</h1>
2
+
3
+ <%= render 'form', post: @post %>
4
+
5
+ <%= link_to 'Show', @post %> |
6
+ <%= link_to 'Back', posts_path %>
@@ -0,0 +1,29 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <h1>Posts</h1>
4
+
5
+ <table>
6
+ <thead>
7
+ <tr>
8
+ <th>Title</th>
9
+ <th>Context</th>
10
+ <th colspan="3"></th>
11
+ </tr>
12
+ </thead>
13
+
14
+ <tbody>
15
+ <% @posts.each do |post| %>
16
+ <tr>
17
+ <td><%= post.title %></td>
18
+ <td><%= post.context %></td>
19
+ <td><%= link_to 'Show', post %></td>
20
+ <td><%= link_to 'Edit', edit_post_path(post) %></td>
21
+ <td><%= link_to 'Destroy', post, method: :delete, data: { confirm: 'Are you sure?' } %></td>
22
+ </tr>
23
+ <% end %>
24
+ </tbody>
25
+ </table>
26
+
27
+ <br>
28
+
29
+ <%= link_to 'New Post', new_post_path %>
@@ -0,0 +1 @@
1
+ json.array! @posts, partial: "posts/post", as: :post
@@ -0,0 +1,5 @@
1
+ <h1>New Post</h1>
2
+
3
+ <%= render 'form', post: @post %>
4
+
5
+ <%= link_to 'Back', posts_path %>
@@ -0,0 +1,14 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <strong>Title:</strong>
5
+ <%= @post.title %>
6
+ </p>
7
+
8
+ <p>
9
+ <strong>Context:</strong>
10
+ <%= @post.context %>
11
+ </p>
12
+
13
+ <%= link_to 'Edit', edit_post_path(@post) %> |
14
+ <%= link_to 'Back', posts_path %>
@@ -0,0 +1 @@
1
+ json.partial! "posts/post", post: @post
@@ -0,0 +1,72 @@
1
+ module.exports = function(api) {
2
+ var validEnv = ['development', 'test', 'production']
3
+ var currentEnv = api.env()
4
+ var isDevelopmentEnv = api.env('development')
5
+ var isProductionEnv = api.env('production')
6
+ var isTestEnv = api.env('test')
7
+
8
+ if (!validEnv.includes(currentEnv)) {
9
+ throw new Error(
10
+ 'Please specify a valid `NODE_ENV` or ' +
11
+ '`BABEL_ENV` environment variables. Valid values are "development", ' +
12
+ '"test", and "production". Instead, received: ' +
13
+ JSON.stringify(currentEnv) +
14
+ '.'
15
+ )
16
+ }
17
+
18
+ return {
19
+ presets: [
20
+ isTestEnv && [
21
+ '@babel/preset-env',
22
+ {
23
+ targets: {
24
+ node: 'current'
25
+ }
26
+ }
27
+ ],
28
+ (isProductionEnv || isDevelopmentEnv) && [
29
+ '@babel/preset-env',
30
+ {
31
+ forceAllTransforms: true,
32
+ useBuiltIns: 'entry',
33
+ corejs: 3,
34
+ modules: false,
35
+ exclude: ['transform-typeof-symbol']
36
+ }
37
+ ]
38
+ ].filter(Boolean),
39
+ plugins: [
40
+ 'babel-plugin-macros',
41
+ '@babel/plugin-syntax-dynamic-import',
42
+ isTestEnv && 'babel-plugin-dynamic-import-node',
43
+ '@babel/plugin-transform-destructuring',
44
+ [
45
+ '@babel/plugin-proposal-class-properties',
46
+ {
47
+ loose: true
48
+ }
49
+ ],
50
+ [
51
+ '@babel/plugin-proposal-object-rest-spread',
52
+ {
53
+ useBuiltIns: true
54
+ }
55
+ ],
56
+ [
57
+ '@babel/plugin-transform-runtime',
58
+ {
59
+ helpers: false,
60
+ regenerator: true,
61
+ corejs: false
62
+ }
63
+ ],
64
+ [
65
+ '@babel/plugin-transform-regenerator',
66
+ {
67
+ async: false
68
+ }
69
+ ]
70
+ ].filter(Boolean)
71
+ }
72
+ }