arxutils_sqlite3 0.1.49 → 0.1.51

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.
data/Gemfile.lock ADDED
@@ -0,0 +1,112 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ arxutils_sqlite3 (0.1.51)
5
+ activerecord (~> 6.1)
6
+ activesupport
7
+ simpleoptparse
8
+ sqlite3
9
+ ykutils
10
+ ykxutils
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ activemodel (6.1.7)
16
+ activesupport (= 6.1.7)
17
+ activerecord (6.1.7)
18
+ activemodel (= 6.1.7)
19
+ activesupport (= 6.1.7)
20
+ activesupport (6.1.7)
21
+ concurrent-ruby (~> 1.0, >= 1.0.2)
22
+ i18n (>= 1.6, < 2)
23
+ minitest (>= 5.1)
24
+ tzinfo (~> 2.0)
25
+ zeitwerk (~> 2.3)
26
+ ast (2.4.2)
27
+ concurrent-ruby (1.1.10)
28
+ diff-lcs (1.5.0)
29
+ erubi (1.11.0)
30
+ erubis (2.7.0)
31
+ filex (0.1.7)
32
+ erubis
33
+ messagex
34
+ i18n (1.12.0)
35
+ concurrent-ruby (~> 1.0)
36
+ json (2.6.2)
37
+ messagex (0.1.5)
38
+ minitest (5.16.3)
39
+ parallel (1.22.1)
40
+ parser (3.1.2.1)
41
+ ast (~> 2.4.1)
42
+ rainbow (3.1.1)
43
+ rake (13.0.6)
44
+ regexp_parser (2.5.0)
45
+ rexml (3.2.5)
46
+ rspec (3.11.0)
47
+ rspec-core (~> 3.11.0)
48
+ rspec-expectations (~> 3.11.0)
49
+ rspec-mocks (~> 3.11.0)
50
+ rspec-core (3.11.0)
51
+ rspec-support (~> 3.11.0)
52
+ rspec-expectations (3.11.1)
53
+ diff-lcs (>= 1.2.0, < 2.0)
54
+ rspec-support (~> 3.11.0)
55
+ rspec-mocks (3.11.1)
56
+ diff-lcs (>= 1.2.0, < 2.0)
57
+ rspec-support (~> 3.11.0)
58
+ rspec-support (3.11.1)
59
+ rubocop (1.36.0)
60
+ json (~> 2.3)
61
+ parallel (~> 1.10)
62
+ parser (>= 3.1.2.1)
63
+ rainbow (>= 2.2.2, < 4.0)
64
+ regexp_parser (>= 1.8, < 3.0)
65
+ rexml (>= 3.2.5, < 4.0)
66
+ rubocop-ast (>= 1.20.1, < 2.0)
67
+ ruby-progressbar (~> 1.7)
68
+ unicode-display_width (>= 1.4.0, < 3.0)
69
+ rubocop-ast (1.21.0)
70
+ parser (>= 3.1.1.0)
71
+ rubocop-rake (0.6.0)
72
+ rubocop (~> 1.0)
73
+ rubocop-rspec (2.13.1)
74
+ rubocop (~> 1.33)
75
+ ruby-progressbar (1.11.0)
76
+ simpleoptparse (0.1.2)
77
+ sqlite3 (1.5.0-x86_64-linux)
78
+ tilt (2.0.11)
79
+ tzinfo (2.0.5)
80
+ concurrent-ruby (~> 1.0)
81
+ unicode-display_width (2.3.0)
82
+ webrick (1.7.0)
83
+ yard (0.9.28)
84
+ webrick (~> 1.7.0)
85
+ ykutils (0.1.6)
86
+ erubi
87
+ filex
88
+ tilt
89
+ ykxutils (0.1.5)
90
+ zeitwerk (2.6.0)
91
+
92
+ PLATFORMS
93
+ x86_64-linux
94
+
95
+ DEPENDENCIES
96
+ activerecord (~> 6.1)
97
+ activesupport
98
+ arxutils_sqlite3!
99
+ bundler
100
+ rake (~> 13.0)
101
+ rspec (~> 3.0)
102
+ rubocop (~> 1.7)
103
+ rubocop-rake
104
+ rubocop-rspec
105
+ simpleoptparse
106
+ sqlite3
107
+ yard
108
+ ykutils (> 0.1.3)
109
+ ykxutils (> 0.1.0)
110
+
111
+ BUNDLED WITH
112
+ 2.3.17
data/Rakefile CHANGED
@@ -1,104 +1,21 @@
1
1
  require "bundler/gem_tasks"
