arxutils_sqlite3 0.1.60 → 0.1.61

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba5f7070ec93ff0ea6f25e7b66fa8f8fb74860ff477adb367fe653ad4853dd70
4
- data.tar.gz: fe71d7c10f6ad03081531fc0f69d532b99a66bc7b2be25a13b5535803dc04ab0
3
+ metadata.gz: 17be2bd82bd6e648b09f7e49c16ef003b4c61404796620641a1f7f1a6a63e704
4
+ data.tar.gz: 2407844b80f1b15b74781a71a88f134c1538dc0900cc2a8cd71d8c621e4f4217
5
5
  SHA512:
6
- metadata.gz: 93fa710fff1d92e873823ac196de7436e66e7b7999d3a4291670c260dd6a338ab11ef30ebc58e769a4a04a86fe895cf0300c6698a71ad2a7486d54ad4ed7285b
7
- data.tar.gz: 502b418dc1faaf99a295a53dc24e642464ea9f4c1052e7b85995914bfc9f4b19eec8b1a6d9a69cb2867d33f659449ee13b393fd2923d76bb28fb21191f92e1e9
6
+ metadata.gz: 8de44db00668e653da29e044f0b4b3bd25256aa7ae466b6747a3417da40ae081954dd6bf45250ce6ea5978393a55620d6e0c75289c0607f8de690a2aca154024
7
+ data.tar.gz: b5c8de59e6bb28ac0c41ad1e0320ab98982107434141c57a25e030a5261aed9ed0ed940efc6d8a0074a426c76709b167568b342e4332a664d57e53aace842cc6
data/Gemfile CHANGED
@@ -5,27 +5,27 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in arxutils_sqlite3.gemspec
6
6
  gemspec
7
7
 
8
- gem 'activesupport'
9
8
  gem 'activerecord', '~> 6.1'
10
- gem 'sqlite3'
9
+ gem 'activesupport'
10
+ gem 'bundler'
11
+ gem 'rake', '~> 13.0'
11
12
  gem 'simpleoptparse'
13
+ gem 'sqlite3'
12
14
  gem 'ykutils'
13
15
  gem 'ykxutils'
14
- gem 'bundler'
15
- gem 'rake', '~> 13.0'
16
16
 
17
17
  group :development do
18
18
  gem 'yard'
19
19
  end
20
20
 
21
21
  group :test, optional: true do
22
- gem "rspec", "~> 3.0"
22
+ gem 'rspec', '~> 3.0'
23
23
  # gem "rspec"
24
- gem "rubocop", '~> 1.7'
25
- gem "rubocop-performance"
26
- gem "rubocop-rake"
27
- gem "rubocop-rspec"
28
24
  gem 'power_assert', '~> 1.1.5'
25
+ gem 'rubocop', '~> 1.7'
26
+ gem 'rubocop-performance'
27
+ gem 'rubocop-rake'
28
+ gem 'rubocop-rspec'
29
29
  end
30
30
 
31
31
  # group :test do
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- arxutils_sqlite3 (0.1.60)
4
+ arxutils_sqlite3 (0.1.61)
5
5
  activerecord (~> 6.1)
6
6
  activesupport
7
7
  bundler
data/Rakefile CHANGED
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/gem_tasks"
3
+ require 'bundler/gem_tasks'
4
4
 
5
5
  begin
6
- require "rspec/core/rake_task"
6
+ require 'rspec/core/rake_task'
7
7
  rescue LoadError => e
8
8
  puts e.message
9
9
  end
@@ -15,7 +15,7 @@ rescue NameError, LoadError => e
15
15
  end
16
16
 
17
17
  begin
18
- require "rubocop/rake_task"
18
+ require 'rubocop/rake_task'
19
19
  rescue LoadError => e
20
20
  puts e.message
21
21
  end
@@ -37,4 +37,3 @@ begin
37
37
  rescue LoadError => e
38
38
  puts e.message
39
39
  end
40
-
@@ -33,16 +33,16 @@ Gem::Specification.new do |spec|
33
33
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
34
34
  # p spec.executables
