pferd 0.1.0 → 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.
- checksums.yaml +4 -4
- data/.gitignore +2 -4
- data/Rakefile +1 -5
- data/lib/pferd/railtie.rb +7 -0
- data/lib/pferd/version.rb +1 -1
- data/lib/pferd.rb +1 -2
- data/lib/tasks/pferd.rake +13 -10
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa8111ec9ec95a8333b1bb1db7409bcefca1efc4b721a01488fd0f4280606d51
|
4
|
+
data.tar.gz: 2898b606d774ea819a98ab6179dd44a3db6723e5ebf5045fbf70893e55420f1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd74590af095a4500399dfc6b074ec26b22acef324d3f4483c072aaa89a9309bba7c6db92edfd023f2b6efda7f6cb0d649338fd02be7d7e6d76c347bb04241b5
|
7
|
+
data.tar.gz: 758b3797551b33aeaee2556e93c4c167b801f4b5ebba784bc3ddbc093c2e7c368162d5ff11db9580c041418694ca8eed38632d846580dcc87bb44ae871c7d4bf
|
data/.gitignore
CHANGED
data/Rakefile
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "bundler/gem_tasks"
|
4
|
-
require "rspec/core/rake_task"
|
5
|
-
|
6
|
-
RSpec::Core::RakeTask.new(:spec)
|
7
|
-
|
8
4
|
require "rubocop/rake_task"
|
9
5
|
|
10
6
|
RuboCop::RakeTask.new
|
11
7
|
|
12
|
-
task default: %i[
|
8
|
+
task default: %i[rubocop]
|
data/lib/pferd/version.rb
CHANGED
data/lib/pferd.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative "pferd/version"
|
4
4
|
require_relative "pferd/entity"
|
5
|
+
require_relative "pferd/railtie" if defined?(Rails)
|
5
6
|
require "ostruct"
|
6
7
|
module Pferd
|
7
8
|
class Error < StandardError; end
|
@@ -33,5 +34,3 @@ module Pferd
|
|
33
34
|
config.highlight_boundary_violations = true
|
34
35
|
end
|
35
36
|
end
|
36
|
-
# Load this last so that the Rake file has access to the above config.
|
37
|
-
load "pferd/lib/tasks/pferd.rake"
|
data/lib/tasks/pferd.rake
CHANGED
@@ -9,22 +9,22 @@ namespace :pferd do
|
|
9
9
|
# Load the models specified in config and generate their Docs
|
10
10
|
# (this is required to get the domain tag from the doc metadata)
|
11
11
|
YARD::Rake::YardocTask.new do |t|
|
12
|
-
t.files = Pferd.configuration.model_dirs.map { |dir|
|
13
|
-
t.options = ["--tag", 'domain:"App domain"']
|
12
|
+
t.files = Pferd.configuration.model_dirs.map { |dir| Rails.root.join(dir, "**", "*.rb").to_s }
|
13
|
+
t.options = ["--tag", 'domain:"App domain"', '--output-dir', './tmp/pferd-yard']
|
14
14
|
end
|
15
15
|
|
16
16
|
desc "Generate an ERD that shows models grouped by domain"
|
17
17
|
task draw_relationships: %i[environment pferd:yard] do
|
18
18
|
# Load the Yard registry
|
19
19
|
YARD::Registry.load!
|
20
|
-
MODEL_DOMAINS =
|
21
|
-
|
20
|
+
MODEL_DOMAINS = {}
|
21
|
+
default_tag = Struct.new(:text).new(Pferd.configuration.default_domain_name)
|
22
22
|
# Populate MODEL_DOMAINS with model names and their domains
|
23
|
-
YARD::Registry.all(:class).
|
24
|
-
|
25
|
-
|
23
|
+
YARD::Registry.all(:class).each do |klass_info|
|
24
|
+
class_name = [klass_info.namespace, klass_info.name].join("::") if klass_info.namespace.present?
|
25
|
+
domain_tag = klass_info.tags.find { |tag| tag.tag_name == "domain" } || default_tag
|
26
|
+
MODEL_DOMAINS[class_name] = domain_tag.text
|
26
27
|
end
|
27
|
-
|
28
28
|
# Load all models
|
29
29
|
Rails.application.eager_load!
|
30
30
|
|
@@ -32,8 +32,10 @@ namespace :pferd do
|
|
32
32
|
next unless MODEL_DOMAINS.key?(model.name)
|
33
33
|
|
34
34
|
entity = Pferd::Entity.new(model.name, Set.new, MODEL_DOMAINS[model.name])
|
35
|
-
associations = (
|
36
|
-
model.reflect_on_all_associations(:
|
35
|
+
associations = (
|
36
|
+
model.reflect_on_all_associations(:has_many) |
|
37
|
+
model.reflect_on_all_associations(:has_one) | model.reflect_on_all_associations(:has_and_belongs_to_many)
|
38
|
+
)
|
37
39
|
associations.each do |assoc|
|
38
40
|
next if Pferd.configuration.ignored_classes.include?(assoc.klass.name)
|
39
41
|
next if Pferd.configuration.ignored_modules.any? do |module_name|
|
@@ -74,6 +76,7 @@ namespace :pferd do
|
|
74
76
|
|
75
77
|
# Generate output as PNG file
|
76
78
|
g.output(png: Pferd.configuration.output_file_name)
|
79
|
+
puts "Done #{Pferd.configuration.output_file_name}"
|
77
80
|
end
|
78
81
|
task default: :draw_relationships
|
79
82
|
end
|
metadata
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pferd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bodacious
|
8
|
+
autorequire:
|
8
9
|
bindir: bin
|
9
10
|
cert_chain: []
|
10
11
|
date: 2025-02-03 00:00:00.000000000 Z
|
@@ -55,6 +56,7 @@ files:
|
|
55
56
|
- lib/pferd.rb
|
56
57
|
- lib/pferd/entity.rb
|
57
58
|
- lib/pferd/entity_relationship.rb
|
59
|
+
- lib/pferd/railtie.rb
|
58
60
|
- lib/pferd/version.rb
|
59
61
|
- lib/tasks/pferd.rake
|
60
62
|
- sig/pferd.rbs
|
@@ -65,6 +67,7 @@ metadata:
|
|
65
67
|
homepage_uri: https://github.com/bodacious/pferd
|
66
68
|
source_code_uri: https://github.com/bodacious/pferd
|
67
69
|
changelog_uri: https://github.com/bodacious/pferd
|
70
|
+
post_install_message:
|
68
71
|
rdoc_options: []
|
69
72
|
require_paths:
|
70
73
|
- lib
|
@@ -79,7 +82,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
82
|
- !ruby/object:Gem::Version
|
80
83
|
version: '0'
|
81
84
|
requirements: []
|
82
|
-
rubygems_version: 3.
|
85
|
+
rubygems_version: 3.5.23
|
86
|
+
signing_key:
|
83
87
|
specification_version: 4
|
84
88
|
summary: Generate domain-based ERDs for Rails
|
85
89
|
test_files: []
|