2
- require "rake/testtask"
2
+ # require "rake/testtask"
3
3
 
4
- Rake::TestTask.new do |t|
5
- t.libs << "test"
6
- end
4
+ # Rake::TestTask.new do |t|
5
+ # t.libs << "test"
6
+ # end
7
7
 
8
- #desc "Run test"
9
- #task default: :test
8
+ # desc "Run test"
9
+ # task default: :test
10
10
 
11
- # Defining a task called default that depends on the tasks setup, makeconfig, migrate, and acr.
11
+ require "rspec/core/rake_task"
12
12
 
13
- desc "setup copy_db_scheme copy_opts makeconfig make_migrate_script migrate acr"
14
- task default: %w[setup copy_db_scheme copy_opts makeconfig make_migrate_script migrate acr]
13
+ RSpec::Core::RakeTask.new(:spec)
15
14
 
16
- desc "delete setup copy_db_scheme copy_opts makeconfig make_migrate_script migrate acr"
17
- task bootstrap: %w[delete setup copy_db_scheme copy_opts makeconfig make_migrate_script migrate acr]
15
+ require "rubocop/rake_task"
18
16
 
19
- desc "setup makeconfig migrate acr"
20
- task scfma: %w[setup makeconfig migrate acr]
21
-
22
- desc "delete setup makeconfig"
23
- task dsc: %w[delete setup makeconfig]
24
-
25
- desc "delete setup"
26
- task ds: %w[delete setup]
27
-
28
- desc "setup"
29
- task s: %w[setup]
30
-
31
- desc "setup makeconfig"
32
- task sc: %w[setup makeconfig]
33
-
34
- desc "delete setup makeconfig migrate"
35
- task dscm: %w[delete setup makeconfig migrate]
36
-
37
- desc "setup makeconfig migrate"
38
- task scm: %w[setup makeconfig migrate]
39
-
40
- desc "delete setup makeconfig migrate acr"
41
- task dscma: %w[delete setup makeconfig migrate acr]
42
-
43
- desc "setup makeconfig migrate acr"
44
- task scma: %w[setup makeconfig migrate acr]
45
-
46
- desc "migrate acr"
47
- task ma: %w[migrate acr]
48
-
49
- desc "delete_db migrate acr"
50
- task bma: %w[delete_db migrate acr]
51
-
52
- desc "delete_db"
53
- task b: %w[delete_db]
54
-
55
- # コマンドラインで指定したクラス名を含むオプション指定用ハッシュの定義を含むRubyスクリ
56
- # プトファイルの生成
57
- desc "produce setting.yml, db_scheme.yml.sample and opts.rb.sample with class name Enop"
58
- task :setup do
59
- sh "bundle exec arxutils_sqlite3 --cmd=s --klass=Enop"
60
- end
61
-
62
- desc "copy from db_scheme.yml.sample to db_scheme.yml"
63
- task :copy_db_scheme do
64
- sh "bundle exec arxutils_sqlite3 --cmd=cds"
65
- end
66
-
67
- desc "copy from opts.rb.sample to opts.rb"
68
- task :copy_opts do
69
- sh "bundle exec arxutils_sqlite3 --cmd=co"
70
- end
71
-
72
- # DB構成情報の生成
73
- desc "produce sqlite3.yml"
74
- task :makeconfig do
75
- sh "bundle exec arxutils_sqlite3 --cmd=c"
76
- end
77
-
78
- # マイグレート用スクリプトファイルの生成
79
- desc "produce migration scripts"
80
- task :make_migrate_script do
81
- sh "bundle exec arxutils_sqlite3 --cmd=f --yaml=config/db_scheme.yml"
82
- end
83
- # マイグレートの実行
84
- desc "execute migration"
85
- task :migrate do
86
- sh "bundle exec arxutils_sqlite3 --cmd=m"
87
- end
88
-
89
- desc "call ActiveRecord instance method"
90
- task :acr do
91
- sh "bundle exec arxutils_sqlite3 --cmd=a"
92
- end
93
-
94
- desc "delete configuration files adn migration scripts and db files"
95
- task :delete do
96
- sh "bundle exec arxutils_sqlite3 --cmd=d"
97
- end
98
-
99
- desc "delete db files"
100
- task :delete_db do
101
- sh "bundle exec arxutils_sqlite3 --cmd=b"
102
- end
17
+ RuboCop::RakeTask.new
103
18
 
