erd 0.8.0 → 0.8.2

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: 23d4342f2a320f75b2e90d11bf2474d5f1878632369e6c5a9e3608f3c9ac9aee
4
- data.tar.gz: d7b53a5993a0b95508e44be666ec68f620563e4a9ee7bfb7ef708f09beb0ffda
3
+ metadata.gz: 5074a23b558abdeda14f0f4eecf1c38bc1b73a6b3df6be11861e5ad735ad4b8b
4
+ data.tar.gz: d3f59580aae0ff78165bf5367b1e73bf38450c1cebfaf1859c6d9452c245c4e8
5
5
  SHA512:
6
- metadata.gz: 37a889901a16afac747792e929a71a8831ff55b0119cdb5cf96911fb19447a493a717021c7a65c1e7d3274809af67dd64c6a0184f79aebfa09716198186d38f8
7
- data.tar.gz: c87a23f1c22cbff2363b8f54d993be86669330854fd80bd9570df87b3f144434c9ad55aacceacdf08f95b0fe60ff0cf67d4a145ee1918c22c1cba2b7b8b31b15
6
+ metadata.gz: 93a11122d991898c675bc620414ee1645091975215896f1d4ae360acb88ace0b1410a903d8679ef954e766734923dba2b255f7adba7eab91c412ed8576e80356
7
+ data.tar.gz: cd7984df408eb0b7ad2e17a24398eb5e530ec6b73e202fa4a06e19b906924ad62fd1cd1513c502e36659dab522e1fbd5cd837ba712cc58054cc6e56c88ce8232
data/README.md CHANGED
@@ -5,7 +5,7 @@ A Rails engine for drawing your app's ER diagram and operating migrations
5
5
 
6
6
  ## Requirements
7
7
 
8
- * Rails 5.2, 5.1, 5.0, 4.2, 4.1, 4.0, 3.2, or 3.1
8
+ * Rails 7.0, 6.1, 6.0, 5.2, 5.1, 5.0, 4.2, 4.1, 4.0, 3.2, or 3.1
9
9
 
10
10
  * Graphviz
11
11
 
@@ -2,7 +2,6 @@
2
2
 
3
3
  require 'nokogiri'
4
4
  require 'ruby-graphviz'
5
- require 'erd/application_controller'
6
5
 
7
6
  module Erd
8
7
  class ErdController < ::Erd::ApplicationController
@@ -137,9 +136,9 @@ module Erd
137
136
  {:model => model_name, :x => (custom_x || (BigDecimal(x) * 72).round), :y => (custom_y || (BigDecimal(y) * 72).round), :width => (BigDecimal(width) * 72).round, :height => (BigDecimal(height) * 72).round, :columns => columns}
138
137
  }.compact
139
138
  max_model_x = models.map {|m| m[:x].to_f + m[:width].to_f }.max
140
- erd_width = [[(BigDecimal(svg_width) * 72).round, max_model_x].min + 150, 1024].max
139
+ erd_width = [[(BigDecimal(svg_width) * 72).round, max_model_x].compact.min + 150, 1024].max
141
140
  max_model_y = models.map {|m| m[:y].to_f + m[:height].to_f }.max
142
- erd_height = [[(BigDecimal(svg_height) * 72).round, max_model_y].min + 150, 768].max
141
+ erd_height = [[(BigDecimal(svg_height) * 72).round, max_model_y].compact.min + 150, 768].max
143
142
  # edge tail head n x1 y1 .. xn yn [label xl yl] style color
144
143
  edges = plain.scan(/^edge ([^ ]+)+ ([^ ]+)/).map {|from, to| {:from => from, :to => to}}
145
144
  render_to_string 'erd/erd/erd', :layout => nil, :locals => {:width => erd_width, :height => erd_height, :models => models, :edges => edges, :edit_mode => edit_mode}
@@ -2,7 +2,7 @@
2
2
  <html>
3
3
  <head>
4
4
  <meta charset='utf-8'>
5
- <title>ERD - <%= Rails.application.class.parent.name %></title>
5
+ <title>ERD - <%= Rails.application.class.name[/[^:]+/] %></title>
6
6
  <%= stylesheet_link_tag '/erd/erd', :media => 'all' %>
7
7
  <%= stylesheet_link_tag 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css', :media => 'all' %>
8
8
  <%= javascript_include_tag 'https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js' %>
data/erd.gemspec CHANGED
@@ -11,9 +11,9 @@ Gem::Specification.new do |gem|
11
11
  gem.homepage = 'https://github.com/amatsuda/erd'
