arxutils_sqlite3 0.1.49 → 0.1.50

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.
@@ -6,28 +6,6 @@ require "active_record"
6
6
  require "sqlite3"
7
7
  require "ykxutils"
8
8
 
9
- def require_x(path)
10
- require path
11
- rescue StandardError => e
12
- p "1 request_x"
13
- p e
14
- rescue LoadError => e
15
- p "21 request_x"
16
- p e
17
- rescue NotImplementedError => e
18
- p "22 request_x"
19
- p e
20
- rescue SyntaxError => e
21
- p "23 request_x"
22
- p e
23
- rescue ScriptError => e
24
- p "20 request_x"
25
- p e
26
- rescue Exception => e
27
- p "9 request_x"
28
- p e
29
- end
30
-
31
9
  module Arxutils_Sqlite3
32
10
  module Dbutil
33
11
  # DB操作用ユーティリティクラス
@@ -64,14 +42,14 @@ module Arxutils_Sqlite3
64
42
  def connect
65
43
  unless @connect_time
66
44
  begin
67
- #p "@dbconfig_dest_path=#{@dbconfig_dest_path}"
45
+ # p "@dbconfig_dest_path=#{@dbconfig_dest_path}"
68
46
  dbconfig = Ykxutils.yaml_load_file_compati(@dbconfig_dest_path)
69
- #p "dbconfig=#{dbconfig}"
70
- #p "@env=#{@env}"
47
+ # p "dbconfig=#{dbconfig}"
48
+ # p "@env=#{@env}"
71
49
  ActiveRecord::Base.establish_connection(dbconfig[@env])
72
50
  ActiveRecord::Base.logger = Logger.new(@log_path)
73
51
  @connect_time = DateTime.now.new_offset
74
- rescue => ex
52
+ rescue StandardError => ex
75
53
  p ex.message
76
54
  end
77
55
  end
@@ -3,6 +3,5 @@ require_relative "dbutil/dbconnect"
3
3
  module Arxutils_Sqlite3
4
4
  # DB操作用ユーティリティクラス
5
5
  module Dbutil
6
- #
7
6
  end
8
7
  end
@@ -142,10 +142,10 @@ module Arxutils_Sqlite3
142
142
  hier = @hier_klass.find_by(child_id: num)
143
143
  level = hier.level
144
144
  parent_id = hier.parent_id
145
- base = @base_klass.find_by(ord_id: num)
145
+ # base = @base_klass.find_by(ord_id: num)
146
146
 
147
- parent_base = @base_klass.find_by(ord_id: parent_id)
148
- parent_hier_string = parent_base.__send__ @hier_symbol
147
+ # parent_base = @base_klass.find_by(ord_id: parent_id)
148
+ # parent_hier_string = parent_base.__send__ @hier_symbol
149
149
 
150
150
  # 属する子を探す
151
151
  children_hier = @hier_klass.where(parent_id: num)
@@ -1,21 +1,22 @@
1
- #require "arxutils_sqlite3"
1
+ # require "arxutils_sqlite3"
2
2
  require "ykutils"
3
3
  require "fileutils"
4
- #require "active_support"
4
+ # require "active_support"
5
5
  require "active_record"
6
6
  require "active_record/migration"
7
7
  require "pp"
8
8
 
9
9
  # ActiveRecord用ユーティリティモジュール
10
10
  module Arxutils_Sqlite3
11
- ##
12
- # migrateに必要なファイルをテンプレートから作成し、migarteを実行する
11
+ ##
12
+ # migrateに必要なファイルをテンプレートから作成し、migarteを実行する
13
13
  class Migrate
14
14
  attr_reader :migrate_dir
15
+
15
16
  # migrate用スクリプトファイル名の先頭の番号の間隔
16
17
  FILENAME_COUNTER_STEP = 10
17
18
  # DB接続までの初期化を行うDbinitクラスのインスタンス
18
- #attr_reader :dbinit
19
+ # attr_reader :dbinit
19
20
 
20
21
  # migrate用のスクリプトの生成、migrateの実行を行うmigratexの生成
21
22
  def initialize(
@@ -25,7 +26,9 @@ module Arxutils_Sqlite3
25
26
  db_scheme_ary,
26
27
  acrecord_config,
27
28
  migrate_dir
28
- )
29
+ )
30
+ # アプリ構成情報
31
+ @config = config
29
32
  # DB格納ディレクトリ名
30
33
  @db_dir = config.get_db_dir
31
34
  # DB構成ファイルの出力先ディレクトリ
@@ -39,7 +42,7 @@ module Arxutils_Sqlite3
39
42
  @src_path = config.get_template_acrecord_dir
40
43
  # 構成ファイル格納ディレクトリ
41
44
  @src_config_path = config.get_template_config_dir
42
- # @src_config_path = Arxutils_Sqlite3::TEMPLATE_CONFIG_DIR
45
+ # @src_config_path = Arxutils_Sqlite3::TEMPLATE_CONFIG_DIR
43
46
  # データベーススキーマ定義配列
44
47
  @db_scheme_ary = db_scheme_ary
45
48
  # リレーション指定