19
+ # task default: %i[spec rubocop]
104
20
 
21
+ require "arxutils_sqlite3/rake_task"
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = "utility functions for ActiveRecord."
13
13
  spec.homepage = "https://ykominami.github.io/arxutils_sqlite3/"
14
14
  spec.license = "MIT"
15
- spec.required_ruby_version = ">= 2.5.0"
15
+ spec.required_ruby_version = ">= 2.6.0"
16
16
 
17
17
  # spec.metadata["allowed_push_host"] = "TODO: Set to 'https://mygemserver.com'"
18
18
 
@@ -31,21 +31,21 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  spec.bindir = "exe"
33
33
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
34
- #p spec.executables
34
+ # p spec.executables
35
35
  spec.require_paths = ["lib"]
36
36
  spec.add_runtime_dependency "activesupport"
37
37
  # spec.add_runtime_dependency "erb"
38
38
  # spec.add_runtime_dependency "activerecord", "~> 4.2"
39
39
 
40
40
  spec.add_runtime_dependency "activerecord", "~> 6.1"
41
+ spec.add_runtime_dependency "simpleoptparse"
41
42
  spec.add_runtime_dependency "sqlite3"
42
43
  spec.add_runtime_dependency "ykutils"
43
44
  spec.add_runtime_dependency "ykxutils"
44
- spec.add_runtime_dependency "simpleoptparse"
45
45
  # spec.add_development_dependency "bundler", "~> 2.2.10"
46
46
  spec.add_development_dependency "bundler"
47
- spec.add_development_dependency "rspec" , "~> 3.0"
48
47
  spec.add_development_dependency "rake", "~> 13.0"
48
+ spec.add_development_dependency "rspec", "~> 3.0"
49
49
  spec.add_development_dependency "rubocop", "~> 1.7"
50
50
  spec.add_development_dependency "rubocop-rake"
51
51
  spec.add_development_dependency "rubocop-rspec"
data/config/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  *
2
+ !setting.yml
2
3
  !.gitignore
3
4
 
@@ -0,0 +1,2 @@
1
+ ---
2
+ :klass: Enop
data/exe/arxutils_sqlite3 CHANGED
@@ -10,7 +10,7 @@ config = Arxutils_Sqlite3::Config.new
10
10
 
11
11
  config.require_opts_file
12
12
 
13
- opts = @opts ? @opts : {}
13
+ opts = @opts || {}
14
14
 
15
15
  acrecord = opts[:acrecord]
16
16
  if acrecord
@@ -18,15 +18,14 @@ if acrecord
18
18
  basename = File.basename(filename)
19
19
 
20
20
  begin
21
- require "#{basename}"
22
- rescue LoadError => ex
23
- #pp ex.message
21
+ require basename.to_s
22
+ rescue LoadError
23
+ # pp ex.message
24
24
  end
25
25
  end
26
26
 
27
27
  opts[:db_dir] = Arxutils_Sqlite3::Config::DB_DIR
28
28
 
29
- klass = nil
30
29
  setting = config.load_setting_yaml_file
