acts_as_graph_diagram 0.1.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.
Files changed (83) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +178 -0
  4. data/Rakefile +5 -0
  5. data/bin/test +7 -0
  6. data/lib/acts_as_graph_diagram/edge_scopes.rb +23 -0
  7. data/lib/acts_as_graph_diagram/node/graph_calculator.rb +129 -0
  8. data/lib/acts_as_graph_diagram/node.rb +120 -0
  9. data/lib/acts_as_graph_diagram/railtie.rb +11 -0
  10. data/lib/acts_as_graph_diagram/version.rb +5 -0
  11. data/lib/acts_as_graph_diagram.rb +12 -0
  12. data/lib/generators/USAGE +5 -0
  13. data/lib/generators/acts_as_graph_diagram_generator.rb +30 -0
  14. data/lib/generators/templates/migration.rb +21 -0
  15. data/lib/generators/templates/model.rb +24 -0
  16. data/test/acts_as_graph_diagram_test.rb +44 -0
  17. data/test/dummy/Rakefile +39 -0
  18. data/test/dummy/app/assets/config/manifest.js +3 -0
  19. data/test/dummy/app/assets/images/.keep +0 -0
  20. data/test/dummy/app/assets/stylesheets/application.css +1 -0
  21. data/test/dummy/app/channels/application_cable/channel.rb +6 -0
  22. data/test/dummy/app/channels/application_cable/connection.rb +6 -0
  23. data/test/dummy/app/controllers/application_controller.rb +4 -0
  24. data/test/dummy/app/controllers/concerns/.keep +0 -0
  25. data/test/dummy/app/controllers/gods_controller.rb +67 -0
  26. data/test/dummy/app/helpers/application_helper.rb +4 -0
  27. data/test/dummy/app/helpers/gods_helper.rb +4 -0
  28. data/test/dummy/app/javascript/application.js +94 -0
  29. data/test/dummy/app/jobs/application_job.rb +9 -0
  30. data/test/dummy/app/mailers/application_mailer.rb +6 -0
  31. data/test/dummy/app/models/application_record.rb +5 -0
  32. data/test/dummy/app/models/concerns/.keep +0 -0
  33. data/test/dummy/app/models/edge.rb +24 -0
  34. data/test/dummy/app/models/god.rb +14 -0
  35. data/test/dummy/app/views/gods/_form.html.erb +22 -0
  36. data/test/dummy/app/views/gods/_god.html.erb +16 -0
  37. data/test/dummy/app/views/gods/edit.html.erb +6 -0
  38. data/test/dummy/app/views/gods/index.html.erb +35 -0
  39. data/test/dummy/app/views/gods/new.html.erb +5 -0
  40. data/test/dummy/app/views/gods/show.html.erb +9 -0
  41. data/test/dummy/app/views/layouts/application.html.erb +15 -0
  42. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  43. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  44. data/test/dummy/bin/importmap +5 -0
  45. data/test/dummy/bin/rails +6 -0
  46. data/test/dummy/bin/rake +6 -0
  47. data/test/dummy/bin/setup +35 -0
  48. data/test/dummy/config/application.rb +23 -0
  49. data/test/dummy/config/boot.rb +7 -0
  50. data/test/dummy/config/cable.yml +10 -0
  51. data/test/dummy/config/database.yml +25 -0
  52. data/test/dummy/config/environment.rb +7 -0
  53. data/test/dummy/config/environments/development.rb +71 -0
  54. data/test/dummy/config/environments/production.rb +89 -0
  55. data/test/dummy/config/environments/test.rb +62 -0
  56. data/test/dummy/config/importmap.rb +43 -0
  57. data/test/dummy/config/initializers/content_security_policy.rb +26 -0
  58. data/test/dummy/config/initializers/filter_parameter_logging.rb +10 -0
  59. data/test/dummy/config/initializers/inflections.rb +17 -0
  60. data/test/dummy/config/initializers/permissions_policy.rb +12 -0
  61. data/test/dummy/config/locales/en.yml +33 -0
  62. data/test/dummy/config/puma.rb +45 -0
  63. data/test/dummy/config/routes.rb +11 -0
  64. data/test/dummy/config/storage.yml +34 -0
  65. data/test/dummy/config.ru +8 -0
  66. data/test/dummy/db/migrate/20220606102242_create_gods.rb +11 -0
  67. data/test/dummy/db/migrate/20220612090334_acts_as_graph_diagram_migration.rb +21 -0
  68. data/test/dummy/db/schema.rb +35 -0
  69. data/test/dummy/db/seeds.rb +53 -0
  70. data/test/dummy/lib/assets/.keep +0 -0
  71. data/test/dummy/log/.keep +0 -0
  72. data/test/dummy/public/404.html +67 -0
  73. data/test/dummy/public/422.html +67 -0
  74. data/test/dummy/public/500.html +66 -0
  75. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  76. data/test/dummy/public/apple-touch-icon.png +0 -0
  77. data/test/dummy/public/favicon.ico +0 -0
  78. data/test/dummy/test/controllers/gods_controller_test.rb +50 -0
  79. data/test/dummy/test/system/gods_test.rb +43 -0
  80. data/test/fixtures/edges.yml +111 -0
  81. data/test/fixtures/gods.yml +81 -0
  82. data/test/test_helper.rb +18 -0
  83. metadata +434 -0
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ .rails-default-error-page {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ .rails-default-error-page div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ .rails-default-error-page div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ .rails-default-error-page h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ .rails-default-error-page div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body class="rails-default-error-page">
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
File without changes
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ class GodsControllerTest < ActionDispatch::IntegrationTest
6
+ setup do
7
+ @god = gods(:one)
8
+ end
9
+
10
+ test 'should get index' do
11
+ get gods_url
12
+ assert_response :success
13
+ end
14
+
15
+ test 'should get new' do
16
+ get new_god_url
17
+ assert_response :success
18
+ end
19
+
20
+ test 'should create god' do
21
+ assert_difference('God.count') do
22
+ post gods_url, params: { god: {} }
23
+ end
24
+
25
+ assert_redirected_to god_url(God.last)
26
+ end
27
+
28
+ test 'should show god' do
29
+ get god_url(@god)
30
+ assert_response :success
31
+ end
32
+
33
+ test 'should get edit' do
34
+ get edit_god_url(@god)
35
+ assert_response :success
36
+ end
37
+
38
+ test 'should update god' do
39
+ patch god_url(@god), params: { god: {} }
40
+ assert_redirected_to god_url(@god)
41
+ end
42
+
43
+ test 'should destroy god' do
44
+ assert_difference('God.count', -1) do
45
+ delete god_url(@god)
46
+ end
47
+
48
+ assert_redirected_to gods_url
49
+ end
50
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'application_system_test_case'
4
+
5
+ class GodsTest < ApplicationSystemTestCase
6
+ setup do
7
+ @god = gods(:one)
8
+ end
9
+
10
+ test 'visiting the index' do
11
+ visit gods_url
12
+ assert_selector 'h1', text: 'Gods'
13
+ end
14
+
15
+ test 'creating a God' do
16
+ visit gods_url
17
+ click_on 'New God'
18
+
19
+ click_on 'Create God'
20
+
21
+ assert_text 'God was successfully created'
22
+ click_on 'Back'
23
+ end
24
+
25
+ test 'updating a God' do
26
+ visit gods_url
27
+ click_on 'Edit', match: :first
28
+
29
+ click_on 'Update God'
30
+
31
+ assert_text 'God was successfully updated'
32
+ click_on 'Back'
33
+ end
34
+
35
+ test 'destroying a God' do
36
+ visit gods_url
37
+ page.accept_confirm do
38
+ click_on 'Destroy', match: :first
39
+ end
40
+
41
+ assert_text 'God was successfully destroyed'
42
+ end
43
+ end
@@ -0,0 +1,111 @@
1
+ ---
2
+ edge_1:
3
+ id: 1
4
+ comment: ''
5
+ cost: 0
6
+ directed: 1
7
+ destination_type: God
8
+ destination_id: 2
9
+ departure_type: God
10
+ departure_id: 1
11
+ created_at: '2022-06-12 10:22:53.474166'
12
+ updated_at: '2022-06-12 10:22:53.474166'
13
+ edge_2:
14
+ id: 2
15
+ comment: ''
16
+ cost: 0
17
+ directed: 1
18
+ destination_type: God
19
+ destination_id: 6
20
+ departure_type: God
21
+ departure_id: 2
22
+ created_at: '2022-06-12 10:24:06.567095'
23
+ updated_at: '2022-06-12 10:24:06.567095'
24
+ edge_3:
25
+ id: 3
26
+ comment: ''
27
+ cost: 0
28
+ directed: 1
29
+ destination_type: God
30
+ destination_id: 9
31
+ departure_type: God
32
+ departure_id: 2
33
+ created_at: '2022-06-12 10:24:15.637117'
34
+ updated_at: '2022-06-12 10:24:15.637117'
35
+ edge_4:
36
+ id: 4
37
+ comment: ''
38
+ cost: 0
39
+ directed: 1
40
+ destination_type: God
41
+ destination_id: 1
42
+ departure_type: God
43
+ departure_id: 16
44
+ created_at: '2022-06-12 10:27:35.769026'
45
+ updated_at: '2022-06-12 10:27:35.769026'
46
+ edge_5:
47
+ id: 5
48
+ comment: ''
49
+ cost: 0
50
+ directed: 1
51
+ destination_type: God
52
+ destination_id: 12
53
+ departure_type: God
54
+ departure_id: 16
55
+ created_at: '2022-06-12 10:27:57.757286'
56
+ updated_at: '2022-06-12 10:27:57.757286'
57
+ edge_6:
58
+ id: 6
59
+ comment: ''
60
+ cost: 0
61
+ directed: 1
62
+ destination_type: God
63
+ destination_id: 14
64
+ departure_type: God
65
+ departure_id: 16
66
+ created_at: '2022-06-12 10:28:09.014984'
67
+ updated_at: '2022-06-12 10:28:09.014984'
68
+ edge_7:
69
+ id: 7
70
+ comment: ''
71
+ cost: 0
72
+ directed: 1
73
+ destination_type: God
74
+ destination_id: 2
75
+ departure_type: God
76
+ departure_id: 16
77
+ created_at: '2022-06-12 10:28:20.582828'
78
+ updated_at: '2022-06-12 10:28:20.582828'
79
+ edge_8:
80
+ id: 8
81
+ comment: ''
82
+ cost: 0
83
+ directed: 1
84
+ destination_type: God
85
+ destination_id: 11
86
+ departure_type: God
87
+ departure_id: 16
88
+ created_at: '2022-06-12 10:28:31.325304'
89
+ updated_at: '2022-06-12 10:28:31.325304'
90
+ edge_9:
91
+ id: 9
92
+ comment: ''
93
+ cost: 0
94
+ directed: 1
95
+ destination_type: God
96
+ destination_id: 8
97
+ departure_type: God
98
+ departure_id: 16
99
+ created_at: '2022-06-12 10:28:45.014246'
100
+ updated_at: '2022-06-12 10:28:45.014246'
101
+ edge_10:
102
+ id: 10
103
+ comment: ''
104
+ cost: 0
105
+ directed: 1
106
+ destination_type: God
107
+ destination_id: 15
108
+ departure_type: God
109
+ departure_id: 14
110
+ created_at: '2022-06-12 10:40:10.499846'
111
+ updated_at: '2022-06-12 10:40:10.499846'
@@ -0,0 +1,81 @@
1
+ ---
2
+ god_1:
3
+ id: 1
4
+ name: Zeus
5
+ created_at: '2022-06-07 13:23:54.400827'
6
+ updated_at: '2022-06-07 13:23:54.400827'
7
+ god_2:
8
+ id: 2
9
+ name: Hēra
10
+ created_at: '2022-06-07 13:23:54.401713'
11
+ updated_at: '2022-06-07 13:23:54.401713'
12
+ god_3:
13
+ id: 3
14
+ name: Athēnā
15
+ created_at: '2022-06-07 13:23:54.402256'
16
+ updated_at: '2022-06-07 13:23:54.402256'
17
+ god_4:
18
+ id: 4
19
+ name: Apollōn
20
+ created_at: '2022-06-07 13:23:54.402750'
21
+ updated_at: '2022-06-07 13:23:54.402750'
22
+ god_5:
23
+ id: 5
24
+ name: Aphrodītē
25
+ created_at: '2022-06-07 13:23:54.403219'
26
+ updated_at: '2022-06-07 13:23:54.403219'
27
+ god_6:
28
+ id: 6
29
+ name: Arēs
30
+ created_at: '2022-06-07 13:23:54.403665'
31
+ updated_at: '2022-06-07 13:23:54.403665'
32
+ god_7:
33
+ id: 7
34
+ name: Artemis
35
+ created_at: '2022-06-07 13:23:54.404115'
36
+ updated_at: '2022-06-07 13:23:54.404115'
37
+ god_8:
38
+ id: 8
39
+ name: Dēmētēr
40
+ created_at: '2022-06-07 13:23:54.404620'
41
+ updated_at: '2022-06-07 13:23:54.404620'
42
+ god_9:
43
+ id: 9
44
+ name: Hēphaistos
45
+ created_at: '2022-06-07 13:23:54.405079'
46
+ updated_at: '2022-06-07 13:23:54.405079'
47
+ god_10:
48
+ id: 10
49
+ name: Hermēs
50
+ created_at: '2022-06-07 13:23:54.405527'
51
+ updated_at: '2022-06-07 13:23:54.405527'
52
+ god_11:
53
+ id: 11
54
+ name: Poseidōn
55
+ created_at: '2022-06-07 13:23:54.405954'
56
+ updated_at: '2022-06-07 13:23:54.405954'
57
+ god_12:
58
+ id: 12
59
+ name: Hestiā
60
+ created_at: '2022-06-07 13:23:54.406398'
61
+ updated_at: '2022-06-07 13:23:54.406398'
62
+ god_13:
63
+ id: 13
64
+ name: Dionȳsos
65
+ created_at: '2022-06-07 13:23:54.406852'
66
+ updated_at: '2022-06-07 13:23:54.406852'
67
+ god_14:
68
+ id: 14
69
+ name: Hādēs
70
+ created_at: '2022-06-07 13:23:54.407294'
71
+ updated_at: '2022-06-07 13:23:54.407294'
72
+ god_15:
73
+ id: 15
74
+ name: Persephonē
75
+ created_at: '2022-06-07 13:23:54.407762'
76
+ updated_at: '2022-06-07 13:23:54.407762'
77
+ god_16:
78
+ id: 16
79
+ name: Rheā
80
+ created_at: '2022-06-12 10:26:51.991511'
81
+ updated_at: '2022-06-12 10:26:51.991511'
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Configure Rails Environment
4
+ ENV['RAILS_ENV'] = 'test'
5
+
6
+ require_relative '../test/dummy/config/environment'
7
+ ActiveRecord::Migrator.migrations_paths = [File.expand_path('../test/dummy/db/migrate', __dir__)]
8
+ ActiveRecord::Base.logger = Logger.new("#{File.dirname(__FILE__)}/debug.log")
9
+
10
+ require 'rails/test_help'
11
+
12
+ # Load fixtures from the engine
13
+ if ActiveSupport::TestCase.respond_to?(:fixture_path=)
14
+ ActiveSupport::TestCase.fixture_path = File.expand_path('fixtures', __dir__)
15
+ ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
16
+ ActiveSupport::TestCase.file_fixture_path = "#{ActiveSupport::TestCase.fixture_path}/files"
17
+ ActiveSupport::TestCase.fixtures :all
18
+ end