12
12
  gem.license = 'MIT'
13
13
 
14
- gem.files = `git ls-files`.split($\)
15
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.files = Dir.chdir(File.expand_path(__dir__)) do
15
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
16
+ end
17
17
  gem.name = 'erd'
18
18
  gem.require_paths = ['lib']
19
19
  gem.version = Erd::VERSION
data/lib/erd/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Erd
4
- VERSION = '0.8.0'
4
+ VERSION = '0.8.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akira Matsuda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-17 00:00:00.000000000 Z
11
+ date: 2024-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-graphviz
@@ -197,16 +197,6 @@ files:
197
197
  - public/erd/erd.css
198
198
  - public/erd/erd.js
199
199
  - src/assets/stylesheets/erd/erd.css.scss
200
- - test/fake_app/config/database.yml
201
- - test/fake_app/db/migrate/20120428022519_create_authors.rb
202
- - test/fake_app/db/migrate/20120428022535_create_books.rb
203
- - test/fake_app/db/schema.rb
204
- - test/fake_app/fake_app.rb
205
- - test/fake_app/log/.gitignore
206
- - test/fake_app/tmp/.gitkeep
207
- - test/features/erd_test.rb
208
- - test/lib/migrator_test.rb
209
- - test/test_helper.rb
210
200
  homepage: https://github.com/amatsuda/erd
211
201
  licenses:
212
202
  - MIT
@@ -226,18 +216,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
226
216
  - !ruby/object:Gem::Version
227
217
  version: '0'
228
218
  requirements: []
229
- rubygems_version: 3.1.4
219
+ rubygems_version: 3.6.0.dev
230
220
  signing_key:
231
221
  specification_version: 4
232
222
  summary: erd engine on Rails