31
30
  klass = setting[:klass]
32
31
 
@@ -50,7 +49,7 @@ cli = Arxutils_Sqlite3::Cli.new(config, dbconfig, env)
50
49
 
51
50
  case opts["cmd"]
52
51
  when "s"
53
- #config.check_file_exist(Arxutils_Sqlite3::Config::SAMPLE_DEST_OPTS_FILE, banner, 10)
52
+ # config.check_file_exist(Arxutils_Sqlite3::Config::SAMPLE_DEST_OPTS_FILE, banner, 10)
54
53
 
55
54
  if opts["klass"].nil? || opts["klass"].strip == ""
56
55
  puts banner
@@ -22,7 +22,7 @@ module Arxutils_Sqlite3
22
22
  @data = data
23
23
 
24
24
  # スキーマ設定の:itemsの値を展開後格納するためのStructクラス
25
- #@field ||= Struct.new("Field", :name, :type, :null)
25
+ # @field ||= Struct.new("Field", :name, :type, :null)
26
26
  @field ||= Struct.new(:name, :type, :null)
27
27
 
28
28
  @data[:ary] = if @data[:items]
@@ -35,7 +35,7 @@ module Arxutils_Sqlite3
35
35
  # テンプレートファイルを元にした変換結果を返す
36
36
  def create
37
37
  scope = Object.new
38
- scope.instance_variable_set(:@data , @data)
38
+ scope.instance_variable_set(:@data, @data)
39
39
  Ykutils::Erubyx.erubi_render_with_template_file(@fname, scope)
40
40
  end
41
41
  end
@@ -8,15 +8,15 @@ module Arxutils_Sqlite3
8
8
  end
9
9
 
10
10
  def setup(klass)
11
- p "make_config_directory"
11
+ # p "make_config_directory"
12
12
  @config.make_config_directory
13
- p "setup_db_scheme_file"
13
+ # p "setup_db_scheme_file"
14
14
  @config.setup_db_scheme_file
15
- p "setup_opts_file(#{klass})"
15
+ # p "setup_opts_file(#{klass})"
16
16
  @config.setup_opts_file(klass)
17
- p "setup_setting_yaml_file(#{klass})"
17
+ # p "setup_setting_yaml_file(#{klass})"
18
18
  @config.setup_setting_yaml_file(klass)
19
- #db_scheme_ary = nil
19
+ # db_scheme_ary = nil
20
20
  end
21
21
 
22
22
  def copy_db_scheme
@@ -29,23 +29,21 @@ module Arxutils_Sqlite3
29
29
  @config.copy_opts_file
30
30
  end
31
31
 
32
- def makeconfig(acrecord, banner, exit_code, opts)
32
+ def makeconfig(acrecord, _banner, _exit_code, opts)
33
33
  db_scheme_ary = nil
34
34
  dbconfig_path = @config.make_dbconfig_path(@dbconfig)
35
- #@config.check_file_exist(dbconfig_path, banner, exit_code)
35
+ # @config.check_file_exist(dbconfig_path, banner, exit_code)
36
36
  mig = @config.prepare_for_migrate(db_scheme_ary, dbconfig_path, @dbconfig, acrecord)
37
37
  mig.make_dbconfig(opts)
38
38
  end
39
39
 
40
40
  def setup_for_migrate(yaml_pn, acrecord, klass)
41
- db_scheme_ary = YAML.load_file( yaml_pn )
41
+ db_scheme_ary = YAML.load_file(yaml_pn)
42
42
  dbconfig_path = @config.make_dbconfig_path(@dbconfig)
43
43
 
44
44
  dest_dbsetup_file = @config.get_dest_dbsetup_file
45
45
  @config.make_dbsetup_file(db_scheme_ary, acrecord, klass, dest_dbsetup_file)
46
46
 
47
- # migrate用スクリプトの出力先ディレクトリ名
48
- migrate_dir = @config.get_migrate_dir
49
47
  # マイグレーション用スクリプトの生成、acrecordのクラス定義ファイルの生成
