schema_to_dbml 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTE.md +68 -0
- data/Gemfile.lock +19 -6
- data/README.md +42 -20
- data/lib/configuration.rb +12 -3
- data/lib/schema_to_dbml/build_dbml_content.rb +6 -1
- data/lib/schema_to_dbml/configs/custom_config.yml +2 -1
- data/lib/schema_to_dbml/dbml_relations_formatter.rb +6 -13
- data/lib/schema_to_dbml/errors/configuration_file_not_found_error.rb +9 -0
- data/lib/schema_to_dbml/formatters/default_field_formatter_helper.rb +19 -0
- data/lib/schema_to_dbml/formatters/fields_formatter.rb +8 -1
- data/lib/schema_to_dbml/helpers/constants.rb +2 -2
- data/lib/schema_to_dbml/version.rb +1 -1
- data/lib/schema_to_dbml.rb +14 -15
- metadata +19 -3
- data/LICENSE.txt +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d437e4d75d3d034a51e6a63d2e5f56ce5b8a95364fd785f354e5ffcad7e5956
|
4
|
+
data.tar.gz: b16dd77e8f191da41fb875582873aeb0c7d53cfa9029c47b805733838585f42b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cb923fdc024dadc60b8d9e309895dbebd0d471c3f8fc0b50e85b5c27ea09df3b771741d8eb0c4a9ae92dc3ae174ce6043661cc95fa7adc2f2697acc51b08a36
|
7
|
+
data.tar.gz: afa0177a0764031887e62fc0feaea2019c8faf2693b289fdf6794db04064abbfe61aed045b7bf40903b8463c26247a575c5a096b5aae1a351c4ffe84cdcce150
|
data/CONTRIBUTE.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# Contributing to `schema_to_dbml`
|
2
|
+
|
3
|
+
Welcome! We're excited that you're interested in contributing to `schema_to_dbml`, an open-source project. By contributing, you can help improve the project, fix bugs, add new features, and enhance its overall quality.
|
4
|
+
|
5
|
+
The following guidelines will help you understand how you can contribute effectively. We encourage you to read them carefully before getting started.
|
6
|
+
|
7
|
+
## Ways to Contribute
|
8
|
+
|
9
|
+
There are several ways in which you can contribute to the project:
|
10
|
+
|
11
|
+
1. **Reporting Issues**: If you come across any bugs or have suggestions for improvements, please open an issue on the project's GitHub repository. Make sure to provide as much information as possible, including steps to reproduce the issue and any relevant error messages.
|
12
|
+
|
13
|
+
2. **Submitting Pull Requests (PRs)**: You can help by fixing bugs, adding new features, or improving the existing codebase. If you're planning to work on a significant change, it's best to open an issue first to discuss it with the maintainers and ensure it aligns with the project's goals.
|
14
|
+
|
15
|
+
## Getting Started
|
16
|
+
|
17
|
+
To contribute code changes to `schema_to_dbml`, follow these steps:
|
18
|
+
|
19
|
+
1. Fork the project repository to your GitHub account.
|
20
|
+
|
21
|
+
2. Clone the forked repository to your local machine:
|
22
|
+
```
|
23
|
+
git clone https://github.com/your-username/schema_to_dbml.git
|
24
|
+
```
|
25
|
+
|
26
|
+
3. Create a new branch for your changes:
|
27
|
+
```
|
28
|
+
git checkout -b my-branch-name
|
29
|
+
```
|
30
|
+
|
31
|
+
4. Make the necessary changes and improvements to the codebase.
|
32
|
+
|
33
|
+
5. Test your changes thoroughly to ensure they work as expected.
|
34
|
+
|
35
|
+
6. Commit your changes with a descriptive commit message:
|
36
|
+
```
|
37
|
+
git commit -m "Add feature XYZ"
|
38
|
+
```
|
39
|
+
|
40
|
+
7. Push your changes to your forked repository:
|
41
|
+
```
|
42
|
+
git push origin my-branch-name
|
43
|
+
```
|
44
|
+
|
45
|
+
8. Open a pull request (PR) on the original repository. Provide a detailed description of your changes, including the problem they solve or the feature they add. Also, reference any related issues in the PR description.
|
46
|
+
|
47
|
+
## Code Guidelines
|
48
|
+
|
49
|
+
To maintain a consistent codebase, please adhere to the following guidelines:
|
50
|
+
|
51
|
+
- Follow the existing code style and naming conventions used in the project.
|
52
|
+
- Write clear and concise code and documentation.
|
53
|
+
- Add tests for any new features or modifications to existing functionality.
|
54
|
+
- Ensure that all tests pass before submitting your changes.
|
55
|
+
|
56
|
+
## Communication
|
57
|
+
|
58
|
+
The project's GitHub repository is the primary channel for communication. Feel free to open issues for bug reports, feature requests, or general discussions related to the project.
|
59
|
+
|
60
|
+
## Code of Conduct
|
61
|
+
|
62
|
+
Please note that this project follows a [Code of Conduct](https://github.com/ricardojcribeiro/schema_to_dbml/blob/develop/CODE_OF_CONDUCT.md). We expect all contributors to adhere to the code when participating in the project.
|
63
|
+
|
64
|
+
## Acknowledgments
|
65
|
+
|
66
|
+
Contributors play a vital role in the success of any open-source project. Your efforts and contributions will be acknowledged in the project's documentation and release notes.
|
67
|
+
|
68
|
+
Thank you for your interest in contributing to `schema_to_dbml`. Together, we can make the project even better!
|
data/Gemfile.lock
CHANGED
@@ -1,22 +1,32 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
schema_to_dbml (0.0.
|
4
|
+
schema_to_dbml (0.0.2)
|
5
|
+
activesupport (>= 6.1.0)
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: https://rubygems.org/
|
8
9
|
specs:
|
10
|
+
activesupport (7.0.4.3)
|
11
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
+
i18n (>= 1.6, < 2)
|
13
|
+
minitest (>= 5.1)
|
14
|
+
tzinfo (~> 2.0)
|
9
15
|
ast (2.4.2)
|
10
16
|
byebug (11.1.3)
|
17
|
+
concurrent-ruby (1.2.2)
|
11
18
|
diff-lcs (1.5.0)
|
12
19
|
docile (1.4.0)
|
20
|
+
i18n (1.13.0)
|
21
|
+
concurrent-ruby (~> 1.0)
|
13
22
|
json (2.6.3)
|
14
|
-
|
15
|
-
|
23
|
+
minitest (5.18.0)
|
24
|
+
parallel (1.23.0)
|
25
|
+
parser (3.2.2.1)
|
16
26
|
ast (~> 2.4.1)
|
17
27
|
rainbow (3.1.1)
|
18
28
|
rake (13.0.6)
|
19
|
-
regexp_parser (2.
|
29
|
+
regexp_parser (2.8.0)
|
20
30
|
rexml (3.2.5)
|
21
31
|
rspec (3.12.0)
|
22
32
|
rspec-core (~> 3.12.0)
|
@@ -31,7 +41,7 @@ GEM
|
|
31
41
|
diff-lcs (>= 1.2.0, < 2.0)
|
32
42
|
rspec-support (~> 3.12.0)
|
33
43
|
rspec-support (3.12.0)
|
34
|
-
rubocop (1.
|
44
|
+
rubocop (1.51.0)
|
35
45
|
json (~> 2.3)
|
36
46
|
parallel (~> 1.10)
|
37
47
|
parser (>= 3.2.0.0)
|
@@ -41,7 +51,7 @@ GEM
|
|
41
51
|
rubocop-ast (>= 1.28.0, < 2.0)
|
42
52
|
ruby-progressbar (~> 1.7)
|
43
53
|
unicode-display_width (>= 2.4.0, < 3.0)
|
44
|
-
rubocop-ast (1.28.
|
54
|
+
rubocop-ast (1.28.1)
|
45
55
|
parser (>= 3.2.1.0)
|
46
56
|
ruby-progressbar (1.13.0)
|
47
57
|
simplecov (0.22.0)
|
@@ -50,10 +60,13 @@ GEM
|
|
50
60
|
simplecov_json_formatter (~> 0.1)
|
51
61
|
simplecov-html (0.12.3)
|
52
62
|
simplecov_json_formatter (0.1.4)
|
63
|
+
tzinfo (2.0.6)
|
64
|
+
concurrent-ruby (~> 1.0)
|
53
65
|
unicode-display_width (2.4.2)
|
54
66
|
|
55
67
|
PLATFORMS
|
56
68
|
x86_64-darwin-22
|
69
|
+
x86_64-linux
|
57
70
|
|
58
71
|
DEPENDENCIES
|
59
72
|
bundler
|
data/README.md
CHANGED
@@ -43,47 +43,69 @@ This will output the generated DBML content.
|
|
43
43
|
|
44
44
|
## Custom Configuration
|
45
45
|
|
46
|
-
If you want to customize the DBML content, you can create a YAML configuration file with your desired properties.
|
47
|
-
By default, the SchemaToDbml will
|
48
|
-
|
49
|
-
Here's an example of the configuration file:
|
46
|
+
If you want to customize the DBML content, you can create a YAML configuration file with your desired properties.
|
47
|
+
By default, the SchemaToDbml will load the below default configuration
|
50
48
|
|
51
49
|
```yaml
|
52
|
-
custom_project_name: '
|
53
|
-
custom_database_type: 'PostgreSQL'
|
54
|
-
custom_project_notes:
|
55
|
-
|
50
|
+
custom_project_name: 'dbml_database_definition'
|
51
|
+
custom_database_type: "'PostgreSQL'"
|
52
|
+
custom_project_notes: |
|
53
|
+
# My Project Notes
|
54
|
+
This is a **project** that documents the database. Here are some key points:
|
55
|
+
|
56
|
+
- Utilizes the custom primary key for better indexing
|
57
|
+
- Specifies the appropriate database type (e.g., PostgreSQL)
|
58
|
+
- Provides meaningful project information and descriptions
|
59
|
+
custom_primary_key: "id integer [pk, unique, note: 'Unique identifier and primary key']"
|
60
|
+
custom_dbml_content: ''
|
56
61
|
```
|
57
62
|
|
58
63
|
You can change the properties as you want. After that, you can load the configuration by calling:
|
59
64
|
|
60
65
|
```ruby
|
61
|
-
SchemaToDbml.load_configuration_from_yaml('/path/to/your/custom_config.yml')
|
66
|
+
SchemaToDbml.load_configuration_from_yaml(file_path: '/path/to/your/custom_config.yml')
|
62
67
|
```
|
63
68
|
|
64
|
-
|
69
|
+
Example of custom yaml configurations:
|
65
70
|
|
66
71
|
```ruby
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
72
|
+
custom_database_type: 'PostgreSQL'
|
73
|
+
custom_project_name: 'my_project_database'
|
74
|
+
custom_project_notes: |
|
75
|
+
# My Project Database
|
76
|
+
This database is designed to support the operations of my project, a leading platform on my core business
|
77
|
+
custom_dbml_content: |
|
78
|
+
enum object_status {
|
79
|
+
created [note: 'Initial status']
|
80
|
+
pending
|
81
|
+
finished
|
82
|
+
cancelled
|
83
|
+
}
|
84
|
+
TableGroup my_table_group {
|
85
|
+
table_1
|
86
|
+
table_2
|
87
|
+
table_3
|
88
|
+
}
|
74
89
|
```
|
75
90
|
|
76
91
|
After that, you can use the SchemaToDbml to generate the DBML content as usual.
|
77
92
|
|
78
93
|
## Development
|
79
94
|
|
95
|
+
|
80
96
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
81
97
|
|
82
|
-
To install this gem onto your local machine, run `bundle
|
98
|
+
To install this gem onto your local machine, run `bundle install`.
|
99
|
+
|
100
|
+
For proposing changes, create a new branch and make your changes there. Do not change the version number in `version.rb`. After you've done your changes, open a new Pull Request (PR) for your changes to be reviewed.
|
101
|
+
|
102
|
+
The maintainers will review your PR. If approved, they will update the version number in `version.rb` and run `bundle exec rake release`. This will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org/).
|
103
|
+
|
104
|
+
Remember, direct changes to the version number and releases are not allowed. All changes should go through a Pull Request and should be approved by the maintainers.
|
83
105
|
|
84
106
|
## Contributing
|
85
107
|
|
86
|
-
|
108
|
+
Please read the [contribution guideline](https://github.com/ricardojcribeiro/schema_to_dbml/blob/develop/CONTRIBUTE.md)
|
87
109
|
|
88
110
|
## License
|
89
111
|
|
@@ -91,4 +113,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
91
113
|
|
92
114
|
## Code of Conduct
|
93
115
|
|
94
|
-
Everyone interacting in the SchemaToDbml project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
116
|
+
Everyone interacting in the SchemaToDbml project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ricardojcribeiro/schema_to_dbml/blob/develop/CODE_OF_CONDUCT.md).
|
data/lib/configuration.rb
CHANGED
@@ -1,8 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Configuration
|
4
|
-
|
5
|
-
|
4
|
+
def configure_from_hash(yaml_data)
|
5
|
+
@custom_database_type = yaml_data['custom_database_type']
|
6
|
+
@custom_dbml_content = yaml_data['custom_dbml_content']
|
7
|
+
@custom_project_name = yaml_data['custom_project_name']
|
8
|
+
@custom_project_notes = yaml_data['custom_project_notes']
|
9
|
+
@custom_primary_key = yaml_data['custom_primary_key']
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_accessor :custom_database_type,
|
13
|
+
:custom_dbml_content,
|
6
14
|
:custom_project_name,
|
7
|
-
:custom_project_notes
|
15
|
+
:custom_project_notes,
|
16
|
+
:custom_primary_key
|
8
17
|
end
|
@@ -10,6 +10,7 @@ class BuildDbmlContent
|
|
10
10
|
dbml << project_header
|
11
11
|
dbml << tables_section(converted[:tables])
|
12
12
|
dbml << relations_section(converted[:relations])
|
13
|
+
dbml << custom_dbml_content
|
13
14
|
|
14
15
|
dbml.join("\n\n")
|
15
16
|
end
|
@@ -18,7 +19,7 @@ class BuildDbmlContent
|
|
18
19
|
|
19
20
|
def project_header
|
20
21
|
header = "Project #{project_name} {\n"
|
21
|
-
header += " database_type: #{custom_database_type}\n"
|
22
|
+
header += " database_type: '#{custom_database_type}'\n"
|
22
23
|
header += " Note: '#{custom_project_notes}'\n"
|
23
24
|
header += '}'
|
24
25
|
header
|
@@ -44,5 +45,9 @@ class BuildDbmlContent
|
|
44
45
|
configuration.custom_project_notes
|
45
46
|
end
|
46
47
|
|
48
|
+
def custom_dbml_content
|
49
|
+
configuration.custom_dbml_content
|
50
|
+
end
|
51
|
+
|
47
52
|
attr_reader :configuration
|
48
53
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
custom_project_name: 'dbml_database_definition'
|
2
|
-
custom_database_type:
|
2
|
+
custom_database_type: 'PostgreSQL'
|
3
3
|
custom_project_notes: |
|
4
4
|
# My Project Notes
|
5
5
|
This is a **project** that documents the database. Here are some key points:
|
@@ -8,3 +8,4 @@ custom_project_notes: |
|
|
8
8
|
- Specifies the appropriate database type (e.g., PostgreSQL)
|
9
9
|
- Provides meaningful project information and descriptions
|
10
10
|
custom_primary_key: "id integer [pk, unique, note: 'Unique identifier and primary key']"
|
11
|
+
custom_dbml_content: ''
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'active_support/inflector'
|
4
|
+
|
3
5
|
class DbmlRelationsFormatter
|
4
6
|
# Formats a database relationship for a DBML file
|
5
7
|
#
|
@@ -21,26 +23,17 @@ class DbmlRelationsFormatter
|
|
21
23
|
|
22
24
|
private
|
23
25
|
|
24
|
-
def default_foreign_key_column(to_table)
|
25
|
-
"#{singularize(to_table)}_id"
|
26
|
-
end
|
27
|
-
|
28
26
|
def generate_reference_name(from_table, to_table, column)
|
29
27
|
ref_name = "fk_rails_#{from_table}_#{to_table}"
|
30
28
|
ref_name += "_#{column}" if column != default_foreign_key_column(to_table)
|
31
29
|
ref_name
|
32
30
|
end
|
33
31
|
|
34
|
-
def
|
35
|
-
"
|
32
|
+
def default_foreign_key_column(to_table)
|
33
|
+
"#{to_table.singularize}_id"
|
36
34
|
end
|
37
35
|
|
38
|
-
|
39
|
-
|
40
|
-
# @param word [String] the word to singularize
|
41
|
-
#
|
42
|
-
# @return [String] the singularized word
|
43
|
-
def singularize(word)
|
44
|
-
word.sub(/(?:([^aeiouy])y|s)$/, '\1').sub(/ies$/, 'y')
|
36
|
+
def build_reference_string(ref_name, from_table, column, to_table)
|
37
|
+
"Ref #{ref_name}:#{from_table}.#{column} - #{to_table}.id"
|
45
38
|
end
|
46
39
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DefaultFieldFormatterHelper
|
4
|
+
DEFAULT_ARRAY_REGEX = [/default: (\[.*?\])/, 'default: \'\1\''].freeze
|
5
|
+
DEFAULT_BOOLEAN_REGEX = [/default: (true|false)/, 'default: \1'].freeze
|
6
|
+
DEFAULT_HASH_REGEX = [/default: (\{(?:[^}]*?)\})/, 'default: \'\1\''].freeze
|
7
|
+
DEFAULT_NUMBER_REGEX = [/default: (\d+(?:\.\d+)?)/, 'default: \1'].freeze
|
8
|
+
DEFAULT_STRING_REGEX = [/default: "(.*?)"/, 'default: \'\1\''].freeze
|
9
|
+
DEFAULT_LAMBDA_REGEX = [/default: -> \{ "(.*?)" \}/, 'default: `\1`'].freeze
|
10
|
+
|
11
|
+
DEFAULT_PATTERNS = [
|
12
|
+
DEFAULT_ARRAY_REGEX,
|
13
|
+
DEFAULT_BOOLEAN_REGEX,
|
14
|
+
DEFAULT_HASH_REGEX,
|
15
|
+
DEFAULT_NUMBER_REGEX,
|
16
|
+
DEFAULT_STRING_REGEX,
|
17
|
+
DEFAULT_LAMBDA_REGEX
|
18
|
+
].freeze
|
19
|
+
end
|
@@ -1,7 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'default_field_formatter_helper'
|
4
|
+
|
3
5
|
module Formatters
|
4
6
|
module FieldsFormatter
|
7
|
+
include DefaultFieldFormatterHelper
|
5
8
|
TYPE_MAPPER = {
|
6
9
|
string: 'varchar',
|
7
10
|
integer: 'int',
|
@@ -22,7 +25,11 @@ module Formatters
|
|
22
25
|
def format_default(default:)
|
23
26
|
return '' if default.to_s.empty?
|
24
27
|
|
25
|
-
|
28
|
+
DEFAULT_PATTERNS.each do |pattern, replacement|
|
29
|
+
default = default.gsub(pattern, replacement)
|
30
|
+
end
|
31
|
+
|
32
|
+
default
|
26
33
|
end
|
27
34
|
|
28
35
|
def format_null(null:)
|
@@ -3,9 +3,9 @@
|
|
3
3
|
module Helpers
|
4
4
|
module Constants
|
5
5
|
# rubocop:disable Layout/LineLength
|
6
|
-
TABLES_REGEXP = /create_table\s+"(?<table_name>\w+)"(?:,\s+comment:\s+"(?<comment>.*?)")?(?:,\s+force:\s+:cascade)?\s+do\s+\|t\|\n(?<table_content
|
6
|
+
TABLES_REGEXP = /create_table\s+"(?<table_name>\w+)"(?:,\s+comment:\s+"(?<comment>.*?)")?(?:,\s+force:\s+:cascade)?\s+do\s+\|t\|\n(?<table_content>(?:.*?)(?:".*?")*.*?)(?<=\n)\s+end/m
|
7
7
|
|
8
|
-
COLUMNS_REGEXP = /t\.(?<type>\w+)\s+"(?<name>\w+)"(?:,\s+
|
8
|
+
COLUMNS_REGEXP = /t\.(?<type>\w+)\s+"(?<name>\w+)"(?:,\s+(?<default>default:[^,\n]+?(?=(?:,\s)|$)))?(?:,\s+(?<null>null:\s+\w+))?(?:,\s+comment:\s+"(?<comment>[^"]+)")?(?:,\s+precision:\s+(?<precision>\d+))?(?:,\s+array:\s+(?<array>true|false))?.*/
|
9
9
|
|
10
10
|
RELATIONS_REGEXP = /add_foreign_key\s+"(?<from_table>\w+)",\s+"(?<to_table>\w+)"(?:,\s+column:\s+"(?<column>\w+)")?(?:,\s+on_delete:\s+:(?<on_delete>\w+))?/
|
11
11
|
# rubocop:enable Layout/LineLength
|
data/lib/schema_to_dbml.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'yaml'
|
4
|
+
require 'active_support/core_ext/hash'
|
4
5
|
require_relative 'configuration'
|
5
6
|
require_relative 'schema_to_dbml/build_dbml_content'
|
6
7
|
require_relative 'schema_to_dbml/errors/schema_file_not_found_error'
|
8
|
+
require_relative 'schema_to_dbml/errors/configuration_file_not_found_error'
|
7
9
|
require_relative 'schema_to_dbml/schema_converter'
|
8
10
|
require_relative 'schema_to_dbml/version'
|
9
11
|
|
@@ -12,27 +14,24 @@ class SchemaToDbml
|
|
12
14
|
|
13
15
|
class << self
|
14
16
|
def configuration
|
15
|
-
@configuration ||=
|
16
|
-
config = Configuration.new
|
17
|
-
load_configuration_from_yaml(DEFAULT_CONFIG_FILE, config)
|
18
|
-
config
|
19
|
-
end
|
17
|
+
@configuration ||= Configuration.new
|
20
18
|
end
|
21
19
|
|
22
|
-
def load_configuration_from_yaml(file_path
|
23
|
-
raise
|
20
|
+
def load_configuration_from_yaml(file_path: DEFAULT_CONFIG_FILE)
|
21
|
+
raise Errors::ConfigurationFileNotFoundError unless File.exist?(file_path)
|
24
22
|
|
25
23
|
yaml_data = YAML.load_file(file_path)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
c.custom_project_name = yaml_data['custom_project_name']
|
30
|
-
c.custom_project_notes = yaml_data['custom_project_notes']
|
31
|
-
end
|
24
|
+
yaml_data = merge_with_defaults(file_path, yaml_data)
|
25
|
+
|
26
|
+
configuration.configure_from_hash(yaml_data)
|
32
27
|
end
|
33
28
|
|
34
|
-
def
|
35
|
-
|
29
|
+
def merge_with_defaults(file_path, yaml_data)
|
30
|
+
return yaml_data unless file_path != DEFAULT_CONFIG_FILE
|
31
|
+
|
32
|
+
default_settings = YAML.load_file(DEFAULT_CONFIG_FILE)
|
33
|
+
|
34
|
+
default_settings.deep_merge!(yaml_data)
|
36
35
|
end
|
37
36
|
end
|
38
37
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema_to_dbml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo Ribeiro
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: activesupport
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 6.1.0
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 6.1.0
|
97
111
|
description: This gem provides functionality for parsing a Rails schema.rb file and
|
98
112
|
generating a corresponding DBML file.
|
99
113
|
email:
|
@@ -105,10 +119,10 @@ files:
|
|
105
119
|
- ".rubocop.yml"
|
106
120
|
- CHANGELOG.md
|
107
121
|
- CODE_OF_CONDUCT.md
|
122
|
+
- CONTRIBUTE.md
|
108
123
|
- Gemfile
|
109
124
|
- Gemfile.lock
|
110
125
|
- LICENSE
|
111
|
-
- LICENSE.txt
|
112
126
|
- README.md
|
113
127
|
- Rakefile
|
114
128
|
- lib/configuration.rb
|
@@ -118,7 +132,9 @@ files:
|
|
118
132
|
- lib/schema_to_dbml/configs/custom_config.yml
|
119
133
|
- lib/schema_to_dbml/dbml_relations_formatter.rb
|
120
134
|
- lib/schema_to_dbml/dbml_tables_formatter.rb
|
135
|
+
- lib/schema_to_dbml/errors/configuration_file_not_found_error.rb
|
121
136
|
- lib/schema_to_dbml/errors/schema_file_not_found_error.rb
|
137
|
+
- lib/schema_to_dbml/formatters/default_field_formatter_helper.rb
|
122
138
|
- lib/schema_to_dbml/formatters/fields_formatter.rb
|
123
139
|
- lib/schema_to_dbml/helpers/constants.rb
|
124
140
|
- lib/schema_to_dbml/schema_converter.rb
|
data/LICENSE.txt
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2023 Ricardo Ribeiro
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|