benchdog-rails 0.1.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.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +85 -0
- data/config/routes.rb +6 -0
- data/dashboard/assets/embroider-virtual-app-3rXH0eIh.css +1860 -0
- data/dashboard/assets/embroider-virtual-vendor-3fUXwkzh.js +9 -0
- data/dashboard/assets/embroider-virtual-vendor-B_SY1GJM.css +0 -0
- data/dashboard/assets/main-DA4FE5ZT.css +1 -0
- data/dashboard/assets/main-Dg-YB7-H.js +1 -0
- data/dashboard/favicon.svg +57 -0
- data/dashboard/index.html +25 -0
- data/lib/benchdog/rails/active_record_store.rb +49 -0
- data/lib/benchdog/rails/configuration.rb +41 -0
- data/lib/benchdog/rails/controller.rb +37 -0
- data/lib/benchdog/rails/engine.rb +32 -0
- data/lib/benchdog/rails/helper.rb +20 -0
- data/lib/benchdog/rails/records.rb +16 -0
- data/lib/benchdog/rails.rb +13 -0
- data/lib/benchdog-rails.rb +3 -0
- data/lib/generators/benchdog/install/install_generator.rb +21 -0
- data/lib/generators/benchdog/install/templates/create_benchdog_tables.rb.tt +19 -0
- data/sig/benchdog-rails.rbs +61 -0
- metadata +122 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" role="img" aria-labelledby="t">
|
|
2
|
+
<title id="t">Benchdog</title>
|
|
3
|
+
<style>
|
|
4
|
+
.a { stop-color: #22c55e; }
|
|
5
|
+
.b { stop-color: #14532d; }
|
|
6
|
+
.d { color: #052e16; }
|
|
7
|
+
@media (prefers-color-scheme: dark) {
|
|
8
|
+
.a { stop-color: #4ade80; }
|
|
9
|
+
.b { stop-color: #15803d; }
|
|
10
|
+
.d { color: #07391c; }
|
|
11
|
+
}
|
|
12
|
+
</style>
|
|
13
|
+
<defs>
|
|
14
|
+
<linearGradient id="g" x1="0" y1="0" x2="1" y2="1">
|
|
15
|
+
<stop class="a" offset="0"/>
|
|
16
|
+
<stop class="b" offset="1"/>
|
|
17
|
+
</linearGradient>
|
|
18
|
+
<radialGradient id="h" cx="16" cy="4" r="54" gradientUnits="userSpaceOnUse">
|
|
19
|
+
<stop offset="0" stop-color="#fff" stop-opacity="0.26"/>
|
|
20
|
+
<stop offset="1" stop-color="#fff" stop-opacity="0"/>
|
|
21
|
+
</radialGradient>
|
|
22
|
+
<linearGradient id="r" x1="0" y1="0" x2="0" y2="1">
|
|
23
|
+
<stop offset="0" stop-color="#fff" stop-opacity="0.65"/>
|
|
24
|
+
<stop offset="0.4" stop-color="#fff" stop-opacity="0"/>
|
|
25
|
+
<stop offset="0.6" stop-color="#000" stop-opacity="0"/>
|
|
26
|
+
<stop offset="1" stop-color="#000" stop-opacity="0.34"/>
|
|
27
|
+
</linearGradient>
|
|
28
|
+
<linearGradient id="f" x1="0" y1="12" x2="0" y2="52" gradientUnits="userSpaceOnUse">
|
|
29
|
+
<stop offset="0" stop-color="#fff"/>
|
|
30
|
+
<stop offset="1" stop-color="#dcfce7"/>
|
|
31
|
+
</linearGradient>
|
|
32
|
+
<linearGradient id="o" x1="0" y1="12" x2="0" y2="52" gradientUnits="userSpaceOnUse">
|
|
33
|
+
<stop offset="0" stop-color="#fde68a"/>
|
|
34
|
+
<stop offset="1" stop-color="#f59e0b"/>
|
|
35
|
+
</linearGradient>
|
|
36
|
+
<filter id="s" x="-20%" y="-20%" width="140%" height="150%">
|
|
37
|
+
<feDropShadow dx="0" dy="1.8" stdDeviation="1.5" flood-color="#000" flood-opacity="0.3"/>
|
|
38
|
+
</filter>
|
|
39
|
+
</defs>
|
|
40
|
+
<rect width="64" height="64" rx="14" fill="url(#g)"/>
|
|
41
|
+
<rect width="64" height="64" rx="14" fill="url(#h)"/>
|
|
42
|
+
<rect x="0.75" y="0.75" width="62.5" height="62.5" rx="13.25" fill="none" stroke="url(#r)" stroke-width="1.5"/>
|
|
43
|
+
<g transform="translate(32 32) scale(1.12) translate(-32 -32) translate(-1.5 -1.75)">
|
|
44
|
+
<g filter="url(#s)">
|
|
45
|
+
<g class="d" opacity="0.88"><g id="e0" transform="translate(0.21 0.25)">
|
|
46
|
+
<rect x="16" y="22" width="5.5" height="23.5" rx="1.3" fill="currentColor"/>
|
|
47
|
+
<rect x="42.5" y="22" width="5.5" height="23.5" rx="1.3" fill="currentColor"/></g><use href="#e0" transform="translate(0.43 0.5)"/><use href="#e0" transform="translate(0.64 0.75)"/><use href="#e0" transform="translate(0.86 1)"/><use href="#e0" transform="translate(1.07 1.25)"/><use href="#e0" transform="translate(1.29 1.5)"/><use href="#e0" transform="translate(1.5 1.75)"/><use href="#e0" transform="translate(1.71 2)"/><use href="#e0" transform="translate(1.93 2.25)"/><use href="#e0" transform="translate(2.14 2.5)"/><use href="#e0" transform="translate(2.36 2.75)"/><use href="#e0" transform="translate(2.57 3)"/><use href="#e0" transform="translate(2.79 3.25)"/><use href="#e0" transform="translate(3 3.5)"/><g id="e1" transform="translate(0.21 0.25)">
|
|
48
|
+
<path d="M12 32h3v13.5h-3a2.5 2.5 0 0 1-2.5-2.5v-8.5a2.5 2.5 0 0 1 2.5-2.5ZM22.5 32h19v13.5h-19ZM49 32h3a2.5 2.5 0 0 1 2.5 2.5v8.5a2.5 2.5 0 0 1-2.5 2.5h-3Z" fill="currentColor"/>
|
|
49
|
+
<rect x="22.5" y="24.5" width="19" height="6.5" rx="1.5" fill="currentColor"/></g><use href="#e1" transform="translate(0.43 0.5)"/><use href="#e1" transform="translate(0.64 0.75)"/><use href="#e1" transform="translate(0.86 1)"/><use href="#e1" transform="translate(1.07 1.25)"/><use href="#e1" transform="translate(1.29 1.5)"/><use href="#e1" transform="translate(1.5 1.75)"/><use href="#e1" transform="translate(1.71 2)"/><use href="#e1" transform="translate(1.93 2.25)"/><use href="#e1" transform="translate(2.14 2.5)"/><use href="#e1" transform="translate(2.36 2.75)"/><use href="#e1" transform="translate(2.57 3)"/><use href="#e1" transform="translate(2.79 3.25)"/><use href="#e1" transform="translate(3 3.5)"/></g>
|
|
50
|
+
<rect x="16" y="22" width="5.5" height="23.5" rx="1.3" fill="url(#o)"/>
|
|
51
|
+
<rect x="42.5" y="22" width="5.5" height="23.5" rx="1.3" fill="url(#o)"/>
|
|
52
|
+
<path d="M12 32h3v13.5h-3a2.5 2.5 0 0 1-2.5-2.5v-8.5a2.5 2.5 0 0 1 2.5-2.5ZM22.5 32h19v13.5h-19ZM49 32h3a2.5 2.5 0 0 1 2.5 2.5v8.5a2.5 2.5 0 0 1-2.5 2.5h-3Z" fill="url(#f)"/>
|
|
53
|
+
<rect x="22.5" y="24.5" width="19" height="6.5" rx="1.5" fill="url(#f)"/>
|
|
54
|
+
</g>
|
|
55
|
+
|
|
56
|
+
</g>
|
|
57
|
+
</svg>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<!DOCTYPE html><html lang="en"><head>
|
|
2
|
+
<meta charset="utf-8">
|
|
3
|
+
<title>Benchdog</title>
|
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
5
|
+
<!-- A host can set the API path here. Default: "api/", next to this page. -->
|
|
6
|
+
<meta name="benchdog-api" content="">
|
|
7
|
+
<link rel="icon" href="./favicon.svg" type="image/svg+xml">
|
|
8
|
+
|
|
9
|
+
<meta name="benchdog-dashboard/config/environment" content="%7B%22modulePrefix%22%3A%22benchdog-dashboard%22%2C%22environment%22%3A%22production%22%2C%22rootURL%22%3A%22%2F%22%2C%22locationType%22%3A%22hash%22%2C%22EmberENV%22%3A%7B%22EXTEND_PROTOTYPES%22%3Afalse%2C%22FEATURES%22%3A%7B%7D%2C%22_APPLICATION_TEMPLATE_WRAPPER%22%3Afalse%2C%22_DEFAULT_ASYNC_OBSERVERS%22%3Atrue%2C%22_JQUERY_INTEGRATION%22%3Afalse%2C%22_NO_IMPLICIT_ROUTE_MODEL%22%3Atrue%2C%22_TEMPLATE_ONLY_GLIMMER_COMPONENTS%22%3Atrue%7D%2C%22APP%22%3A%7B%7D%7D">
|
|
10
|
+
|
|
11
|
+
<link integrity="" rel="stylesheet" href="./assets/embroider-virtual-app-3rXH0eIh.css">
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
<script type="module" crossorigin="" src="./assets/main-Dg-YB7-H.js"></script>
|
|
15
|
+
<link rel="stylesheet" crossorigin="" href="./assets/main-DA4FE5ZT.css">
|
|
16
|
+
</head>
|
|
17
|
+
<body>
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
<script src="./assets/embroider-virtual-vendor-3fUXwkzh.js"></script>
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
</body></html>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
module Benchdog
|
|
6
|
+
module Rails
|
|
7
|
+
# A Benchdog store in two ActiveRecord tables. `rails generate benchdog:install` writes the
|
|
8
|
+
# migration. A write locks the environment row, so the audit chain has no gap.
|
|
9
|
+
class ActiveRecordStore
|
|
10
|
+
def capabilities = CAPABILITIES
|
|
11
|
+
|
|
12
|
+
def load(environment)
|
|
13
|
+
text = environments.where(name: environment).pick(:flag_set)
|
|
14
|
+
text ? JSON.parse(text) : Store.empty_set(environment)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def version(environment) = environments.where(name: environment).pick(:version).to_i.to_s
|
|
18
|
+
|
|
19
|
+
def write(environment, change, audit)
|
|
20
|
+
environments.create_or_find_by!(name: environment) do |row|
|
|
21
|
+
row.flag_set = JSON.generate(Store.empty_set(environment))
|
|
22
|
+
row.version = 0
|
|
23
|
+
end
|
|
24
|
+
environments.transaction { write_locked(environment, change, audit) }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def audit_log(environment)
|
|
28
|
+
audits.where(environment: environment).order(:seq).pluck(:entry).map { |text| JSON.parse(text) }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
# Loads ActiveRecord::Base at the first use. The records load with it (see benchdog/rails.rb).
|
|
34
|
+
def environments = ::ActiveRecord::Base.then { EnvironmentRecord }
|
|
35
|
+
|
|
36
|
+
def audits = ::ActiveRecord::Base.then { AuditRecord }
|
|
37
|
+
|
|
38
|
+
def write_locked(environment, change, audit)
|
|
39
|
+
row = environments.lock.find_by!(name: environment)
|
|
40
|
+
set = JSON.parse(row.flag_set)
|
|
41
|
+
last = audits.where(environment: environment).order(seq: :desc).pick(:entry)
|
|
42
|
+
entry = Store.next_audit_entry(environment, last && JSON.parse(last), set, change, audit)
|
|
43
|
+
row.update!(flag_set: JSON.generate(Store.apply_change(set, change)), version: row.version + 1)
|
|
44
|
+
audits.create!(environment: environment, seq: entry["seq"], entry: JSON.generate(entry))
|
|
45
|
+
entry
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Benchdog
|
|
4
|
+
# Benchdog for Rails. Configure it in an initializer:
|
|
5
|
+
#
|
|
6
|
+
# Benchdog::Rails.configure do |config|
|
|
7
|
+
# config.store = Benchdog::Rails::ActiveRecordStore.new
|
|
8
|
+
# config.environments = [{ name: "staging", promotes_to: "production" }, { name: "production" }]
|
|
9
|
+
# config.authenticate = ->(env) { ... }
|
|
10
|
+
# config.role_for = ->(user, environment) { "admin" }
|
|
11
|
+
# end
|
|
12
|
+
module Rails
|
|
13
|
+
# The options of Benchdog::AdminApi, and:
|
|
14
|
+
# - environment: the environment of the client in this app. Default: Rails.env.
|
|
15
|
+
# - dashboard_dir: the built dashboard (the dist/ directory of @benchdog-ts/dashboard).
|
|
16
|
+
class Configuration
|
|
17
|
+
API_OPTIONS = %i[store environments authenticate role_for actor_for cron_secret references groups audience].freeze
|
|
18
|
+
|
|
19
|
+
attr_accessor(*API_OPTIONS, :environment, :dashboard_dir)
|
|
20
|
+
|
|
21
|
+
def api_options = API_OPTIONS.to_h { |name| [name, public_send(name)] }.compact
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class << self
|
|
25
|
+
attr_reader :admin_api
|
|
26
|
+
|
|
27
|
+
def config = @config ||= Configuration.new
|
|
28
|
+
|
|
29
|
+
def configure
|
|
30
|
+
yield config
|
|
31
|
+
@admin_api = Benchdog::AdminApi.new(**config.api_options)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# A new client with a snapshot of the app's environment.
|
|
35
|
+
def client
|
|
36
|
+
Benchdog::Client.new(store: config.store, environment: config.environment || ::Rails.env.to_s,
|
|
37
|
+
groups: config.groups.to_h)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "active_support/concern"
|
|
4
|
+
|
|
5
|
+
module Benchdog
|
|
6
|
+
module Rails
|
|
7
|
+
# A controller concern. Each request gets one snapshot of the flags, on first use:
|
|
8
|
+
#
|
|
9
|
+
# class ApplicationController < ActionController::Base
|
|
10
|
+
# include Benchdog::Rails::Controller
|
|
11
|
+
# end
|
|
12
|
+
#
|
|
13
|
+
# benchdog_enabled?("new-checkout") # In a controller or a view.
|
|
14
|
+
module Controller
|
|
15
|
+
extend ActiveSupport::Concern
|
|
16
|
+
|
|
17
|
+
included do
|
|
18
|
+
helper Helper
|
|
19
|
+
helper_method :benchdog, :benchdog_actor, :benchdog_enabled?, :benchdog_value
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def benchdog = @benchdog ||= Benchdog::Rails.client
|
|
25
|
+
|
|
26
|
+
# The actor of the request: "user:<id>" of `current_user`, or nil. Override it for another actor.
|
|
27
|
+
def benchdog_actor
|
|
28
|
+
user = respond_to?(:current_user, true) ? send(:current_user) : nil
|
|
29
|
+
user && { "id" => "user:#{user.id}" }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def benchdog_enabled?(key) = benchdog.enabled?(key, benchdog_actor)
|
|
33
|
+
|
|
34
|
+
def benchdog_value(key, default) = benchdog.value(key, benchdog_actor, default)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rails/engine"
|
|
4
|
+
require "rack/files"
|
|
5
|
+
|
|
6
|
+
module Benchdog
|
|
7
|
+
module Rails
|
|
8
|
+
# Serves the built dashboard from `config.dashboard_dir`, or else from the copy in the gem.
|
|
9
|
+
class Dashboard
|
|
10
|
+
# `scripts/bundle-dashboard.sh` copies the dashboard build here before `gem build`.
|
|
11
|
+
BUNDLED = File.expand_path("../../../dashboard", __dir__)
|
|
12
|
+
|
|
13
|
+
def call(env)
|
|
14
|
+
dir = Benchdog::Rails.config.dashboard_dir || (BUNDLED if Dir.exist?(BUNDLED))
|
|
15
|
+
return [404, { "content-type" => "text/plain" }, ["Set Benchdog::Rails.config.dashboard_dir"]] unless dir
|
|
16
|
+
|
|
17
|
+
# The dashboard calls "api/" next to its page, so the mount path needs its slash.
|
|
18
|
+
path = env["ORIGINAL_FULLPATH"].to_s.split("?").first.to_s
|
|
19
|
+
root = env["PATH_INFO"].to_s.delete_prefix("/").empty?
|
|
20
|
+
return [301, { "location" => "#{path}/" }, []] if root && !path.end_with?("/")
|
|
21
|
+
|
|
22
|
+
Rack::Files.new(dir.to_s).call(env.merge("PATH_INFO" => root ? "/index.html" : env["PATH_INFO"]))
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Mount it in config/routes.rb: `mount Benchdog::Rails::Engine, at: "/benchdog"`. The
|
|
27
|
+
# dashboard is at /benchdog/, and the admin API is at /benchdog/api.
|
|
28
|
+
class Engine < ::Rails::Engine
|
|
29
|
+
engine_name "benchdog"
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "erb"
|
|
4
|
+
require "json"
|
|
5
|
+
|
|
6
|
+
module Benchdog
|
|
7
|
+
module Rails
|
|
8
|
+
# View helpers. Benchdog::Rails::Controller adds them to the views of its controllers.
|
|
9
|
+
module Helper
|
|
10
|
+
# The client payload of the request's actor, for `readPayload()` of @benchdog-ts/client.
|
|
11
|
+
def benchdog_payload_tag
|
|
12
|
+
actor = benchdog_actor
|
|
13
|
+
payload = Benchdog.client_payload(benchdog.snapshot, actor ? { "actor" => actor } : {},
|
|
14
|
+
groups: Benchdog::Rails.config.groups.to_h)
|
|
15
|
+
json = ERB::Util.json_escape(JSON.generate(payload)).html_safe
|
|
16
|
+
tag.script(json, type: "application/json", id: "benchdog-payload")
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Benchdog
|
|
4
|
+
module Rails
|
|
5
|
+
# One row for each environment: the flag set as JSON text, and a version that each write adds 1 to.
|
|
6
|
+
class EnvironmentRecord < ::ActiveRecord::Base
|
|
7
|
+
self.table_name = "benchdog_environments"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# One row for each audit entry, as JSON text. JSON text keeps each value of the hashed entry
|
|
11
|
+
# the same in each database.
|
|
12
|
+
class AuditRecord < ::ActiveRecord::Base
|
|
13
|
+
self.table_name = "benchdog_audit_entries"
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "benchdog"
|
|
4
|
+
require "active_support"
|
|
5
|
+
require_relative "rails/configuration"
|
|
6
|
+
require_relative "rails/active_record_store"
|
|
7
|
+
require_relative "rails/helper"
|
|
8
|
+
require_relative "rails/controller"
|
|
9
|
+
require_relative "rails/engine"
|
|
10
|
+
|
|
11
|
+
# The records load with ActiveRecord, so the gem does not load ActiveRecord::Base before the app
|
|
12
|
+
# configures it.
|
|
13
|
+
ActiveSupport.on_load(:active_record) { require_relative "rails/records" }
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rails/generators"
|
|
4
|
+
require "rails/generators/active_record"
|
|
5
|
+
|
|
6
|
+
module Benchdog
|
|
7
|
+
module Generators
|
|
8
|
+
# `rails generate benchdog:install` writes the migration for the ActiveRecord store.
|
|
9
|
+
class InstallGenerator < ::Rails::Generators::Base
|
|
10
|
+
include ::Rails::Generators::Migration
|
|
11
|
+
|
|
12
|
+
source_root File.expand_path("templates", __dir__)
|
|
13
|
+
|
|
14
|
+
def self.next_migration_number(dirname) = ::ActiveRecord::Generators::Base.next_migration_number(dirname)
|
|
15
|
+
|
|
16
|
+
def create_migration_file
|
|
17
|
+
migration_template "create_benchdog_tables.rb.tt", "db/migrate/create_benchdog_tables.rb"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# The tables of the Benchdog ActiveRecord store.
|
|
4
|
+
class CreateBenchdogTables < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
|
|
5
|
+
def change
|
|
6
|
+
create_table :benchdog_environments do |t|
|
|
7
|
+
t.string :name, null: false, index: { unique: true }
|
|
8
|
+
t.text :flag_set, null: false
|
|
9
|
+
t.integer :version, null: false, default: 0
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
create_table :benchdog_audit_entries do |t|
|
|
13
|
+
t.string :environment, null: false
|
|
14
|
+
t.integer :seq, null: false
|
|
15
|
+
t.text :entry, null: false
|
|
16
|
+
t.index %i[environment seq], unique: true
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# The part of Rails that the checked files call.
|
|
2
|
+
module Rails
|
|
3
|
+
def self.env: () -> String
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
module ActiveRecord
|
|
7
|
+
class Base
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
module Benchdog
|
|
12
|
+
module Rails
|
|
13
|
+
class Configuration
|
|
14
|
+
API_OPTIONS: Array[Symbol]
|
|
15
|
+
|
|
16
|
+
attr_accessor store: _Store
|
|
17
|
+
attr_accessor environments: Array[Hash[Symbol, untyped]]
|
|
18
|
+
attr_accessor authenticate: ^(rack_env) -> json_hash?
|
|
19
|
+
attr_accessor role_for: ^(json_hash, String) -> String?
|
|
20
|
+
attr_accessor actor_for: (^(rack_env, json_hash?) -> json_hash?)?
|
|
21
|
+
attr_accessor cron_secret: String?
|
|
22
|
+
attr_accessor references: untyped
|
|
23
|
+
attr_accessor groups: Hash[String, ^(json_hash) -> untyped]?
|
|
24
|
+
attr_accessor audience: Hash[Symbol, untyped]?
|
|
25
|
+
attr_accessor environment: String?
|
|
26
|
+
attr_accessor dashboard_dir: String?
|
|
27
|
+
|
|
28
|
+
def api_options: () -> Hash[Symbol, untyped]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
self.@config: Configuration?
|
|
32
|
+
|
|
33
|
+
def self.admin_api: () -> AdminApi
|
|
34
|
+
def self.config: () -> Configuration
|
|
35
|
+
def self.configure: () { (Configuration config) -> void } -> AdminApi
|
|
36
|
+
def self.client: () -> Client
|
|
37
|
+
|
|
38
|
+
# ActiveRecord models. Only the class methods that the store calls are here.
|
|
39
|
+
class EnvironmentRecord
|
|
40
|
+
def self.where: (**untyped) -> untyped
|
|
41
|
+
def self.lock: () -> untyped
|
|
42
|
+
def self.create_or_find_by!: (**untyped) { (untyped row) -> void } -> untyped
|
|
43
|
+
def self.transaction: [T] () { () -> T } -> T
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
class AuditRecord
|
|
47
|
+
def self.where: (**untyped) -> untyped
|
|
48
|
+
def self.create!: (**untyped) -> untyped
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
class ActiveRecordStore
|
|
52
|
+
include _Store
|
|
53
|
+
|
|
54
|
+
private
|
|
55
|
+
|
|
56
|
+
def environments: () -> singleton(EnvironmentRecord)
|
|
57
|
+
def audits: () -> singleton(AuditRecord)
|
|
58
|
+
def write_locked: (String environment, json_hash change, json_hash audit) -> json_hash
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: benchdog-rails
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Joe Gaudet
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-12-03 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: activerecord
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '7.1'
|
|
20
|
+
- - "<"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '9'
|
|
23
|
+
type: :runtime
|
|
24
|
+
prerelease: false
|
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
+
requirements:
|
|
27
|
+
- - ">="
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '7.1'
|
|
30
|
+
- - "<"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '9'
|
|
33
|
+
- !ruby/object:Gem::Dependency
|
|
34
|
+
name: benchdog
|
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - '='
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: 0.1.0
|
|
40
|
+
type: :runtime
|
|
41
|
+
prerelease: false
|
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - '='
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: 0.1.0
|
|
47
|
+
- !ruby/object:Gem::Dependency
|
|
48
|
+
name: railties
|
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '7.1'
|
|
54
|
+
- - "<"
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: '9'
|
|
57
|
+
type: :runtime
|
|
58
|
+
prerelease: false
|
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
60
|
+
requirements:
|
|
61
|
+
- - ">="
|
|
62
|
+
- !ruby/object:Gem::Version
|
|
63
|
+
version: '7.1'
|
|
64
|
+
- - "<"
|
|
65
|
+
- !ruby/object:Gem::Version
|
|
66
|
+
version: '9'
|
|
67
|
+
description:
|
|
68
|
+
email:
|
|
69
|
+
- joe@joegaudet.com
|
|
70
|
+
executables: []
|
|
71
|
+
extensions: []
|
|
72
|
+
extra_rdoc_files: []
|
|
73
|
+
files:
|
|
74
|
+
- LICENSE
|
|
75
|
+
- README.md
|
|
76
|
+
- config/routes.rb
|
|
77
|
+
- dashboard/assets/embroider-virtual-app-3rXH0eIh.css
|
|
78
|
+
- dashboard/assets/embroider-virtual-vendor-3fUXwkzh.js
|
|
79
|
+
- dashboard/assets/embroider-virtual-vendor-B_SY1GJM.css
|
|
80
|
+
- dashboard/assets/main-DA4FE5ZT.css
|
|
81
|
+
- dashboard/assets/main-Dg-YB7-H.js
|
|
82
|
+
- dashboard/favicon.svg
|
|
83
|
+
- dashboard/index.html
|
|
84
|
+
- lib/benchdog-rails.rb
|
|
85
|
+
- lib/benchdog/rails.rb
|
|
86
|
+
- lib/benchdog/rails/active_record_store.rb
|
|
87
|
+
- lib/benchdog/rails/configuration.rb
|
|
88
|
+
- lib/benchdog/rails/controller.rb
|
|
89
|
+
- lib/benchdog/rails/engine.rb
|
|
90
|
+
- lib/benchdog/rails/helper.rb
|
|
91
|
+
- lib/benchdog/rails/records.rb
|
|
92
|
+
- lib/generators/benchdog/install/install_generator.rb
|
|
93
|
+
- lib/generators/benchdog/install/templates/create_benchdog_tables.rb.tt
|
|
94
|
+
- sig/benchdog-rails.rbs
|
|
95
|
+
homepage: https://joegaudet.com/benchdog/
|
|
96
|
+
licenses:
|
|
97
|
+
- MIT
|
|
98
|
+
metadata:
|
|
99
|
+
source_code_uri: https://github.com/joegaudet/benchdog/tree/main/ruby/benchdog-rails
|
|
100
|
+
bug_tracker_uri: https://github.com/joegaudet/benchdog/issues
|
|
101
|
+
rubygems_mfa_required: 'true'
|
|
102
|
+
post_install_message:
|
|
103
|
+
rdoc_options: []
|
|
104
|
+
require_paths:
|
|
105
|
+
- lib
|
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '3.3'
|
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
|
+
requirements:
|
|
113
|
+
- - ">="
|
|
114
|
+
- !ruby/object:Gem::Version
|
|
115
|
+
version: '0'
|
|
116
|
+
requirements: []
|
|
117
|
+
rubygems_version: 3.5.11
|
|
118
|
+
signing_key:
|
|
119
|
+
specification_version: 4
|
|
120
|
+
summary: 'Benchdog for Rails: an ActiveRecord store, the dashboard engine, a helper
|
|
121
|
+
and a concern.'
|
|
122
|
+
test_files: []
|