50
48
  mig = @config.prepare_for_migrate(db_scheme_ary, dbconfig_path, @dbconfig, acrecord)
51
49
  mig.output
@@ -55,7 +53,7 @@ module Arxutils_Sqlite3
55
53
  # migrate用スクリプトの出力先ディレクトリ名
56
54
  migrate_dir = @config.get_migrate_dir
57
55
 
58
- connect_time = Arxutils_Sqlite3::Dbutil::Dbconnect.db_connect(@config, @dbconfig, @env)
56
+ Arxutils_Sqlite3::Dbutil::Dbconnect.db_connect(@config, @dbconfig, @env)
59
57
 
60
58
  # マイグレーション実行
61
59
  ActiveRecord::MigrationContext.new(migrate_dir, ActiveRecord::SchemaMigration).up
@@ -83,7 +81,7 @@ module Arxutils_Sqlite3
83
81
 
84
82
  def rm_dbconfig
85
83
  dbconfig_path = @config.make_dbconfig_path(@dbconfig)
86
- #p dbconfig_path
84
+ # p dbconfig_path
87
85
  FileUtils.rm_f(dbconfig_path)
88
86
  end
89
87
  end
@@ -23,85 +23,86 @@ module Arxutils_Sqlite3
23
23
  TEMPLATE_DIR = Arxutils_Sqlite3::TOP_DIR.join("template")
24
24
  # リレーションテンプレートディレクトリへのパス
25
25
  TEMPLATE_ACRECORD_DIR = TEMPLATE_DIR.join("acrecord")
26
- TEMPLATE_CONFIG_DIR = TEMPLATE_DIR.join( CONFIG_DIR )
26
+ TEMPLATE_CONFIG_DIR = TEMPLATE_DIR.join(CONFIG_DIR)
27
27
  DB_SCHEME_DIR = TEMPLATE_ACRECORD_DIR.join("db_scheme")
28
28
  DB_SCHEME_FILE = DB_SCHEME_DIR.join("db_scheme.yml")
29
29
  SAMPLE_DB_SCHEME_FILE = CONFIG_DIR.join("db_scheme.yml.sample")
30
30
  DB_SCHEME_FILE_NAME = "db_scheme.yml".freeze
31
- DB_SCHEME_FILE_NAME_2 = "db_scheme".freeze
32
- OPTS_FILE_NAME = "opts.rb".freeze
31
+ DB_SCHEME_FILE_NAME_B = "db_scheme".freeze
32
+ OPTS_FILE_NAME = "opts.tmpl".freeze
33
33
  SAMPLE_OPTS_FILE_NAME = "opts.rb.sample".freeze
34
- OPTS_FILE_NAME_2 = "opts".freeze
35
- DBSETUP_FILE_NAME = "dbsetup.rb".freeze
36
- DBSETUP_FILE_NAME_2 = "dbsetup".freeze
34
+ OPTS_FILE_NAME_B = "opts".freeze
35
+ DEST_OPTS_FILE_NAME = "opts.rb".freeze
36
+ DEST_OPTS_FILE_NAME_B = "opts".freeze
37
+ DBSETUP_FILE_NAME = "dbsetup.tmpl".freeze
38
+ DBSETUP_FILE_NAME_B = "dbsetup".freeze
39
+ DEST_DBSETUP_FILE_NAME = "dbsetup.rb".freeze
37
40
  SETTING_YAML_FILE_NAME = "setting.yml".freeze
38
- DEST_CONFIG_DIR = Pathname.new( CONFIG_DIR )
41
+ DEST_CONFIG_DIR = Pathname.new(CONFIG_DIR)
39
42
  OPTS_FILE = DB_SCHEME_DIR.join(OPTS_FILE_NAME)
40
43
  SAMPLE_OPTS_FILE = CONFIG_DIR.join(SAMPLE_OPTS_FILE_NAME)
41
44
  # 変換先Dbsetupクラス定義のRubyスクリプトファイルへのパス