233
- test_files:
234
- - test/fake_app/config/database.yml
235
- - test/fake_app/db/migrate/20120428022519_create_authors.rb
236
- - test/fake_app/db/migrate/20120428022535_create_books.rb
237
- - test/fake_app/db/schema.rb
238
- - test/fake_app/fake_app.rb
239
- - test/fake_app/log/.gitignore
240
- - test/fake_app/tmp/.gitkeep
241
- - test/features/erd_test.rb
242
- - test/lib/migrator_test.rb
243
- - test/test_helper.rb
223
+ test_files: []
@@ -1,3 +0,0 @@
1
- development:
2
- adapter: sqlite3
3
- database: ":memory:"
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class CreateAuthors < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[5.0] : ActiveRecord::Migration
4
- def change
5
- create_table :authors do |t|
6
- t.string :name
7
-
8
- t.timestamps
9
- end
10
- end
11
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class CreateBooks < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[5.0] : ActiveRecord::Migration
4
- def change
5
- create_table :books do |t|
6
- t.references :author
7
- t.string :title
8
-
9
- t.timestamps
10
- end
11
- end
12
- end
File without changes
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'active_record'
4
- require 'action_controller/railtie'
5
-
6
- # config
7
- module ErdApp
8
- class Application < Rails::Application
9
- # Rais.root
10
- config.root = File.dirname(__FILE__)
11
-
12
- config.secret_token = 'fall to your knees and repent if you please'
13
- config.session_store :cookie_store, :key => '_myapp_session'
14
- config.active_support.deprecation = :log
15
- config.eager_load = false
16
-
17
- config.app_generators.orm :active_record, :migration => true, :timestamps => true
18
- end
19
- end
20
- ErdApp::Application.initialize!
21
- ErdApp::Application.routes.draw {}
22
-
23
- # models
24
- class Author < ActiveRecord::Base
25
- has_many :books
26
- end
27
- class Book < ActiveRecord::Base
28
- belongs_to :author
29
- end
30
-
31
- # helpers
32
- module ApplicationHelper; end
@@ -1 +0,0 @@
1
- *.log
File without changes
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- class ErdIndexTest < ActionDispatch::IntegrationTest
6
- test 'with author and book model' do
7
- visit '/erd'
8
-
9
- if Capybara::VERSION > '3'
10
- assert has_content? 'Author', :minimum => 1
11
- else
12
- assert has_content? 'Author'
13
- end
14
- assert has_content? 'name'
15
- assert has_content? 'Book'
16
- assert has_content? 'title'
17
- end
18
- end
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- class MigratorTest < ActiveSupport::TestCase
6
- teardown do
7
- Dir.glob(Rails.root.join('db/migrate/*.rb')).each do |f|
8
- FileUtils.rm f unless File.basename(f).in? %w(20120428022519_create_authors.rb 20120428022535_create_books.rb)
9
- end
10
- end
11
-
12
- sub_test_case '.status' do
13
- test 'when all migrations are up' do
14
- assert_equal [{:status => 'up', :version => '20120428022519', :name => 'create_authors', :filename => '20120428022519_create_authors.rb'}, {:status => 'up', :version => '20120428022535', :name => 'create_books', :filename => '20120428022535_create_books.rb'}], Erd::Migrator.status
15
- end
16
-
17
- test 'when one is undone' do
18
- FileUtils.touch Rails.root.join('db/migrate/20999999999999_create_foobars.rb')
19
-
20
- assert_equal [{:status => 'up', :version => '20120428022519', :name => 'create_authors', :filename => '20120428022519_create_authors.rb'}, {:status => 'up', :version => '20120428022535', :name => 'create_books', :filename => '20120428022535_create_books.rb'}, {:status => 'down', :version => '20999999999999', :name => 'create_foobars', :filename => '20999999999999_create_foobars.rb'}], Erd::Migrator.status
21
- end
22
- end
23
-
24
- sub_test_case '.run_migrations' do
25
- setup do
26
- File.open(Rails.root.join('db/migrate/20999999999999_create_foobars.rb'), 'w') do |f|
27
- f.puts 'class CreateFoobars < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[5.0] : ActiveRecord::Migration; end'
28
- end
29
-
30
- if defined? ActiveRecord::MigrationContext # >= 5.2
31
- mock.instance_of(ActiveRecord::MigrationContext).run(:up, 20999999999999)
32
- else
33
- mock(ActiveRecord::Migrator).run(:up, ['db/migrate'], 20999999999999)
34
- end
35
- mock(ActiveRecord::SchemaDumper).dump(ActiveRecord::Base.connection, anything)
36
- end
37
- test 'runs migration by version number' do
38
- Erd::Migrator.run_migrations(:up => ['20999999999999'])
39
- end
40
- test 'runs migration by migration filename' do
41
- Erd::Migrator.run_migrations(:up => [Rails.root.join('db/migrate/20999999999999_create_foobars.rb')])
42
- end
43
- end
44
- end
45
-
46
- class GenaratorRunnerTest < ActiveSupport::TestCase
47
- setup do
48
- stub.proxy(Time).now {|t| stub(t).utc { Time.parse '2012/5/12 13:26' } }
49
- end
50
- teardown do
51
- Dir.glob(Rails.root.join('db/migrate/*.rb')).each do |f|
52
- FileUtils.rm f unless File.basename(f).in? %w(20120428022519_create_authors.rb 20120428022535_create_books.rb)
53
- end
54
- end
55
-
56
- test '.execute_generate_migration' do
57
- assert_includes Erd::GenaratorRunner.execute_generate_migration('create_foobars'), 'db/migrate/20120512132600_create_foobars.rb'
58
- end
59
- end
data/test/test_helper.rb DELETED
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- $LOAD_PATH.unshift(File.dirname(__FILE__))
5
-
6
- ENV['RAILS_ENV'] = 'development'
7
-
8
- # load Rails first
9
- require 'rails'
10
- require 'action_controller/railtie'
11
- require 'active_record/railtie'
12
- require 'erd'
13
- require 'fake_app/fake_app'
14
- require 'test/unit/rails/test_help'
15
- Bundler.require
16
- require 'capybara'
17
- require 'selenium/webdriver'
18
-
19
- begin
20
- require "action_dispatch/system_test_case"
21
- rescue LoadError
22
- Capybara.register_driver :chrome do |app|
23
- options = Selenium::WebDriver::Chrome::Options.new(:args => %w[no-sandbox headless disable-gpu])
24
- Capybara::Selenium::Driver.new(app, :browser => :chrome, :options => options)
25
- end
26
- Capybara.javascript_driver = :chrome
27
- else
28
- ActionDispatch::SystemTestCase.driven_by(:selenium, :using => :headless_chrome)
29
- end
30
-
31
- ActiveRecord::Migration.verbose = false
32
- if defined? ActiveRecord::MigrationContext # >= 5.2
33
- ActiveRecord::Migrator.migrations_paths = Rails.application.paths['db/migrate'].to_a
34
- ActiveRecord::Base.connection.migration_context.migrate
35
- else
36
- ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths.map {|p| Rails.root.join p}, nil)
37
- end