activerecord_uml 0.5.0 → 0.10.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: 75bc29669bc6893589083ea59d6dcb6699a53165b3258a008ed69fce1f907c7d
4
- data.tar.gz: 8fa743ad797eef029abd1d347654f51589c9b575bced44735ea62752e7b906cc
3
+ metadata.gz: 2abcbc6eff7c040819407f366d069092e03eab839f769360030637af73535b25
4
+ data.tar.gz: 7ea892c78d8297850f57a7b976af9c71a2a1b2a893a9bbce6effae986e58f187
5
5
  SHA512:
6
- metadata.gz: c026ab1b8b5de2630e49ec544c73693d157cee869c0b8995109e877611a6522d5f48f703dd5d0eb08fb74cf094454a887ba2511353d67837894fa3edf8bed62c
7
- data.tar.gz: 6c08b058547c1f8010fefb5048653ff462d47618689b722b23db679e3b1cc375525a1323d77f0ee06936f84e214c55d8f887bae19d15a31a3bd4fd9c6823dfaf
6
+ metadata.gz: b77c58d014dd66aff2699ef266a8e89ce5eb5c0c9d92e02231b5204fd893523abb5ea5d34b6165667685549959b6d54d7970a321d7aecde9b0f981dc2045b17f
7
+ data.tar.gz: ae244cdaa9b8c32b1c5a9f0dd18264d0c2f4609bc20d7f6720b61062019fb96203f58cecaac4cd2a12e7a085ffb2047e746fefbcc0cb1d3fed2f1189ae998d9c
data/README.md CHANGED
@@ -29,7 +29,7 @@ Or install it yourself as:
29
29
  In your Ruby on Rails directory:
30
30
 
31
31
  ```
32
- activerecord_uml User
32
+ activerecord_uml User Book Review
33
33
  ```
34
34
 
35
35
  Execute the activerecord_uml command with name of model classes.
data/exe/activerecord_uml CHANGED
@@ -1,7 +1,8 @@
1
1
  #! /usr/bin/env ruby
2
- require "activerecord_uml"
3
2
 
4
- require(File.join(Dir.pwd, "config/application"))
5
- Rails.application.require_environment!
3
+ activerecord_uml = File.join __dir__,"../lib/activerecord_uml"
4
+ ruby_script = "require \"#{activerecord_uml}\"; ActiverecordUml.draw"
5
+ rails = File.join Dir.pwd,"bin/rails"
6
+ rails_runner_command = "echo '#{ruby_script}' | #{rails} runner - #{ARGV.join ' '}"
6
7
 
7
- ActiverecordUml.draw
8
+ system rails_runner_command
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ require "erb"
2
3
  require_relative "activerecord_uml/version"
3
4
  require_relative "activerecord_uml/diagram_drawer"
4
5
 
@@ -28,11 +28,11 @@ EOF
28
28
 
29
29
  def relations
30
30
  @class_name.reflect_on_all_associations(:belongs_to).map do |a|
31
- "#{a.name.to_s.classify} --* #{@class_name}"
31
+ "#{a.class_name} --* #{@class_name}#{label_for a}"
32
32
  end.concat(@class_name.reflect_on_all_associations(:has_many).map do |a|
33
- "#{@class_name} --* #{a.name.to_s.classify}"
33
+ "#{@class_name} --* #{a.class_name}#{label_for a}"
34
34
  end).concat(@class_name.reflect_on_all_associations(:has_one).map do |a|
35
- "#{@class_name} --* #{a.name.to_s.classify}"
35
+ "#{@class_name} --* #{a.class_name}#{label_for a}"
36
36
  end)
37
37
  end
38
38
 
@@ -47,9 +47,18 @@ EOF
47
47
  method_parameters = @class_name.new.method(m)
48
48
  .parameters
49
49
  .filter { |a| a[0] == :req }
50
- .map { |a| a[1] }.join(", ")
51
- [m.to_s, method_parameters]
50
+ .map { |a| a[1] }
51
+
52
+ if method_parameters.length > 3
53
+ method_parameters = method_parameters.slice(0, 3).append("...")
54
+ end
55
+
56
+ [m.to_s, method_parameters.join(", ")]
52
57
  end
53
58
  end
59
+
60
+ def label_for(association)
61
+ association.class_name != association.name.to_s.classify ? " : #{association.name.to_s.classify}" : ''
62
+ end
54
63
  end
55
64
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiverecordUml
4
- VERSION = "0.5.0"
4
+ VERSION = "0.10.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord_uml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - shigeru.nakajima
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-15 00:00:00.000000000 Z
11
+ date: 2021-06-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Generate UML class diagram for Mermaid.js from ActiveRecord instances
14
14
  by Rails runner.