42
45
  DBSETUP_FILE = DB_SCHEME_DIR.join(DBSETUP_FILE_NAME)
43
46
  # 変換先optsファイル(Rubyスクリプトファイル)へのパス
44
- DEST_OPTS_FILE = DEST_CONFIG_DIR.join(OPTS_FILE_NAME)
45
- DEST_OPTS_FILE_2 = DEST_CONFIG_DIR.join(OPTS_FILE_NAME_2)
47
+ DEST_OPTS_FILE = DEST_CONFIG_DIR.join(DEST_OPTS_FILE_NAME)
48
+ DEST_OPTS_FILE_B = DEST_CONFIG_DIR.join(OPTS_FILE_NAME_B)
46
49
  # 変換先Dbsetupクラス定義のRubyスクリプトファイルへのパス
47
- DEST_DBSETUP_FILE = DEST_CONFIG_DIR.join(DBSETUP_FILE_NAME)
50
+ DEST_DBSETUP_FILE = DEST_CONFIG_DIR.join(DEST_DBSETUP_FILE_NAME)
48
51
  # 変換先Dbsetupクラス定義のRubyスクリプトファイル(拡張子無し)へのパス
49
- DEST_DBSETUP_FILE_2 = DEST_CONFIG_DIR.join(DBSETUP_FILE_NAME_2)
52
+ DEST_DBSETUP_FILE_B = DEST_CONFIG_DIR.join(DBSETUP_FILE_NAME_B)
50
53
  DEST_DB_SCHEME_FILE = DEST_CONFIG_DIR.join(DB_SCHEME_FILE_NAME)
51
54
  # 変換後DBスキームファイル(拡張子無し)へのパス
52
- DEST_DB_SCHEME_FILE_2 = DEST_CONFIG_DIR.join(DB_SCHEME_FILE_NAME_2)
55
+ DEST_DB_SCHEME_FILE_B = DEST_CONFIG_DIR.join(DB_SCHEME_FILE_NAME_B)
53
56
  SETTING_YAML_FILE = CONFIG_DIR.join(SETTING_YAML_FILE_NAME)
54
57
  DB_PN = Pathname.new(DB_DIR)
55
58
  # migrateディレクトリへのパス
56
59
  MIGRATE_DIR = DB_PN.join(MIGRATE_BASE_DIR)
57
60
 
61
+ EXCLUDE_FILES = %w[SETTING_YAML_FILE_NAME].freeze
62
+
58
63
  # DB構成ファイル格納ディレクトリの作成
59
64
  def make_config_directory
60
- p "config make_config_directory"
65
+ # p "config make_config_directory"
61
66
  FileUtils.mkdir_p(CONFIG_DIR)
62
67
  end
63
68
 
64
69
  # DBスキームファイルのサンプルファイルコピー
65
70
  def setup_db_scheme_file
66
- p "config setup_db_scheme_file"
67
- p "DB_SCHEME_FILE=#{DB_SCHEME_FILE}"
68
- p "SAMPLE_DB_SCHEME_FILE=#{SAMPLE_DB_SCHEME_FILE}"
69
- FileUtils.cp(DB_SCHEME_FILE, SAMPLE_DB_SCHEME_FILE)
71
+ # p "config setup_db_scheme_file"
72
+ # p "DB_SCHEME_FILE=#{DB_SCHEME_FILE}"
73
+ # p "SAMPLE_DB_SCHEME_FILE=#{SAMPLE_DB_SCHEME_FILE}"
74
+ FileUtils.cp(DB_SCHEME_FILE, SAMPLE_DB_SCHEME_FILE)
70
75
  end
71
76
 
72
77
  # DBスキームファイルが存在しなければ、サンプルファイルをDBスキームファイルとしてコピー
73
78
  def copy_db_scheme_file
74
- if !File.exist?(DEST_DB_SCHEME_FILE)
75
- FileUtils.cp(SAMPLE_DB_SCHEME_FILE, DEST_DB_SCHEME_FILE)
76
- end
79
+ return if File.exist?(DEST_DB_SCHEME_FILE)
80
+
81
+ FileUtils.cp(SAMPLE_DB_SCHEME_FILE, DEST_DB_SCHEME_FILE)
77
82
  end
