pferd 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4cfbec7f22022f6fde8257a419ae16a322a33b1a5a3b808066615c9e5a36c49a
4
- data.tar.gz: 725ae61787aa419a0e97f5fa3b82e285cf116b440884f94fbcd72300c70a3d01
3
+ metadata.gz: fa8111ec9ec95a8333b1bb1db7409bcefca1efc4b721a01488fd0f4280606d51
4
+ data.tar.gz: 2898b606d774ea819a98ab6179dd44a3db6723e5ebf5045fbf70893e55420f1a
5
5
  SHA512:
6
- metadata.gz: 0b39ddbc987ef910722df3b0514b3a66a1402c0e9cba2cd516a74ad4992b55cdcfe9a89868fa1a42b5453cc3fed97aaf408e547554ddfc546fd2ee1f87482094
7
- data.tar.gz: 945a120e05fa4107328ea6bdc1d5629b6e975d3a1fe387b190535ca7e8794e9e1c7d00ffbcf28b05641bf4311df49131896c324060d40be952decd76c74d1a54
6
+ metadata.gz: fd74590af095a4500399dfc6b074ec26b22acef324d3f4483c072aaa89a9309bba7c6db92edfd023f2b6efda7f6cb0d649338fd02be7d7e6d76c347bb04241b5
7
+ data.tar.gz: 758b3797551b33aeaee2556e93c4c167b801f4b5ebba784bc3ddbc093c2e7c368162d5ff11db9580c041418694ca8eed38632d846580dcc87bb44ae871c7d4bf
data/.gitignore CHANGED
@@ -4,8 +4,6 @@
4
4
  /coverage/
5
5
  /doc/
6
6
  /pkg/
7
- /spec/reports/
8
7
  /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
8
+ pferd-*.gem
9
+ .idea
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[spec rubocop]
8
+ task default: %i[rubocop]
@@ -0,0 +1,7 @@
1
+ module Pferd
2
+ class Railtie < Rails::Railtie
3
+ rake_tasks do
4
+ load "tasks/pferd.rake"
5
+ end
6
+ end
7
+ end
data/lib/pferd/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pferd
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
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| File.join(dir, "**", "*.rb") }
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 = Hash.new(Pferd.configuration.default_domain_name)
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).find_each do |klass_info|
24
- domain_tag = klass_info.tags.find { |tag| tag.tag_name == "domain" }
25
- MODEL_DOMAINS[klass_info.name.to_s] = domain_tag.text if domain_tag
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 = (model.reflect_on_all_associations(:has_many) |
36
- model.reflect_on_all_associations(:has_one))
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.1.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.6.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: []