@@ -59,7 +62,11 @@ module Arxutils_Sqlite3
59
62
  end
60
63
  end
61
64
  Dir.glob(File.join(@dest_config_dir, "*")).each do |x|
62
- FileUtils.rm(x) if File.file?(x)
65
+ basename = File.basename(x)
66
+ ret = !@config.exclude_file?( basename )
67
+ ret_file = File.file?(x)
68
+ ret2 = (ret_file && ret)
69
+ FileUtils.rm(x) if ret2
63
70
  end
64
71
  Dir.glob(File.join(@db_dir, "*")).each do |x|
65
72
  # puts x
@@ -152,7 +159,8 @@ module Arxutils_Sqlite3
152
159
  def make_dbconfig(data)
153
160
  content = convert(data, @src_config_path, @dbconfig_src_fname)
154
161
  File.open(
155
- @dbconfig_dest_path, "w:utf-8") do |f|
162
+ @dbconfig_dest_path, "w:utf-8"
163
+ ) do |f|
156
164
  f.puts(content)
157
165
  end
158
166
  end
@@ -185,23 +193,22 @@ module Arxutils_Sqlite3
185
193
 
186
194
  # スキーマ設定からmigarte用スクリプトの内容を生成
187
195
  def make_script_group(data)
188
- #p data
189
- data[:flist].map {
190
- |kind|
196
+ # p data
197
+ data[:flist].map do |kind|
191
198
  [kind,
192
- convert(data, @src_path, "#{kind}.tmpl"),
193
- data[:classname_downcase]
194
- ] }
199
+ convert(data, @src_path, "#{kind}.tmpl"),
200
+ data[:classname_downcase]]
201
+ end
195
202
  end
196
203
 
197
204
  # migrationのスクリプトをファイル出力する
198
205
  def output_script(idy, kind, content, classname_downcase)
199
206
  additional = case kind
200
- when "base", "noitem"
201
- ""
202
- else
203
- kind
204
- end
207
+ when "base", "noitem"
208
+ ""
209
+ else
210
+ kind
211
+ end
205
212
  fname = File.join(@migrate_dir, format("%03d_create_%s%s.rb", idy, additional, classname_downcase))
206
213
  File.open(fname, "w", **{ encoding: Encoding::UTF_8 }) do |f|
207
214
  f.puts(content)
@@ -4,7 +4,8 @@ module Arxutils_Sqlite3
4
4
  def self.make_log_path(db_dir, dbconfig)
5
5
  log_path = ""
6
6
  log_fname = Dbutil::Dbconnect.make_log_file_name(
7
- dbconfig, Config::DATABASELOG)
7
+ dbconfig, Config::DATABASELOG
8
+ )
8
9
  if db_dir && log_fname
9
10
  # DB用ログファイルへのパス
10
11
  log_path = File.join(db_dir, log_fname)
@@ -1,4 +1,4 @@
1
1
  module Arxutils_Sqlite3
2
2
  # バージョン番号
3
- VERSION = "0.1.49".freeze
3
+ VERSION = "0.1.50".freeze
4
4
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "ykutils"
3
4
  require "ykxutils"
4
5
 
@@ -24,4 +25,4 @@ require_relative "arxutils_sqlite3/transactstate"
24
25
  require_relative "arxutils_sqlite3/hier"
25
26
  require_relative "arxutils_sqlite3/migrate"
26
27
  require_relative "arxutils_sqlite3/util"
27
- require_relative "dbacrecord"
28
+ require_relative "dbacrecord"
@@ -0,0 +1,68 @@
1
+ # Defining a task called default that depends on the tasks setup, makeconfig, migrate, and acr.
2
+ require "arxutils_sqlite3"
3
+ config = Arxutils_Sqlite3::Config.new
4
+
5
+ klass = nil
6
+ setting = config.load_setting_yaml_file
7
+ klass = setting[:klass]
8
+
9
+ desc "setup copy_db_scheme copy_opts makeconfig make_migrate_script migrate acr"
10
+ task default: %w[setup copy_db_scheme copy_opts makeconfig make_migrate_script migrate acr]
11
+
12
+ desc "delete setup copy_db_scheme copy_opts makeconfig make_migrate_script migrate acr"
13
+ task bootstrap: %w[delete setup copy_db_scheme copy_opts makeconfig make_migrate_script migrate acr]
14
+
15
+ desc "migrate acr"
16
+ task ma: %w[migrate acr]
17
+
18
+ desc "delete_db"
19
+ task b: %w[delete_db]
20
+
21
+ # コマンドラインで指定したクラス名を含むオプション指定用ハッシュの定義を含むRubyスクリ
22
+ # プトファイルの生成
23
+ desc "produce setting.yml, db_scheme.yml.sample and opts.rb.sample with class name #{klass}"
24
+ task :setup do
25
+ sh "bundle exec arxutils_sqlite3 --cmd=s --klass=#{klass}"
26
+ end
27
+
28
+ desc "copy from db_scheme.yml.sample to db_scheme.yml"
29
+ task :copy_db_scheme do
30
+ sh "bundle exec arxutils_sqlite3 --cmd=cds"
31
+ end
32
+
33
+ desc "copy from opts.rb.sample to opts.rb"
34
+ task :copy_opts do
35
+ sh "bundle exec arxutils_sqlite3 --cmd=co"
36
+ end
37
+
38
+ # DB構成情報の生成
39
+ desc "produce sqlite3.yml"
40
+ task :makeconfig do
41
+ sh "bundle exec arxutils_sqlite3 --cmd=c"
42
+ end
43
+
44
+ # マイグレート用スクリプトファイルの生成
45
+ desc "produce migration scripts"
46
+ task :make_migrate_script do
47
+ sh "bundle exec arxutils_sqlite3 --cmd=f --yaml=config/db_scheme.yml"
48
+ end
49
+ # マイグレートの実行
50
+ desc "execute migration"
51
+ task :migrate do
52
+ sh "bundle exec arxutils_sqlite3 --cmd=m"
53
+ end
54
+
55
+ desc "call ActiveRecord instance method"
56
+ task :acr do
57
+ sh "bundle exec arxutils_sqlite3 --cmd=a"
58
+ end
59
+
60
+ desc "delete configuration files adn migration scripts and db files"
61
+ task :delete do
62
+ sh "bundle exec arxutils_sqlite3 --cmd=d"
63
+ end
64
+
65
+ desc "delete db files"
66
+ task :delete_db do
67
+ sh "bundle exec arxutils_sqlite3 --cmd=b"
68
+ end
@@ -2,8 +2,8 @@ class Dbsetup
2
2
  def initialize(connect_time)