78
83
 
79
84
  # optsファイル(Rubyスクリプトファイル)のサンプルファイル書き込み
80
85
  def setup_opts_file(klass)
81
86
  scope = Object.new
82
- hash = {klass: klass}
87
+ hash = { klass: klass }
83
88
  result_content = Ykutils::Erubyx.erubi_render_with_template_file(OPTS_FILE, scope, hash)
84
- File.open(SAMPLE_OPTS_FILE, "w"){|file|
85
- file.write(result_content)
86
- }
89
+ File.write(SAMPLE_OPTS_FILE, result_content)
87
90
  end
88
91
 
89
92
  # optsファイルが存在しなければ、サンプルファイルをoptsファイルとしてコピー
90
93
  def copy_opts_file
91
- if !File.exist?(DEST_OPTS_FILE)
92
- p "exist? #{File.exist?(DEST_OPTS_FILE)}"
93
- p "copy SAMPLE_OPTS_FILE(#{SAMPLE_OPTS_FILE}) to DEST_OPTS_FILE(#{DEST_OPTS_FILE})"
94
- FileUtils.cp(SAMPLE_OPTS_FILE, DEST_OPTS_FILE)
95
- end
94
+ return if File.exist?(DEST_OPTS_FILE)
95
+
96
+ # p "exist? #{File.exist?(DEST_OPTS_FILE)}"
97
+ # p "copy SAMPLE_OPTS_FILE(#{SAMPLE_OPTS_FILE}) to DEST_OPTS_FILE(#{DEST_OPTS_FILE})"
98
+ FileUtils.cp(SAMPLE_OPTS_FILE, DEST_OPTS_FILE)
96
99
  end
97
100
 
98
101
  # setting.ymlへの出力
99
102
  def setup_setting_yaml_file(klass)
100
- hash = { "klass": klass }
103
+ hash = { klass: klass }
101
104
  content = YAML.dump(hash)
102
- File.open(SETTING_YAML_FILE, "w"){|file|
103
- file.write(content)
104
- }
105
+ File.write(SETTING_YAML_FILE, content)
105
106
  end
106
107
 
107
108
  # DB構成ファイルの作成
@@ -112,13 +113,13 @@ module Arxutils_Sqlite3
112
113
 
113
114
  # optsファイル(Rubyスクリプトファイル)のrequire
114
115
  def require_opts_file
115
- if DEST_OPTS_FILE.exist?
116
- opts_file = File.join("./" , DEST_OPTS_FILE_2.to_s)
117
- begin
118
- require opts_file
119
- rescue LoadError => ex
120
- #pp ex.message
121
- end
116
+ return unless DEST_OPTS_FILE.exist?
117
+
118
+ opts_file = File.join("./", DEST_OPTS_FILE_B.to_s)
119
+ begin
120
+ require opts_file
121
+ rescue LoadError
122
+ # pp ex.message
122
123
  end
123
124
  end
124
125
 
@@ -127,40 +128,38 @@ module Arxutils_Sqlite3
127
128
  setting = {}
128
129
  # settingファイル
129
130
  setting_yaml_file = SETTING_YAML_FILE
130
- if setting_yaml_file.exist?
131
- setting = YAML.load_file( setting_yaml_file )
132
- end
131
+ setting = YAML.load_file(setting_yaml_file) if setting_yaml_file.exist?
133
132
  setting
134
133
  end
135
134
 
136
135
  # Dbsetupファイル(Rubyスクリプトファイル)のrequire
137
136
  def require_dbsetup_file
138
- dbsetup_file = File.join(".", get_dest_dbsetup_file_2.to_s)
137
+ dbsetup_file = File.join(".", get_dest_dbsetup_file_b.to_s)
139
138
  begin
140
139
  require dbsetup_file
141
- rescue LoadError => ex
140
+ rescue LoadError
142
141
  # pp ex.message
