arxutils_sqlite3 0.1.58 → 0.1.60
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -3
- data/.rubocop_todo.yml +21 -49
- data/Gemfile +20 -26
- data/Gemfile.lock +15 -7
- data/Rakefile +37 -18
- data/arxutils_sqlite3.gemspec +31 -30
- data/bin/console +3 -3
- data/bin/setup +2 -0
- data/exe/arxutils_sqlite3 +29 -28
- data/lib/arxutils_sqlite3/arx.rb +4 -2
- data/lib/arxutils_sqlite3/cli.rb +3 -1
- data/lib/arxutils_sqlite3/config.rb +29 -27
- data/lib/arxutils_sqlite3/dbutil/dbconnect.rb +7 -6
- data/lib/arxutils_sqlite3/dbutil.rb +3 -1
- data/lib/arxutils_sqlite3/hier.rb +6 -4
- data/lib/arxutils_sqlite3/migrate.rb +23 -21
- data/lib/arxutils_sqlite3/rake_task.rb +47 -45
- data/lib/arxutils_sqlite3/transactstate.rb +2 -0
- data/lib/arxutils_sqlite3/util.rb +4 -1
- data/lib/arxutils_sqlite3/version.rb +3 -1
- data/lib/arxutils_sqlite3.rb +17 -17
- data/lib/dbacrecord.rb +3 -3
- data/lib/template/acrecord/acrecord_current.tmpl +1 -1
- data/lib/template/acrecord/acrecord_invalid.tmpl +2 -2
- data/lib/template/acrecord/db_scheme/dbsetup.tmpl +1 -46
- data/lib/template/acrecord/db_scheme/opts.rb.sample +2 -2
- data/lib/template/acrecord/db_scheme/opts.tmpl +2 -2
- metadata +41 -13
@@ -1,43 +1,45 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ykutils'
|
2
4
|
|
3
5
|
module Arxutils_Sqlite3
|
4
6
|
##
|
5
7
|
# migrateに必要なファイルをテンプレートから作成し、migarteを実行する
|
6
8
|
class Config
|
7
9
|
# DB格納ディレクトリ名
|
8
|
-
DB_DIR =
|
10
|
+
DB_DIR = 'db'
|
9
11
|
# migrate用スクリプト格納ディレクトリ名
|
10
|
-
MIGRATE_BASE_DIR =
|
12
|
+
MIGRATE_BASE_DIR = 'migrate'
|
11
13
|
# SQLITE3用DB構成名
|
12
|
-
DBCONFIG_SQLITE3 =
|
14
|
+
DBCONFIG_SQLITE3 = 'sqlite3'
|
13
15
|
# MYSQL用DB構成名
|
14
|
-
DBCONFIG_MYSQL =
|
16
|
+
DBCONFIG_MYSQL = 'mysql'
|
15
17
|
# DB構成格納用ディレクトリ名
|
16
|
-
CONFIG_DIR_NAME =
|
18
|
+
CONFIG_DIR_NAME = 'config'
|
17
19
|
|
18
20
|
# コンフィグディレクトリへのパス
|
19
21
|
CONFIG_DIR = Pathname.new(CONFIG_DIR_NAME)
|
20
22
|
# データベース用ログファイル名
|
21
|
-
DATABASELOG =
|
23
|
+
DATABASELOG = 'database.log'
|
22
24
|
# テンプレートディレクトリへのパス
|
23
|
-
TEMPLATE_DIR = Arxutils_Sqlite3::TOP_DIR.join(
|
25
|
+
TEMPLATE_DIR = Arxutils_Sqlite3::TOP_DIR.join('template')
|
24
26
|
# リレーションテンプレートディレクトリへのパス
|
25
|
-
TEMPLATE_ACRECORD_DIR = TEMPLATE_DIR.join(
|
27
|
+
TEMPLATE_ACRECORD_DIR = TEMPLATE_DIR.join('acrecord')
|
26
28
|
TEMPLATE_CONFIG_DIR = TEMPLATE_DIR.join(CONFIG_DIR)
|
27
|
-
DB_SCHEME_DIR = TEMPLATE_ACRECORD_DIR.join(
|
28
|
-
DB_SCHEME_FILE = DB_SCHEME_DIR.join(
|
29
|
-
SAMPLE_DB_SCHEME_FILE = CONFIG_DIR.join(
|
30
|
-
DB_SCHEME_FILE_NAME =
|
31
|
-
DB_SCHEME_FILE_NAME_B =
|
32
|
-
OPTS_FILE_NAME =
|
33
|
-
SAMPLE_OPTS_FILE_NAME =
|
34
|
-
OPTS_FILE_NAME_B =
|
35
|
-
DEST_OPTS_FILE_NAME =
|
36
|
-
DEST_OPTS_FILE_NAME_B =
|
37
|
-
DBSETUP_FILE_NAME =
|
38
|
-
DBSETUP_FILE_NAME_B =
|
39
|
-
DEST_DBSETUP_FILE_NAME =
|
40
|
-
SETTING_YAML_FILE_NAME =
|
29
|
+
DB_SCHEME_DIR = TEMPLATE_ACRECORD_DIR.join('db_scheme')
|
30
|
+
DB_SCHEME_FILE = DB_SCHEME_DIR.join('db_scheme.yml')
|
31
|
+
SAMPLE_DB_SCHEME_FILE = CONFIG_DIR.join('db_scheme.yml.sample')
|
32
|
+
DB_SCHEME_FILE_NAME = 'db_scheme.yml'
|
33
|
+
DB_SCHEME_FILE_NAME_B = 'db_scheme'
|
34
|
+
OPTS_FILE_NAME = 'opts.tmpl'
|
35
|
+
SAMPLE_OPTS_FILE_NAME = 'opts.rb.sample'
|
36
|
+
OPTS_FILE_NAME_B = 'opts'
|
37
|
+
DEST_OPTS_FILE_NAME = 'opts.rb'
|
38
|
+
DEST_OPTS_FILE_NAME_B = 'opts'
|
39
|
+
DBSETUP_FILE_NAME = 'dbsetup.tmpl'
|
40
|
+
DBSETUP_FILE_NAME_B = 'dbsetup'
|
41
|
+
DEST_DBSETUP_FILE_NAME = 'dbsetup.rb'
|
42
|
+
SETTING_YAML_FILE_NAME = 'setting.yml'
|
41
43
|
DEST_CONFIG_DIR = Pathname.new(CONFIG_DIR)
|
42
44
|
OPTS_FILE = DB_SCHEME_DIR.join(OPTS_FILE_NAME)
|
43
45
|
SAMPLE_OPTS_FILE = CONFIG_DIR.join(SAMPLE_OPTS_FILE_NAME)
|
@@ -61,7 +63,7 @@ module Arxutils_Sqlite3
|
|
61
63
|
# 削除しないファイル群
|
62
64
|
EXCLUDE_FILES = %w[SETTING_YAML_FILE_NAME].freeze
|
63
65
|
# 作成対象のActiveRecordの子クラスのデフォルトクラス名
|
64
|
-
DEFAULT_MOD =
|
66
|
+
DEFAULT_MOD = 'Xenop'
|
65
67
|
|
66
68
|
def default_mod
|
67
69
|
DEFAULT_MOD
|
@@ -169,7 +171,7 @@ module Arxutils_Sqlite3
|
|
169
171
|
def require_opts_file
|
170
172
|
return unless DEST_OPTS_FILE.exist?
|
171
173
|
|
172
|
-
opts_file = File.join(
|
174
|
+
opts_file = File.join('./', DEST_OPTS_FILE_B.to_s)
|
173
175
|
begin
|
174
176
|
require opts_file
|
175
177
|
rescue LoadError
|
@@ -188,7 +190,7 @@ module Arxutils_Sqlite3
|
|
188
190
|
|
189
191
|
# Dbsetupファイル(Rubyスクリプトファイル)のrequire
|
190
192
|
def require_dbsetup_file
|
191
|
-
dbsetup_file = File.join(
|
193
|
+
dbsetup_file = File.join('.', dest_dbsetup_file_b.to_s)
|
192
194
|
begin
|
193
195
|
require dbsetup_file
|
194
196
|
rescue LoadError
|
@@ -287,7 +289,7 @@ module Arxutils_Sqlite3
|
|
287
289
|
|
288
290
|
def make_dbsetup_file(db_scheme_ary, acrecord, _mod, dest_dbsetup_file)
|
289
291
|
scope = Object.new
|
290
|
-
hash0 = { mod_name: acrecord[:module].join(
|
292
|
+
hash0 = { mod_name: acrecord[:module].join('::') }
|
291
293
|
hash = db_scheme_ary[0].merge(hash0)
|
292
294
|
result_content = Ykutils::Erubyx.erubi_render_with_template_file(src_dbsetup_file, scope, hash)
|
293
295
|
|
@@ -1,17 +1,18 @@
|
|
1
1
|
#! -*- encoding : UTF-8 -*-
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
4
|
+
require 'fileutils'
|
5
|
+
require 'yaml'
|
6
|
+
require 'active_record'
|
7
|
+
require 'sqlite3'
|
8
|
+
require 'ykxutils'
|
8
9
|
|
9
10
|
module Arxutils_Sqlite3
|
10
11
|
module Dbutil
|
11
12
|
# DB操作用ユーティリティクラス
|
12
13
|
class Dbconnect
|
13
14
|
def self.make_log_file_name(dbconfig, log_file_base_name)
|
14
|
-
format(
|
15
|
+
format('%s-%s', dbconfig.to_s, log_file_base_name)
|
15
16
|
end
|
16
17
|
|
17
18
|
def self.db_connect(config, dbconfig, env)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Arxutils_Sqlite3
|
2
4
|
# 階層処理
|
3
5
|
class HierOp
|
@@ -93,7 +95,7 @@ module Arxutils_Sqlite3
|
|
93
95
|
def register_parent(hier_ary, child_num, level)
|
94
96
|
hier_ary.pop
|
95
97
|
parent_hier_ary = hier_ary
|
96
|
-
parent_hier = parent_hier_ary.join(
|
98
|
+
parent_hier = parent_hier_ary.join('/')
|
97
99
|
parent_num = register(parent_hier)
|
98
100
|
hs = { parent_id: parent_num, child_id: child_num, level: level }
|
99
101
|
@hier_klass.create(hs)
|
@@ -101,7 +103,7 @@ module Arxutils_Sqlite3
|
|
101
103
|
|
102
104
|
# 文字列で指定した階層(/を区切り文字として持つ)をhier_klassに登録
|
103
105
|
def register(hier)
|
104
|
-
hier_ary = hier.split(
|
106
|
+
hier_ary = hier.split('/')
|
105
107
|
level = get_level_by_array(hier_ary)
|
106
108
|
|
107
109
|
# もしhier_aryがnilだけを1個持つ配列、または空文字列だけを1個もつ配列であれば、hier_nameは空文字列になる
|
@@ -175,7 +177,7 @@ module Arxutils_Sqlite3
|
|
175
177
|
|
176
178
|
# 階層を表すデータ構造から階層の名前を得る
|
177
179
|
def get_name(items_row)
|
178
|
-
items_row ? items_row.name.split(
|
180
|
+
items_row ? items_row.name.split('/').pop : ''
|
179
181
|
end
|
180
182
|
|
181
183
|
# 階層を表すデータ構造で指定された階層の下部階層の名前を調整する
|
@@ -212,7 +214,7 @@ module Arxutils_Sqlite3
|
|
212
214
|
|
213
215
|
# 文字列で指定された親の階層の下の子の名前から、子の名前を作成
|
214
216
|
def make_hier(parent_hier, name)
|
215
|
-
[parent_hier, name].join(
|
217
|
+
[parent_hier, name].join('/')
|
216
218
|
end
|
217
219
|
end
|
218
220
|
end
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# require "arxutils_sqlite3"
|
2
|
-
require
|
3
|
-
require
|
4
|
+
require 'ykutils'
|
5
|
+
require 'fileutils'
|
4
6
|
# require "active_support"
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
7
|
+
require 'active_record'
|
8
|
+
require 'active_record/migration'
|
9
|
+
require 'pp'
|
8
10
|
|
9
11
|
# ActiveRecord用ユーティリティモジュール
|
10
12
|
module Arxutils_Sqlite3
|
@@ -58,7 +60,7 @@ module Arxutils_Sqlite3
|
|
58
60
|
def delete_migrate_and_config_and_db
|
59
61
|
# def delete_migrate_and_config
|
60
62
|
delete_migrate
|
61
|
-
Dir.glob(File.join(@dest_config_dir,
|
63
|
+
Dir.glob(File.join(@dest_config_dir, '*')).each do |x|
|
62
64
|
basename = File.basename(x)
|
63
65
|
ret = !@config.exclude_file?(basename)
|
64
66
|
ret_file = File.file?(x)
|
@@ -77,14 +79,14 @@ module Arxutils_Sqlite3
|
|
77
79
|
def delete_migrate
|
78
80
|
return unless @migrate_dir
|
79
81
|
|
80
|
-
Dir.glob(File.join(@migrate_dir,
|
82
|
+
Dir.glob(File.join(@migrate_dir, '*')).each do |x|
|
81
83
|
FileUtils.rm(x) if File.file?(x)
|
82
84
|
end
|
83
85
|
end
|
84
86
|
|
85
87
|
# DBファイルの削除
|
86
88
|
def delete_db
|
87
|
-
Dir.glob(File.join(@db_dir,
|
89
|
+
Dir.glob(File.join(@db_dir, '*')).each do |x|
|
88
90
|
FileUtils.rm(x) if File.file?(x)
|
89
91
|
end
|
90
92
|
end
|
@@ -106,12 +108,12 @@ module Arxutils_Sqlite3
|
|
106
108
|
if content_array.find { |x| !x.nil? }
|
107
109
|
# p "####### 1"
|
108
110
|
data_count = {
|
109
|
-
count_classname:
|
111
|
+
count_classname: 'Count',
|
110
112
|
need_count_class_plural: need_count_class_plural
|
111
113
|
}
|
112
114
|
# p "data_count=#{data_count}"
|
113
115
|
ary = content_array.collect { |x| x[:content] }.flatten
|
114
|
-
count_content = convert_count_class_acrecord(data_count,
|
116
|
+
count_content = convert_count_class_acrecord(data_count, 'acrecord_count.tmpl')
|
115
117
|
ary.unshift(count_content)
|
116
118
|
content_array = ary
|
117
119
|
end
|
@@ -132,7 +134,7 @@ module Arxutils_Sqlite3
|
|
132
134
|
def make_content_array
|
133
135
|
# スキーマ設定配列から、acrecordのmigrate用のスクリプトの内容(ハッシュ形式)の配列を作成する
|
134
136
|
acrecords = @db_scheme_ary.map do |x|
|
135
|
-
make_acrecord(x,
|
137
|
+
make_acrecord(x, 'count')
|
136
138
|
end
|
137
139
|
acrecords.select { |x| x.size.positive? }
|
138
140
|
end
|
@@ -153,7 +155,7 @@ module Arxutils_Sqlite3
|
|
153
155
|
def make_dbconfig(data)
|
154
156
|
content = convert(data, @src_config_path, @dbconfig_src_fname)
|
155
157
|
File.open(
|
156
|
-
@dbconfig_dest_path,
|
158
|
+
@dbconfig_dest_path, 'w:utf-8'
|
157
159
|
) do |f|
|
158
160
|
f.puts(content)
|
159
161
|
end
|
@@ -169,8 +171,8 @@ module Arxutils_Sqlite3
|
|
169
171
|
# 指定フィールドのフィールド名に対応したテンプレートファイルを用いて、acrecord設定を作成
|
170
172
|
data[:flist].each_with_object({ content: [], need_count_class: nil }) do |field_name, s|
|
171
173
|
case field_name
|
172
|
-
when
|
173
|
-
name_base =
|
174
|
+
when 'base', 'noitem'
|
175
|
+
name_base = 'acrecord'
|
174
176
|
# data[:acrecord]がnilに設定されていたら改めて空の配列を設定
|
175
177
|
data[:acrecord] = [] unless data[:acrecord]
|
176
178
|
else
|
@@ -198,13 +200,13 @@ module Arxutils_Sqlite3
|
|
198
200
|
# migrationのスクリプトをファイル出力する
|
199
201
|
def output_script(idy, kind, content, classname_downcase)
|
200
202
|
additional = case kind
|
201
|
-
when
|
202
|
-
|
203
|
+
when 'base', 'noitem'
|
204
|
+
''
|
203
205
|
else
|
204
206
|
kind
|
205
207
|
end
|
206
|
-
fname = File.join(@migrate_dir, format(
|
207
|
-
File.open(fname,
|
208
|
+
fname = File.join(@migrate_dir, format('%03d_create_%s%s.rb', idy, additional, classname_downcase))
|
209
|
+
File.open(fname, 'w', **{ encoding: Encoding::UTF_8 }) do |f|
|
208
210
|
f.puts(content)
|
209
211
|
end
|
210
212
|
end
|
@@ -216,13 +218,13 @@ module Arxutils_Sqlite3
|
|
216
218
|
fpath = File.join(dir, fname)
|
217
219
|
ret = :SUCCESS
|
218
220
|
begin
|
219
|
-
File.open(fpath,
|
221
|
+
File.open(fpath, 'w') do |file|
|
220
222
|
acrecord_config[:module].map { |mod| file.puts("module #{mod}") }
|
221
223
|
content_array.map do |x|
|
222
224
|
file.puts x
|
223
|
-
file.puts
|
225
|
+
file.puts ''
|
224
226
|
end
|
225
|
-
acrecord_config[:module].map { |_mod| file.puts(
|
227
|
+
acrecord_config[:module].map { |_mod| file.puts('end') }
|
226
228
|
end
|
227
229
|
rescue StandardError
|
228
230
|
ret = :StandardError
|
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Defining a task called default that depends on the tasks setup, makeconfig, migrate, and acr.
|
2
|
-
require
|
4
|
+
require 'arxutils_sqlite3'
|
3
5
|
config = Arxutils_Sqlite3::Config.new
|
4
6
|
|
5
7
|
mod = nil
|
@@ -7,86 +9,86 @@ setting = config.load_setting_yaml_file
|
|
7
9
|
mod = setting[:mod]
|
8
10
|
mod = config.default_mod if mod.nil?
|
9
11
|
|
10
|
-
desc_arxutils_sqlite3 =
|
12
|
+
desc_arxutils_sqlite3 = 'setup copy_db_scheme copy_opts makeconfig make_migrate_script migrate acr'
|
11
13
|
|
12
14
|
desc desc_arxutils_sqlite3.to_s
|
13
15
|
task arxutils_sqlite3: %w[arx:setup arx:copy_db_scheme arx:copy_opts arx:makeconfig arx:make_migrate_script arx:migrate arx:acr]
|
14
16
|
|
15
17
|
desc desc_arxutils_sqlite3.to_s
|
16
|
-
task
|
18
|
+
task 'arx:arxutils_sqlite3': %w[arxutils_sqlite3]
|
17
19
|
|
18
|
-
desc
|
19
|
-
task
|
20
|
+
desc 'delete setup copy_db_scheme copy_opts makeconfig make_migrate_script migrate acr'
|
21
|
+
task 'arx:bootstrap': %w[arx:delete arxutils_sqlite3]
|
20
22
|
|
21
|
-
desc
|
22
|
-
task
|
23
|
+
desc 'migrate acr'
|
24
|
+
task 'arx:ma': %w[arx:migrate arx:acr]
|
23
25
|
|
24
|
-
desc
|
25
|
-
task
|
26
|
+
desc 'delete_db'
|
27
|
+
task 'arx:b': %w[arx:delete_db]
|
26
28
|
|
27
|
-
desc
|
28
|
-
task
|
29
|
+
desc 'delete setting.yaml'
|
30
|
+
task 'arx:ds': %w[arx:delete_setting]
|
29
31
|
|
30
32
|
# コマンドラインで指定したクラス名を含むオプション指定用ハッシュの定義を含むRubyスクリ
|
31
33
|
# プトファイルの生成
|
32
34
|
desc "produce setting.yml, db_scheme.yml.sample and opts.rb.sample with class name #{mod}"
|
33
|
-
task
|
35
|
+
task 'arx:setup' do
|
34
36
|
sh "bundle exec arxutils_sqlite3 --cmd=s --mod=#{mod}"
|
35
37
|
end
|
36
38
|
|
37
|
-
desc
|
38
|
-
task
|
39
|
-
sh
|
39
|
+
desc 'copy from db_scheme.yml.sample to db_scheme.yml'
|
40
|
+
task 'arx:copy_db_scheme' do
|
41
|
+
sh 'bundle exec arxutils_sqlite3 --cmd=cds'
|
40
42
|
end
|
41
43
|
|
42
|
-
desc
|
43
|
-
task
|
44
|
-
sh
|
44
|
+
desc 'copy from opts.rb.sample to opts.rb'
|
45
|
+
task 'arx:copy_opts' do
|
46
|
+
sh 'bundle exec arxutils_sqlite3 --cmd=co'
|
45
47
|
end
|
46
48
|
|
47
49
|
# DB構成情報の生成
|
48
|
-
desc
|
49
|
-
task
|
50
|
-
sh
|
50
|
+
desc 'produce sqlite3.yml'
|
51
|
+
task 'arx:makeconfig' do
|
52
|
+
sh 'bundle exec arxutils_sqlite3 --cmd=c'
|
51
53
|
end
|
52
54
|
|
53
55
|
# マイグレート用スクリプトファイルの生成
|
54
|
-
desc
|
55
|
-
task
|
56
|
-
sh
|
56
|
+
desc 'produce migration scripts'
|
57
|
+
task 'arx:make_migrate_script' do
|
58
|
+
sh 'bundle exec arxutils_sqlite3 --cmd=f --yaml=config/db_scheme.yml'
|
57
59
|
end
|
58
60
|
# マイグレートの実行
|
59
|
-
desc
|
60
|
-
task
|
61
|
-
sh
|
61
|
+
desc 'execute migration'
|
62
|
+
task 'arx:migrate' do
|
63
|
+
sh 'bundle exec arxutils_sqlite3 --cmd=m'
|
62
64
|
end
|
63
65
|
|
64
|
-
desc
|
65
|
-
task
|
66
|
-
sh
|
66
|
+
desc 'call ActiveRecord instance method'
|
67
|
+
task 'arx:acr' do
|
68
|
+
sh 'bundle exec arxutils_sqlite3 --cmd=a'
|
67
69
|
end
|
68
70
|
|
69
|
-
desc
|
70
|
-
task
|
71
|
-
sh
|
71
|
+
desc 'delete configuration files adn migration scripts and db files'
|
72
|
+
task 'arx:delete' do
|
73
|
+
sh 'bundle exec arxutils_sqlite3 --cmd=del'
|
72
74
|
end
|
73
75
|
|
74
|
-
desc
|
75
|
-
task
|
76
|
-
sh
|
76
|
+
desc 'delete configuration files adn migration scripts and db files'
|
77
|
+
task 'arx:clean' do
|
78
|
+
sh 'bundle exec arxutils_sqlite3 --cmd=d'
|
77
79
|
end
|
78
80
|
|
79
|
-
desc
|
80
|
-
task
|
81
|
-
sh
|
81
|
+
desc 'delete db files'
|
82
|
+
task 'arx:delete_db' do
|
83
|
+
sh 'bundle exec arxutils_sqlite3 --cmd=b'
|
82
84
|
end
|
83
85
|
|
84
|
-
desc
|
85
|
-
task
|
86
|
-
sh
|
86
|
+
desc 'delete setting yaml'
|
87
|
+
task 'arx:delete_setting' do
|
88
|
+
sh 'bundle exec arxutils_sqlite3 --cmd=y'
|
87
89
|
end
|
88
90
|
|
89
|
-
desc
|
90
|
-
task
|
91
|
-
sh
|
91
|
+
desc 'delete migrate scripts'
|
92
|
+
task 'arx:delete_migrate' do
|
93
|
+
sh 'bundle exec arxutils_sqlite3 --cmd=dm'
|
92
94
|
end
|
@@ -1,8 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Arxutils_Sqlite3
|
4
|
+
# パス操作ユーティリティクラス
|
2
5
|
class Util
|
3
6
|
# DBログファイルへのパスの作成
|
4
7
|
def self.make_log_path(db_dir, dbconfig)
|
5
|
-
log_path =
|
8
|
+
log_path = ''
|
6
9
|
log_fname = Dbutil::Dbconnect.make_log_file_name(
|
7
10
|
dbconfig, Config::DATABASELOG
|
8
11
|
)
|
data/lib/arxutils_sqlite3.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'ykutils'
|
4
|
+
require 'ykxutils'
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
6
|
+
require 'bigdecimal'
|
7
|
+
require 'active_support'
|
8
|
+
require 'active_support/core_ext'
|
9
|
+
require 'active_record'
|
10
|
+
require 'pathname'
|
11
11
|
|
12
12
|
module Arxutils_Sqlite3
|
13
13
|
TOP_DIR = Pathname(__FILE__).parent
|
@@ -15,14 +15,14 @@ module Arxutils_Sqlite3
|
|
15
15
|
# Your code goes here...
|
16
16
|
end
|
17
17
|
|
18
|
-
require_relative
|
19
|
-
require_relative
|
20
|
-
require_relative
|
18
|
+
require_relative 'arxutils_sqlite3/dbutil'
|
19
|
+
require_relative 'arxutils_sqlite3/config'
|
20
|
+
require_relative 'arxutils_sqlite3/cli'
|
21
21
|
|
22
|
-
require_relative
|
23
|
-
require_relative
|
24
|
-
require_relative
|
25
|
-
require_relative
|
26
|
-
require_relative
|
27
|
-
require_relative
|
28
|
-
require_relative
|
22
|
+
require_relative 'arxutils_sqlite3/version'
|
23
|
+
require_relative 'arxutils_sqlite3/arx'
|
24
|
+
require_relative 'arxutils_sqlite3/transactstate'
|
25
|
+
require_relative 'arxutils_sqlite3/hier'
|
26
|
+
require_relative 'arxutils_sqlite3/migrate'
|
27
|
+
require_relative 'arxutils_sqlite3/util'
|
28
|
+
require_relative 'dbacrecord'
|
data/lib/dbacrecord.rb
CHANGED
@@ -14,12 +14,12 @@ module Dbutil
|
|
14
14
|
end
|
15
15
|
|
16
16
|
class Invalidxenoplist < ActiveRecord::Base
|
17
|
-
belongs_to :xenoplist, foreign_key:
|
18
|
-
belongs_to :count, foreign_key:
|
17
|
+
belongs_to :xenoplist, foreign_key: 'org_id'
|
18
|
+
belongs_to :count, foreign_key: ''
|
19
19
|
end
|
20
20
|
|
21
21
|
class Currentxenoplist < ActiveRecord::Base
|
22
|
-
belongs_to :xenoplist, foreign_key:
|
22
|
+
belongs_to :xenoplist, foreign_key: 'org_id'
|
23
23
|
end
|
24
24
|
|
25
25
|
end
|
@@ -1,4 +1,4 @@
|
|
1
1
|
class Invalid<%= @data[:classname_downcase] %> < ActiveRecord::Base
|
2
|
-
belongs_to :<%= @data[:classname_downcase] %>, foreign_key:
|
3
|
-
belongs_to :<%= @data[:count_classname_downcase] %>, foreign_key:
|
2
|
+
belongs_to :<%= @data[:classname_downcase] %>, foreign_key: 'org_id'
|
3
|
+
belongs_to :<%= @data[:count_classname_downcase] %>, foreign_key: '<%= @data[:count_field] %>'
|
4
4
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative '../lib/dbacrecord'
|
2
2
|
|
3
3
|
# テスト用クラス
|
4
4
|
class Dbsetup
|
@@ -8,49 +8,4 @@ class Dbsetup
|
|
8
8
|
@hs_by_notebook = {}
|
9
9
|
@hs_by_id = {}
|
10
10
|
end
|
11
|
-
=begin
|
12
|
-
# 指定stack(文字列)にノートブック(文字列)、ノートブック数、タグ数を追加
|
13
|
-
def add( stack , notebook, count, tag_count )
|
14
|
-
ennblist = @hs_by_notebook[notebook]
|
15
|
-
unless ennblist
|
16
|
-
cur_ennblist = Currentennblist.where( notebook: notebook ).limit(1)
|
17
|
-
if cur_ennblist.size == 0
|
18
|
-
begin
|
19
|
-
ennblist = Ennblist.create( stack: stack, notebook: notebook ,
|
20
|
-
count: count, tag_count: tag_count ,
|
21
|
-
start_datetime: @register_time )
|
22
|
-
evnb = Evnb.create( time_id: @ct.id , ennb_id: ennblist.id )
|
23
|
-
rescue => ex
|
24
|
-
p ex.class
|
25
|
-
p ex.message
|
26
|
-
pp ex.backtrace
|
27
|
-
|
28
|
-
ennblist = nil
|
29
|
-
evnb = nil
|
30
|
-
end
|
31
|
-
else
|
32
|
-
current_ennblist = cur_ennblist.first.ennblist
|
33
|
-
hs = {:stack => stack, :count => count , :tag_count => tag_count }
|
34
|
-
value_hs = hs.reduce({}){ |hsx,item|
|
35
|
-
if current_ennblist[ item[0] ] != item[1]
|
36
|
-
hsx[ item[0] ] = item[1]
|
37
|
-
end
|
38
|
-
hsx
|
39
|
-
}
|
40
|
-
if value_hs.size > 0
|
41
|
-
if value_hs.all? { |item| item[1] != nil }
|
42
|
-
current_ennblist.update(value_hs)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
else
|
47
|
-
# ignore this case.
|
48
|
-
end
|
49
|
-
if ennblist
|
50
|
-
@hs_by_notebook[notebook] = ennblist
|
51
|
-
@hs_by_id[ennblist.id] = ennblist
|
52
|
-
end
|
53
|
-
ennblist
|
54
|
-
end
|
55
|
-
=end
|
56
11
|
end
|