35
35
  spec.require_paths = ['lib']
36
-
36
+
37
37
  spec.add_runtime_dependency 'bundler'
38
38
 
39
- spec.add_runtime_dependency 'activesupport'
40
39
  spec.add_runtime_dependency 'activerecord', '~> 6.1'
41
- spec.add_runtime_dependency 'sqlite3'
40
+ spec.add_runtime_dependency 'activesupport'
41
+ spec.add_runtime_dependency 'rake', '~> 13.0'
42
42
  spec.add_runtime_dependency 'simpleoptparse'
43
+ spec.add_runtime_dependency 'sqlite3'
43
44
  spec.add_runtime_dependency 'ykutils'
44
45
  spec.add_runtime_dependency 'ykxutils'
45
- spec.add_runtime_dependency 'rake', '~> 13.0'
46
46
 
47
47
  spec.add_development_dependency 'power_assert', '~> 1.1.5'
48
48
  spec.add_development_dependency 'rspec', '~> 3.0'
@@ -12,13 +12,13 @@ module Arxutils_Sqlite3
12
12
  # nameというメソッド/アトリビュート(string)を持つ。"'/'を区切り文字として持つ階層を表す文字列
13
13
  # registerメソッドを呼び出す時は、hier_symbolのみを指定してcreate出来なければならない(そうでなければSQLの制約違反発生)
14
14
  attr_reader :base_klass
15
+ # IDの親子関係で階層処理を実現するクラス名(DB中のテーブルに対応するActiveRecordの子クラス)
16
+ # parent_id(integer) , child_id(integer) , leve(integer)というメソッド/アトリビュートを持つ
17
+ attr_reader :hier_klass
15
18
  # '/'が区切り文字の文字列で階層処理を実現するクラスのカレントに対応するクラス名(DB中のテーブルに対応するActiveRecordの子クラス)
16
19
  attr_reader :current_klass
17
20
  # '/'が区切り文字の文字列で階層処理を実現するクラスのインバリッドに対応するクラス名(DB中のテーブルに対応するActiveRecordの子クラス)
18
21
  attr_reader :invalid_klass
19
- # IDの親子関係で階層処理を実現するクラス名(DB中のテーブルに対応するActiveRecordの子クラス)
20
- # parent_id(integer) , child_id(integer) , leve(integer)というメソッド/アトリビュートを持つ
21
- attr_reader :hier_klass
22
22
 
23
23
  # 初期化
24
24
  def initialize(field_name, hier_symbol, _hier_name, base_klass, hier_klass, current_klass, invalid_klass)
@@ -27,7 +27,7 @@ module Arxutils_Sqlite3
27
27
  # '/'が区切り文字の文字列で階層処理を実現するクラスの階層構造を表す文字列を持つメソッド/アトリビュートを表すシンボ
28
28
  @hier_symbol = hier_symbol
29
29
  # '/'が区切り文字の文字列で階層処理を実現するクラスのクラス名(DB中のテーブルに対応するActiveRecordの子クラス)
30
- @base_klass = base_klass
30
+ @base_klass = base_klass
31
31
  # '/'が区切り文字の文字列で階層処理を実現するクラスのカレントに対応するクラス名(DB中のテーブルに対応するActiveRecordの子クラス)
32
32
  @current_klass = current_klass
33
33
  # '/'が区切り文字の文字列で階層処理を実現するクラスのインバリッドに対応するクラス名(DB中のテーブルに対応するActiveRecordの子クラス)
@@ -43,16 +43,19 @@ module Arxutils_Sqlite3
43
43
  id = nil
44
44
  base = @base_klass.find_by({ @hier_symbol => hier })
45
45
  if base
46
- delete_at(base.org_id)
47
- @base_klass.delete_at(base.id)
46
+ delete_at(base.id)
47
+ # @base_klass.delete_at(base.id)
48
+ @base_klass.delete(base.id)
48
49
  end
49
50
  id
50
51
  end
51
52
 