143
142
  end
144
143
  end
145
144
 
146
145
  # 指定ファイルの存在確認
147
146
  def check_file_exist(file_pn, banner, exit_code)
148
- if file_pn.exist?
149
- puts "#{file_pn} exists!"
150
- puts banner
151
- exit exit_code
152
- end
147
+ return unless file_pn.exist?
148
+
149
+ puts "#{file_pn} exists!"
150
+ puts banner
151
+ exit exit_code
153
152
  end
154
153
 
155
154
  # 指定ファイルの非存在確認
156
155
  def check_file_not_exist(file_pn, banner, exit_code)
157
- if !file_pn.exist?
158
- puts "#{file_pn} does not exists!"
159
- puts banner
160
- exit exit_code
161
- end
156
+ return if file_pn.exist?
157
+
158
+ puts "#{file_pn} does not exists!"
159
+ puts banner
160
+ exit exit_code
162
161
  end
163
-
162
+
164
163
  # 変換先optsファイル(Rubyスクリプトファイル)へのパス
165
164
  def get_dest_opts_file
166
165
  DEST_OPTS_FILE
@@ -175,6 +174,7 @@ module Arxutils_Sqlite3
175
174
  def get_migrate_dir
176
175
  MIGRATE_DIR
177
176
  end
177
+
178
178
  # コンフィグディレクトリへのパス
179
179
  def get_config_dir
180
180
  CONFIG_DIR
@@ -201,13 +201,13 @@ module Arxutils_Sqlite3
201
201
  end
202
202
 
203
203
  # 変換先Dbsetupクラス定義のRubyスクリプトファイル(拡張子無し)へのパス
204
- def get_dest_dbsetup_file_2
205
- DEST_DBSETUP_FILE_2
204
+ def get_dest_dbsetup_file_b
205
+ DEST_DBSETUP_FILE_B
206
206
  end
207
207
 
208
208
  # 変換後DBスキームファイル名(拡張子無し)
209
209
  def get_dest_db_scheme_file
210
- DEST_DB_SCHEME_FILE_2
210
+ DEST_DB_SCHEME_FILE_B
211
211
  end
212
212
 
213
213
  # DBログファイルの作成
@@ -233,14 +233,12 @@ module Arxutils_Sqlite3
233
233
 
234
234
  # migrateの準備
235
235
  def prepare_for_migrate(db_scheme_ary, dbconfig_dest_path, dbconfig, acrecord)
236
- #db_dir = config.DB_DIR
237
- db_dir = get_db_dir
238
236
  # DB構成ファイルの出力先ディレクトリ
239
237
  dbconfig_src_fname = "#{dbconfig}.tmpl"
240
238
  # migrate用スクリプトの出力先ディレクトリ名
241
239
  migrate_dir = get_migrate_dir
242
240
 
243
- mig = Migrate.new(
241
+ Migrate.new(
244
242
  self,
245
243
  dbconfig_dest_path,
246
244
  dbconfig_src_fname,
@@ -254,14 +252,16 @@ module Arxutils_Sqlite3
254
252
  src_dbsetup_file = get_src_dbsetup_file
255
253
 
256
254
  scope = Object.new
257
- hash0 = {module_name: acrecord[:module].join("::")}
258
- hash = db_scheme_ary[0].merge( hash0 )
255
+ hash0 = { module_name: acrecord[:module].join("::") }
256
+ hash = db_scheme_ary[0].merge(hash0)
259
257
  hash["klass"] = klass
260
258
  result_content = Ykutils::Erubyx.erubi_render_with_template_file(src_dbsetup_file, scope, hash)
261
259
 
262
- File.open(dest_dbsetup_file, "w"){|file|
263
- file.write(result_content)
264
- }
260
+ File.write(dest_dbsetup_file, result_content)
261
+ end
262
+
263
+ def exclude_file?(fname)
264
+ EXCLUDE_FILES.index(fname) != nil
265
265
  end
266
266
  end
267
- end
267
+ end