rails-crud-tools 0.4.1 → 0.4.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 +4 -4
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +26 -35
- data/Gemfile +5 -4
- data/lib/rails/crud/tools/crud_data.rb +24 -1
- data/lib/rails/crud/tools/crud_notifications.rb +1 -1
- data/lib/rails/crud/tools/crud_operations_logger.rb +54 -9
- data/lib/rails/crud/tools/version.rb +1 -1
- data/lib/rails/crud/tools.rb +1 -0
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6550332d57eaa6efc9a533edcd245dc0fbb622f3db4dc60137ded1ce07b9732f
|
4
|
+
data.tar.gz: d640cad53acee4a59aaf354dec8c0fee9b80c51112f3240814c34205288a2ef7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a54979463a9fc47dc5da2e932b94f82e0c992b19ea59b4107d56f55cd88fc5426beaea58042b7c693c305e3a4aa9856afacf239c96acb990af13557e94eba0ea
|
7
|
+
data.tar.gz: 8e2638a585a23d084a7c9e1347138604d0f65aa33e680af4aa93c2e216f345ce80037335e502617a8ce78698aa2a168517dffc11a996901753caa42d384dbba6
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,64 +1,55 @@
|
|
1
|
+
## [0.4.2] - 2025-01-06
|
2
|
+
- Fixed to update the last modifier of the CRUD file
|
3
|
+
- Changed CRUD file saving process to asynchronous processing
|
4
|
+
|
1
5
|
## [0.4.1] - 2025-01-04
|
2
|
-
-
|
6
|
+
- Create the base directory if it does not exist during initialization
|
3
7
|
|
4
8
|
## [0.4.0] - 2025-01-04
|
5
|
-
-
|
6
|
-
-
|
7
|
-
-
|
8
|
-
-
|
9
|
-
-
|
10
|
-
-
|
9
|
+
- Fixed to save only when cell values change
|
10
|
+
- Added sheet name to configuration file
|
11
|
+
- Added font name to configuration file
|
12
|
+
- Created test code
|
13
|
+
- Added initialization command
|
14
|
+
- Added configuration file creation command
|
11
15
|
|
12
16
|
## [0.3.2] - 2025-01-01
|
13
|
-
|
14
|
-
- 複数スレッド対応
|
17
|
+
- Multi-thread support
|
15
18
|
|
16
19
|
## [0.3.1] - 2024-12-31
|
17
|
-
|
18
|
-
- rails-crud-toolsに変更
|
20
|
+
- Changed to rails-crud-tools
|
19
21
|
|
20
22
|
## [0.3.0] - 2024-12-30
|
21
|
-
|
22
|
-
-
|
23
|
-
- クラッド図生成コマンドの追加
|
23
|
+
- Job support
|
24
|
+
- Added command to generate CRUD diagrams
|
24
25
|
|
25
26
|
## [0.2.2] - 2024-12-25
|
26
|
-
|
27
|
-
-
|
28
|
-
- サマリーログの改善
|
27
|
+
- Added ON/OFF for SQL output
|
28
|
+
- Improved summary log
|
29
29
|
|
30
30
|
## [0.2.1] - 2024-12-25
|
31
|
-
|
32
|
-
- リファクタリング
|
31
|
+
- Refactoring
|
33
32
|
|
34
33
|
## [0.2.0] - 2024-12-25
|
35
|
-
|
36
|
-
- api対応
|
34
|
+
- API support
|
37
35
|
|
38
36
|
## [0.1.6] - 2024-12-25
|
39
|
-
|
40
|
-
- ログ改善
|
37
|
+
- Improved logging
|
41
38
|
|
42
39
|
## [0.1.5] - 2024-12-25
|
43
|
-
|
44
|
-
- マルチスレッド改善
|
40
|
+
- Improved multi-threading
|
45
41
|
|
46
42
|
## [0.1.4] - 2024-12-24
|
47
|
-
|
48
|
-
- リファクタリング
|
43
|
+
- Refactoring
|
49
44
|
|
50
45
|
## [0.1.3] - 2024-12-24
|
51
|
-
|
52
|
-
- bug fix
|
46
|
+
- Bug fix
|
53
47
|
|
54
48
|
## [0.1.2] - 2024-12-24
|
55
|
-
|
56
|
-
- bug fix
|
49
|
+
- Bug fix
|
57
50
|
|
58
51
|
## [0.1.1] - 2024-12-24
|
59
|
-
|
60
|
-
- プレビュー版のリリース
|
52
|
+
- Preview release
|
61
53
|
|
62
54
|
## [0.1.0] - 2024-12-23
|
63
|
-
|
64
|
-
- Initial release
|
55
|
+
- Initial release
|
data/Gemfile
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require "zip"
|
1
2
|
require_relative "crud_logger"
|
2
3
|
require_relative "constants"
|
3
4
|
|
@@ -8,9 +9,10 @@ module Rails
|
|
8
9
|
class CrudData
|
9
10
|
include Singleton
|
10
11
|
|
11
|
-
attr_accessor :crud_rows, :crud_cols, :workbook, :last_loaded_time
|
12
|
+
attr_accessor :process_id, :crud_rows, :crud_cols, :workbook, :last_loaded_time
|
12
13
|
|
13
14
|
def initialize
|
15
|
+
@process_id = nil
|
14
16
|
@crud_rows = {}
|
15
17
|
@crud_cols = {}
|
16
18
|
@last_loaded_time = nil
|
@@ -61,9 +63,30 @@ module Rails
|
|
61
63
|
return unless config.enabled
|
62
64
|
|
63
65
|
return unless @last_loaded_time.nil? || File.mtime(config.crud_file_path) > @last_loaded_time
|
66
|
+
|
67
|
+
last_modified_by = get_last_modified_by(config.crud_file_path)
|
68
|
+
CrudLogger.logger.debug "last modified by: #{last_modified_by}. process_id: #{process_id}"
|
69
|
+
return if process_id == last_modified_by
|
70
|
+
|
64
71
|
CrudLogger.logger.info "Reloading CRUD data due to file modification. last_loaded_time = #{@last_loaded_time}"
|
65
72
|
load_crud_data
|
73
|
+
end
|
74
|
+
|
75
|
+
# xlsxファイルの最終更新者を取得する
|
76
|
+
def get_last_modified_by(file_path)
|
77
|
+
last_modified_by = nil
|
78
|
+
|
79
|
+
Zip::File.open(file_path) do |zipfile|
|
80
|
+
doc_props = zipfile.find_entry("docProps/core.xml")
|
81
|
+
if doc_props
|
82
|
+
content = doc_props.get_input_stream.read
|
83
|
+
last_modified_by = content[/\<cp:lastModifiedBy\>(.*?)\<\/cp:lastModifiedBy\>/, 1]
|
84
|
+
else
|
85
|
+
CrudLogger.logger.warn "docProps/core.xml が見つかりませんでした。"
|
86
|
+
end
|
87
|
+
end
|
66
88
|
|
89
|
+
last_modified_by
|
67
90
|
end
|
68
91
|
|
69
92
|
# CRUDシートを取得する
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
2
|
-
require_relative
|
1
|
+
require "zip"
|
2
|
+
require_relative "crud_logger"
|
3
|
+
require_relative "constants"
|
3
4
|
|
4
5
|
# ログ出力を行うモジュール
|
5
6
|
module Rails
|
@@ -50,6 +51,31 @@ module Rails
|
|
50
51
|
Thread.current[:crud_sidekiq_job_class] = nil
|
51
52
|
end
|
52
53
|
|
54
|
+
# xlsxファイルの最終更新者を更新する
|
55
|
+
def set_last_modified_by(file_path, modifier_name)
|
56
|
+
Zip::File.open(file_path) do |zip_file|
|
57
|
+
doc_props = zip_file.find_entry("docProps/core.xml")
|
58
|
+
if doc_props
|
59
|
+
content = doc_props.get_input_stream.read
|
60
|
+
updated_content = if content.include?("<cp:lastModifiedBy>")
|
61
|
+
content.sub(
|
62
|
+
%r{<cp:lastModifiedBy>.*?</cp:lastModifiedBy>},
|
63
|
+
"<cp:lastModifiedBy>#{modifier_name}</cp:lastModifiedBy>"
|
64
|
+
)
|
65
|
+
else
|
66
|
+
content.sub(
|
67
|
+
%r{</cp:coreProperties>},
|
68
|
+
"<cp:lastModifiedBy>#{modifier_name}</cp:lastModifiedBy></cp:coreProperties>"
|
69
|
+
)
|
70
|
+
end
|
71
|
+
zip_file.get_output_stream("docProps/core.xml") { |f| f.write(updated_content) }
|
72
|
+
CrudLogger.logger.info "Set the last modifier to #{modifier_name}."
|
73
|
+
else
|
74
|
+
CrudLogger.logger.warn "docProps/core.xml was not found."
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
53
79
|
private
|
54
80
|
|
55
81
|
# リクエストの詳細をログ出力する
|
@@ -107,15 +133,34 @@ module Rails
|
|
107
133
|
end
|
108
134
|
end
|
109
135
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
#
|
116
|
-
|
136
|
+
return unless contents_changed
|
137
|
+
|
138
|
+
Thread.new do
|
139
|
+
update_crud_file
|
140
|
+
rescue StandardError => e
|
141
|
+
CrudLogger.logger.error "Failed to update #{CrudConfig.instance.crud_file_path}: #{e.message}"
|
142
|
+
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
|
+
|
147
|
+
def update_crud_file
|
148
|
+
File.open(CrudConfig.instance.crud_file_path, "r+") do |crud_file|
|
149
|
+
crud_file.flock(File::LOCK_EX)
|
150
|
+
begin
|
151
|
+
# Excelファイルを書き込む
|
152
|
+
CrudData.instance.workbook.write(crud_file)
|
153
|
+
set_last_modified_by(crud_file, CrudData.instance.process_id)
|
154
|
+
timestamp = File.mtime(crud_file)
|
155
|
+
CrudLogger.logger.debug "Updated timestamp: #{timestamp}"
|
156
|
+
# タイムスタンプを更新する
|
157
|
+
CrudData.instance.last_loaded_time = timestamp
|
158
|
+
ensure
|
159
|
+
crud_file.flock(File::LOCK_UN)
|
160
|
+
end
|
117
161
|
end
|
118
162
|
end
|
163
|
+
|
119
164
|
end
|
120
165
|
end
|
121
166
|
end
|
data/lib/rails/crud/tools.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-crud-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yhijikata
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-01-
|
11
|
+
date: 2025-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activerecord
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '7.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '7.0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rubyXL
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -25,19 +39,19 @@ dependencies:
|
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: '3.4'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
42
|
+
name: rubyzip
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
47
|
+
version: '2.4'
|
34
48
|
type: :runtime
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
54
|
+
version: '2.4'
|
41
55
|
description: This gem provides CRUD functionality for Rails applications.
|
42
56
|
email:
|
43
57
|
- yhijikata@systemlancer.com
|
@@ -89,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
89
103
|
requirements:
|
90
104
|
- - ">="
|
91
105
|
- !ruby/object:Gem::Version
|
92
|
-
version: 2.
|
106
|
+
version: 2.7.0
|
93
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
108
|
requirements:
|
95
109
|
- - ">="
|