52
53
  def delete_by_id(id)
53
- base = @base_klass.find_by(org_id: id)
54
+ # base = @base_klass.find_by(id: id)
55
+ base = @base_klass.find(id)
54
56
  delete_at(id)
55
57
  @base_klass.delete_at(base.id)
58
+ @base_klass.delete_at(base.id)
56
59
  end
57
60
 
58
61
  # 文字列で指定した階層を移動
@@ -142,15 +145,22 @@ module Arxutils_Sqlite3
142
145
  def delete_at(num)
143
146
  # 子として探す
144
147
  hier = @hier_klass.find_by(child_id: num)
145
- level = hier.level
146
- parent_id = hier.parent_id
147
- # base = @base_klass.find_by(ord_id: num)
148
-
149
- # parent_base = @base_klass.find_by(ord_id: parent_id)
150
- # parent_hier_string = parent_base.__send__ @hier_symbol
148
+ if hier
149
+ level = hier.level
150
+ parent_id = hier.parent_id
151
+ end
151
152
 
153
+ parent = @base_klass.find(num)
154
+ parent_hier = get_name(parent)
152
155
  # 属する子を探す
153
156
  children_hier = @hier_klass.where(parent_id: num)
157
+ return unless children_hier
158
+
159
+ adjust_children_hier(children_hier, level, parent_id, parent_hier)
160
+ end
161
+
162
+ # 子の階層の調整
163
+ def adjust_children_hier(children_hier, level, parent_id, parent_hier)
154
164
  # 属する子の階層レベルを調整する(削除するのでlevel - 1になる)
155
165
  children_hier.map { |x| level_adjust(x, level - 1) }
156
166
  # 属する子の親を、親の親にする
@@ -160,7 +170,7 @@ module Arxutils_Sqlite3
160
170
  end
161
171
  # 属する子のhierを調整する
162
172
  children_hier.map do |x|
163
- child_base = @base_klass.find_by(org_id: x.child_id)
173
+ child_base = @base_klass.find_by(id: x.child_id)
164
174
  name = get_name(child_base)
165
175
  child_base.hier = make_hier(parent_hier, name)
166
176
  child_base.save
@@ -183,14 +193,16 @@ module Arxutils_Sqlite3
183
193
  # 階層を表すデータ構造で指定された階層の下部階層の名前を調整する
184
194
  def hier_adjust(base)
185
195
  parent_hier_string = base.__send__ @hier_symbol
186
- parent_num = base.org_id
196
+ # parent_num = base.org_id
197
+ parent_num = base.id
187
198
 
188
199
  tbl_rows = @hier_klass.where(parent_id: parent_num)
189
200
  return if tbl_rows.size.zero?
190
201
 
191
202
  tbl_rows.map do |x|
192
203
  child_num = x.child_id
193
- item_row = @base_klass.find_by(org_id: child_num)
204
+ # item_row = @base_klass.find_by(org_id: child_num)
205
+ item_row = @base_klass.find(child_num)
194
206
  item_row.hier = make_hier(parent_hier_string, get_name(item_row))
195
207
  item_row.save
196
208
  hier_adjust(item_row)
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Arxutils_Sqlite3
4
4
  # バージョン番号
5
- VERSION = '0.1.60'
5
+ VERSION = '0.1.61'
6
6
  end
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.60
4
+ version: 0.1.61
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-10-03 00:00:00.000000000 Z
11
+ date: 2022-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activerecord
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '6.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '6.1'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: activesupport
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -39,21 +53,21 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: activerecord
56
+ name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '6.1'
61
+ version: '13.0'
48
62
  type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '6.1'
68
+ version: '13.0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: sqlite3
70
+ name: simpleoptparse
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - ">="
@@ -67,7 +81,7 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: simpleoptparse
84
+ name: sqlite3
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - ">="
@@ -108,20 +122,6 @@ dependencies:
108
122
  - - ">="
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: rake
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '13.0'
118
- type: :runtime
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '13.0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: power_assert
127
127
  requirement: !ruby/object:Gem::Requirement