3
3
  @connect_time = connect_time
4
4
  @ct = <%= klass %>::Dbutil::Countdatetime.create( countdatetime: @connect_time )
5
- @hs_by_notebook = {}
6
- @hs_by_id = {}
5
+ @hs_by_notebook = Hash.new
6
+ @hs_by_id = Hash.new
7
7
  end
8
8
  =begin
9
9
  # 指定stack(文字列)にノートブック(文字列)、ノートブック数、タグ数を追加
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arxutils_sqlite3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.49
4
+ version: 0.1.50
5
5
  platform: ruby
6
6
  authors:
7
7
  - yasuo kominami
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-14 00:00:00.000000000 Z
11
+ date: 2022-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '6.1'
41
41
  - !ruby/object:Gem::Dependency
42
- name: sqlite3
42
+ name: simpleoptparse
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: ykutils
56
+ name: sqlite3
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: ykxutils
70
+ name: ykutils
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: simpleoptparse
84
+ name: ykxutils
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -109,33 +109,33 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: rspec
112
+ name: rake
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '3.0'
117
+ version: '13.0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '3.0'
124
+ version: '13.0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: rake
126
+ name: rspec
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '13.0'
131
+ version: '3.0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '13.0'
138
+ version: '3.0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rubocop
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -206,14 +206,15 @@ files:
206
206
  - CHANGELOG.md
207
207
  - CODE_OF_CONDUCT.md
208
208
  - Gemfile
209
+ - Gemfile.lock
209
210
  - LICENSE
210
- - LICENSE.txt
211
211
  - README.md
212
212
  - Rakefile
213
213
  - arxutils_sqlite3.gemspec
214
214
  - bin/console
215
215
  - bin/setup
216
216
  - config/.gitignore
217
+ - config/setting.yml
217
218
  - exe/arxutils_sqlite3
218
219
  - lib/arxutils_sqlite3.rb
219
220
  - lib/arxutils_sqlite3/arx.rb
@@ -226,6 +227,7 @@ files:
226
227
  - lib/arxutils_sqlite3/transactstate.rb
227
228
  - lib/arxutils_sqlite3/util.rb
228
229
  - lib/arxutils_sqlite3/version.rb
230
+ - lib/arxutils_sqlite3_rake_task.rb
229
231
  - lib/dbacrecord.rb
230
232
  - lib/template/acrecord/acrecord.tmpl
231
233
  - lib/template/acrecord/acrecord_count.tmpl
@@ -235,9 +237,9 @@ files:
235
237
  - lib/template/acrecord/current.tmpl
236
238
  - lib/template/acrecord/db_scheme/db_scheme.yml
237
239
  - lib/template/acrecord/db_scheme/db_scheme.yml.sample
238
- - lib/template/acrecord/db_scheme/dbsetup.rb
239
- - lib/template/acrecord/db_scheme/opts.rb
240
+ - lib/template/acrecord/db_scheme/dbsetup.tmpl
240
241
  - lib/template/acrecord/db_scheme/opts.rb.sample
242
+ - lib/template/acrecord/db_scheme/opts.tmpl
241
243
  - lib/template/acrecord/invalid.tmpl
242
244
  - lib/template/acrecord/noitem.tmpl
243
245
  - lib/template/config/mysql.tmpl
@@ -256,7 +258,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
256
258
  requirements:
257
259
  - - ">="
258
260
  - !ruby/object:Gem::Version
259
- version: 2.5.0
261
+ version: 2.6.0
260
262
  required_rubygems_version: !ruby/object:Gem::Requirement
261
263
  requirements:
262
264
  - - ">="
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2022 yasuo kominami
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.