pferd 0.1.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 946aa6214de4a342e5cc66719ccdb5398f7c8509e9c0e99ec21e3147cb85f3ac
4
- data.tar.gz: d103e4581b083098c399269d1ec2908688b2d3fc7ee72a2c3fb190e98ea4e5d3
3
+ metadata.gz: fa8111ec9ec95a8333b1bb1db7409bcefca1efc4b721a01488fd0f4280606d51
4
+ data.tar.gz: 2898b606d774ea819a98ab6179dd44a3db6723e5ebf5045fbf70893e55420f1a
5
5
  SHA512:
6
- metadata.gz: 4882c377f6c9f994595a37406c9782645bec1aed8861b86b38e55252ad269040a2e7830ceedbb75f7d97b27c2e7bcbb916950df80e447bc2d3a31a601fd90404
7
- data.tar.gz: b28cf170d718fd803556c8a455a0fb725a60a5357d28bddc907cefc353706d5149ad7fb174e272a4607bdab319f6d6cda6e51a27d2143d15583c0fe5c059c61a
6
+ metadata.gz: fd74590af095a4500399dfc6b074ec26b22acef324d3f4483c072aaa89a9309bba7c6db92edfd023f2b6efda7f6cb0d649338fd02be7d7e6d76c347bb04241b5
7
+ data.tar.gz: 758b3797551b33aeaee2556e93c4c167b801f4b5ebba784bc3ddbc093c2e7c368162d5ff11db9580c041418694ca8eed38632d846580dcc87bb44ae871c7d4bf
@@ -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.1"
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
23
  YARD::Registry.all(:class).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
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
 
@@ -76,6 +76,7 @@ namespace :pferd do
76
76
 
77
77
  # Generate output as PNG file
78
78
  g.output(png: Pferd.configuration.output_file_name)
79
+ puts "Done #{Pferd.configuration.output_file_name}"
79
80
  end
80
81
  task default: :draw_relationships
81
82
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pferd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bodacious
@@ -56,6 +56,7 @@ files:
56
56
  - lib/pferd.rb
57
57
  - lib/pferd/entity.rb
58
58
  - lib/pferd/entity_relationship.rb
59
+ - lib/pferd/railtie.rb
59
60
  - lib/pferd/version.rb
60
61
  - lib/tasks/pferd.rake
61
62
  - sig/pferd.rbs
@@ -81,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
82
  - !ruby/object:Gem::Version
82
83
  version: '0'
83
84
  requirements: []
84
- rubygems_version: 3.5.11
85
+ rubygems_version: 3.5.23
85
86
  signing_key:
86
87
  specification_version: 4
87
88
  summary: Generate domain-based ERDs for Rails