exwiw 0.1.0 → 0.1.1
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 +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +7 -1
- data/lib/exwiw/table_config.rb +25 -1
- data/lib/exwiw/version.rb +1 -1
- data/lib/tasks/exwiw.rake +10 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57f6e105901e8e59e683b93f6fb1e6e8139dc6b3017cc6ac0579d5005f0eae7f
|
4
|
+
data.tar.gz: a3b8a7e546eb9b05694259c46f50e8568baafa9b02642178d816b4310c1333a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fd906a22713484fa28d2301144a188ee5d57c9da0a7fbfb591c41d978ab8fa4771d48ea438e00f3d51a4ba8eb18a3e50e64eb6903352d26686ff6a8cffaa123
|
7
|
+
data.tar.gz: 6a9c4b42302eb86bfae1de412ce79fd244c829ecc4580f14df749dfb374f1d3c5f825caf2e506ea6344d92bad120e5ffa859f32b6a7a60d4b9843defcbd08d04
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
1
3
|
## [Unreleased]
|
2
4
|
|
5
|
+
## [0.1.1] - 2025-03-02
|
6
|
+
|
7
|
+
### Added
|
8
|
+
|
9
|
+
- Added support for `OUTPUT_DIR_PATH` environment variable in `exwiw:schema:generate` task to specify custom output directory for generated schema files.
|
10
|
+
- When `exwiw:scheman:generate` detects schema files in the output directory, it tries to keep filter and masking options.
|
11
|
+
|
3
12
|
## [0.1.0] - 2025-01-31
|
4
13
|
|
5
14
|
- Initial release
|
data/README.md
CHANGED
@@ -76,13 +76,19 @@ idx meaning is the same as insert sql.
|
|
76
76
|
|
77
77
|
### Generator
|
78
78
|
|
79
|
-
|
79
|
+
The config generator is provided as a Rake task.
|
80
80
|
|
81
81
|
```bash
|
82
82
|
# generate table schema under exwiw/
|
83
83
|
bundle exec rake exwiw:schema:generate
|
84
84
|
```
|
85
85
|
|
86
|
+
By default, the schema files will be saved in the `exwiw` directory. You can specify a different output directory by setting the `OUTPUT_DIR_PATH` environment variable:
|
87
|
+
|
88
|
+
```sh
|
89
|
+
OUTPUT_DIR_PATH=custom_directory bundle exec rake exwiw:schema:generate
|
90
|
+
```
|
91
|
+
|
86
92
|
### Configuration
|
87
93
|
|
88
94
|
This is an example of the one table schema:
|
data/lib/exwiw/table_config.rb
CHANGED
@@ -11,7 +11,7 @@ module Exwiw
|
|
11
11
|
attribute :columns, array(TableColumn)
|
12
12
|
|
13
13
|
def self.from_symbol_keys(hash)
|
14
|
-
from(hash.
|
14
|
+
from(JSON.parse(hash.to_json))
|
15
15
|
end
|
16
16
|
|
17
17
|
def column_names
|
@@ -65,6 +65,30 @@ module Exwiw
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
+
def merge(passed_table)
|
69
|
+
return passed_table if passed_table.to_hash == self.to_hash
|
70
|
+
|
71
|
+
|
72
|
+
TableConfig.new.tap do |merged_table|
|
73
|
+
merged_table.name = name
|
74
|
+
merged_table.primary_key = passed_table.primary_key
|
75
|
+
merged_table.filter = filter
|
76
|
+
merged_table.belongs_tos = passed_table.belongs_tos
|
77
|
+
|
78
|
+
receiver_column_by_name = columns.each_with_object({}) { |column, hash| hash[column.name] = column }
|
79
|
+
|
80
|
+
merged_table.columns =
|
81
|
+
passed_table.columns.map do |passed_column|
|
82
|
+
if receiver_column_by_name.key?(passed_column.name)
|
83
|
+
receiver_column = receiver_column_by_name[passed_column.name]
|
84
|
+
receiver_column
|
85
|
+
else
|
86
|
+
passed_column
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
68
92
|
private def compute_dependency_to_table(target_table_name, tables_by_name)
|
69
93
|
return [] if belongs_tos.empty?
|
70
94
|
|
data/lib/exwiw/version.rb
CHANGED
data/lib/tasks/exwiw.rake
CHANGED
@@ -43,11 +43,18 @@ namespace :exwiw do
|
|
43
43
|
|
44
44
|
tables = table_by_name.values
|
45
45
|
|
46
|
-
|
46
|
+
output_dir = ENV['OUTPUT_DIR_PATH'] || "exwiw"
|
47
|
+
FileUtils.mkdir_p(output_dir)
|
47
48
|
|
48
49
|
tables.each do |table|
|
49
|
-
path = File.join(
|
50
|
-
File.
|
50
|
+
path = File.join(output_dir, "#{table.name}.json")
|
51
|
+
if File.exist?(path)
|
52
|
+
current_config = Exwiw::TableConfig.from(JSON.parse(File.read(path)))
|
53
|
+
merged_config = current_config.merge(table)
|
54
|
+
File.write(path, JSON.pretty_generate(merged_config.to_hash))
|
55
|
+
else
|
56
|
+
File.write(path, JSON.pretty_generate([table.to_hash]))
|
57
|
+
end
|
51
58
|
end
|
52
59
|
end
|
53
60
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exwiw
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shia
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-02
|
10
|
+
date: 2025-03-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: serdes
|