runger_rails_model_explorer 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 13594a1f1badfb4c8a76809112550bd6fc1d6c9af400836f43dc0478a14723d6
4
+ data.tar.gz: 8c5f4913877b98d698a8543275eb085b65fee34b68f7e5ca8128e0b2d664ceab
5
+ SHA512:
6
+ metadata.gz: 57f2707038031e6834cfb0b3f0f17196a5c8681c5530ade1b0e5a06aac0ccac01f72742fbabced9813f529a93dcdb87959506cb5de54cc2882f9a65168d71791
7
+ data.tar.gz: eb863c9993b29b9250f24760b0956a1f2cd7ddce234b47c20a376325f7e6f967c302ae5ae863b5453a89f0df8f7808d0434b7c4b745819081c8bc4fbfa8d2e77
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) David Runger
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # RungerRailsModelExplorer
2
+
3
+ Explore your Rails models.
4
+
5
+ ## Installation
6
+
7
+ Add to your `Gemfile`:
8
+
9
+ ```ruby
10
+ gem 'runger_rails_model_explorer'
11
+ ```
12
+
13
+ and then run `bundle install`.
14
+
15
+ ## Usage
16
+
17
+ Add a Rails controller to your application that looks something like this:
18
+
19
+ ```rb
20
+ # app/controllers/model_graph_controller.rb
21
+ class ModelGraphController < ApplicationController
22
+ def index
23
+ bootstrap(model_metadata: RungerRailsModelExplorer.model_metadata)
24
+ end
25
+ end
26
+ ```
27
+
28
+ Add a view that looks something like this:
29
+
30
+ ```haml
31
+ -# app/views/model_graph/index.html.haml
32
+ - content_for(:page_assets) do
33
+ = ts_tag('model_graph')
34
+ ```
35
+
36
+ Add a route that looks something like this:
37
+
38
+ ```rb
39
+ # config/routes.rb
40
+ get 'models', to: 'model_graph#index'
41
+ ```
42
+
43
+ **NOTE:** If this is a private app, then you will probably want to secure that route somehow, e.g. within a Devise `authenticate :admin_user do ... end` block.
44
+
45
+ Then, follow setup instructions for [the `@davidrunger/vue-model-explorer` NPM package][npm-package-setup-instructions].
46
+
47
+ [npm-package-setup-instructions]: https://github.com/davidrunger/vue_rails_model_explorer/blob/main/vue-model-explorer/README.md
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RungerRailsModelExplorer
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'runger_rails_model_explorer/version'
4
+
5
+ module RungerRailsModelExplorer
6
+ class << self
7
+ def model_metadata
8
+ Rails.application.eager_load!
9
+
10
+ models =
11
+ ActiveRecord::Base.descendants.select do |model_class|
12
+ !model_class.abstract_class? && model_class.table_exists?
13
+ end
14
+
15
+ models.map do |model|
16
+ {
17
+ model_name: model.name,
18
+ table_name: model.table_name,
19
+ columns: model.columns.map do |column|
20
+ {
21
+ name: column.name,
22
+ type: column.type,
23
+ null: column.null,
24
+ default: column.default,
25
+ }
26
+ end,
27
+ associations: model.reflect_on_all_associations.map do |association|
28
+ {
29
+ name: association.name,
30
+ macro: association.macro,
31
+ class_name: association.class_name,
32
+ options: association.options,
33
+ }
34
+ end,
35
+ }
36
+ end
37
+ end
38
+ end
39
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: runger_rails_model_explorer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - David Runger
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 2025-03-19 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: activerecord
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 8.0.2
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: 8.0.2
26
+ email:
27
+ - davidjrunger@gmail.com
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - LICENSE.txt
33
+ - README.md
34
+ - lib/runger_rails_model_explorer.rb
35
+ - lib/runger_rails_model_explorer/version.rb
36
+ homepage: https://github.com/davidrunger/vue_rails_model_explorer/blob/main/runger_rails_model_explorer/README.md
37
+ licenses:
38
+ - MIT
39
+ metadata:
40
+ homepage_uri: https://github.com/davidrunger/vue_rails_model_explorer/blob/main/runger_rails_model_explorer/README.md
41
+ source_code_uri: https://github.com/davidrunger/vue_rails_model_explorer/blob/main/runger_rails_model_explorer/README.md
42
+ changelog_uri: https://github.com/davidrunger/vue_rails_model_explorer/blob/main/runger_rails_model_explorer/CHANGELOG.md
43
+ rubygems_mfa_required: 'true'
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: 3.4.2
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubygems_version: 3.6.3
59
+ specification_version: 4
60
+ summary: Explore your Rails models
61
+ test_files: []