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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0aa1977437fc4e44349ecc11431e4f8697acb1471e159777c629850a52de1664
4
- data.tar.gz: cd92c7a05f6958d2f0cc5ee1204b30fe7b6bd6e168aa18c0b2b182da3b00af9a
3
+ metadata.gz: 57f6e105901e8e59e683b93f6fb1e6e8139dc6b3017cc6ac0579d5005f0eae7f
4
+ data.tar.gz: a3b8a7e546eb9b05694259c46f50e8568baafa9b02642178d816b4310c1333a6
5
5
  SHA512:
6
- metadata.gz: e979a144ac442f73483c23c93cb335742b43e9d198811788edb9a416a3d70cd3b23b64ab0783cf20b4452afa00d46827aaed629d021d880172d373491cc9ec96
7
- data.tar.gz: 35375bb916081981ff264dd74a53b59638c78ad0e2f4dfb40d8716bec59caa387dc114001234be8bb2ba20a3345ecac9d88a1b7b0322ae38b8d92759c61efa75
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
- the config generator is provided as Rake task.
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:
@@ -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.transform_keys(&:to_s))
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Exwiw
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
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
- FileUtils.mkdir_p("exwiw")
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("exwiw", "#{table.name}.json")
50
- File.write(path, JSON.pretty_generate(table.to_hash))
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.0
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-17 00:00:00.000000000 Z
10
+ date: 2025-03-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: serdes