arxutils 0.1.35 → 0.1.36
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/arxutils/dbutil/dbinit.rb +7 -8
- data/lib/arxutils/dbutil/dbmgr.rb +2 -2
- data/lib/arxutils/hier.rb +19 -2
- data/lib/arxutils/migrate.rb +3 -5
- data/lib/arxutils/store/storedb.rb +1 -1
- data/lib/arxutils/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b719f143307e145df60195bc5e2670aa7fb2474
|
4
|
+
data.tar.gz: 00c4f031d2555d54eb937523eb8b02c7f5a57e52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bee744f9f8444396d9e0c41dda4851dfb24c0e6959c3e465bf1e91b0f64a2e1c4a99427aae8fce2e778d75dcf99bd872a773f5143cf1ea9f9c7e15b0afb80be1
|
7
|
+
data.tar.gz: a0fd2f8c5f1c0973d0673194ebd98b83e033fba1ba6eb7620a5ca2f13cddd75d0113c05425afad57e9fb7de838bf7b7f83c0b112a71078fdd9911b21a085be48
|
@@ -16,16 +16,17 @@ module Arxutils
|
|
16
16
|
class Dbinit
|
17
17
|
attr_accessor :dbconfig_dest_path , :dbconfig_src_path , :dbconfig_src_fname , :dbconfig_dest_fname , :migrate_dir
|
18
18
|
|
19
|
-
def initialize( migrate_base_dir , src_config_dir , dbconfig , log_fname, forced = false )
|
20
|
-
@db_dir =
|
19
|
+
def initialize( db_dir , migrate_base_dir , src_config_dir , dbconfig , env, log_fname, forced = false )
|
20
|
+
@db_dir = db_dir
|
21
21
|
@src_config_dir = src_config_dir
|
22
22
|
@dest_config_dir = "config"
|
23
|
-
@dbconfig_dest_fname = "#{dbconfig
|
24
|
-
@dbconfig_src_fname = "#{dbconfig
|
23
|
+
@dbconfig_dest_fname = "#{dbconfig}.yaml"
|
24
|
+
@dbconfig_src_fname = "#{dbconfig}.tmpl"
|
25
25
|
@dbconfig_dest_path = File.join( @dest_config_dir , @dbconfig_dest_fname)
|
26
26
|
@dbconfig_src_path = File.join(@src_config_dir , @dbconfig_src_fname)
|
27
|
+
@env = env
|
27
28
|
@log_fname = log_fname
|
28
|
-
|
29
|
+
|
29
30
|
if @db_dir and @log_fname
|
30
31
|
@log_path = File.join( @db_dir , @log_fname )
|
31
32
|
@migrate_dir = File.join( @db_dir , migrate_base_dir )
|
@@ -40,10 +41,8 @@ module Arxutils
|
|
40
41
|
end
|
41
42
|
|
42
43
|
def setup
|
43
|
-
puts ENV['ENV']
|
44
44
|
dbconfig = YAML.load( File.read( @dbconfig_dest_path ) )
|
45
|
-
|
46
|
-
ActiveRecord::Base.establish_connection(dbconfig[ENV['ENV']])
|
45
|
+
ActiveRecord::Base.establish_connection(dbconfig[@env])
|
47
46
|
ActiveRecord::Base.logger = Logger.new( @log_path )
|
48
47
|
end
|
49
48
|
end
|
@@ -8,8 +8,8 @@ require 'pp'
|
|
8
8
|
module Arxutils
|
9
9
|
module Dbutil
|
10
10
|
class DbMgr
|
11
|
-
def DbMgr.init( migrate_dir , config_dir , dbconfig, log_fname, forced = false )
|
12
|
-
dbinit = Dbinit.new( migrate_dir , config_dir , dbconfig, log_fname, forced )
|
11
|
+
def DbMgr.init( db_dir , migrate_dir , config_dir , dbconfig, env , log_fname, forced = false )
|
12
|
+
dbinit = Dbinit.new( db_dir, migrate_dir , config_dir , dbconfig, env , log_fname, forced )
|
13
13
|
DbMgr.setup( dbinit )
|
14
14
|
end
|
15
15
|
|
data/lib/arxutils/hier.rb
CHANGED
@@ -2,13 +2,30 @@
|
|
2
2
|
|
3
3
|
module Arxutils
|
4
4
|
class HierOp
|
5
|
-
|
5
|
+
attr_reader :field_name, :hier_symbol, :base_klass, :hier_klass, :current_klass, :invalid_klass
|
6
|
+
|
7
|
+
def initialize( field_name, hier_symbol , hier_name, base_klass , hier_klass , current_klass , invalid_klass )
|
8
|
+
@field_name = field_name
|
6
9
|
@hier_symbol = hier_symbol
|
7
10
|
@base_klass = base_klass
|
8
11
|
@hier_klass = hier_klass
|
9
12
|
@current_klass = current_klass
|
13
|
+
@invalid_klass = invalid_klass
|
10
14
|
end
|
11
|
-
|
15
|
+
|
16
|
+
def get_category_hier_json( kind_num )
|
17
|
+
JSON( @hier_klass.pluck( :parent_id , :child_id , :level ).map{ |ary|
|
18
|
+
text = @base_klass.find( ary[1] ).__send__( @hier_symbol ).split("/").pop
|
19
|
+
if ary[2] == 0
|
20
|
+
parent_id = "#"
|
21
|
+
else
|
22
|
+
parent_id = %Q!#{ary[0]}!
|
23
|
+
end
|
24
|
+
child_id = %Q!#{ary[1]}!
|
25
|
+
{ "id" => child_id , "parent" => parent_id , "text" => text }
|
26
|
+
} )
|
27
|
+
end
|
28
|
+
|
12
29
|
def delete( hier )
|
13
30
|
# 子として探す
|
14
31
|
id = nil
|
data/lib/arxutils/migrate.rb
CHANGED
@@ -10,7 +10,7 @@ module Arxutils
|
|
10
10
|
class Migrate
|
11
11
|
attr_accessor :dbinit , :dbconfig_dest_path , :dbconfig_dest_fname , :dbconfig_src_path , :dbconfig_src_fname
|
12
12
|
|
13
|
-
def Migrate.migrate( data_ary , relation_def_fpath , module_name, count_classname_downcase ,
|
13
|
+
def Migrate.migrate( data_ary , relation_def_fpath , module_name, count_classname_downcase , dbconfig , forced )
|
14
14
|
src_config_dir = Arxutils.configdir
|
15
15
|
mig = Migrate.new( Dbutil::MIGRATE_DIR , src_config_dir , dbconfig, Dbutil::DATABASELOG, forced )
|
16
16
|
# dbconfigのテンプレートは内容が固定である。convertを呼び出し、Arxのインスタンスを作成するときに、適切なdata_aryの要素を与える必要がある(ただしテンプレートへの埋め込みには用いられない
|
@@ -21,7 +21,7 @@ module Arxutils
|
|
21
21
|
}
|
22
22
|
|
23
23
|
content_array = data_ary.map { |x|
|
24
|
-
mig.make_relation( x , "count"
|
24
|
+
mig.make_relation( x , "count" )
|
25
25
|
}.select{ |x| x.size > 0 }
|
26
26
|
need_count_class_plural = content_array.reduce([]){ |s,x|
|
27
27
|
s << x[:need_count_class_plural] if x[:need_count_class_plural] != nil
|
@@ -29,7 +29,6 @@ module Arxutils
|
|
29
29
|
}
|
30
30
|
if content_array.size > 0
|
31
31
|
data_count = {count_classname: "Count" ,
|
32
|
-
count_field: count_field,
|
33
32
|
need_count_class_plural: need_count_class_plural,
|
34
33
|
}
|
35
34
|
ary = content_array.collect{|x| x[:content] }.flatten
|
@@ -78,7 +77,7 @@ module Arxutils
|
|
78
77
|
}
|
79
78
|
end
|
80
79
|
|
81
|
-
def make_relation( data , count_classname_downcase
|
80
|
+
def make_relation( data , count_classname_downcase )
|
82
81
|
if data[:classname_downcase] != count_classname_downcase
|
83
82
|
data[:flist].reduce( { content: [], need_count_class: nil } ){ |s, x|
|
84
83
|
case x
|
@@ -87,7 +86,6 @@ module Arxutils
|
|
87
86
|
data[:relation] = [] unless data[:relation]
|
88
87
|
else
|
89
88
|
data[:count_classname_downcase] = count_classname_downcase
|
90
|
-
data[:count_field] = count_field
|
91
89
|
name_base = "relation_#{x}"
|
92
90
|
s[:need_count_class_plural] ||= data[:plural]
|
93
91
|
end
|
@@ -6,7 +6,7 @@ module Arxutils
|
|
6
6
|
class StoreDb
|
7
7
|
def StoreDb.init( hs , block = nil )
|
8
8
|
ret = nil
|
9
|
-
register_time = Dbutil::DbMgr.init( hs["migrate_dir"] , hs["config_dir"], hs["dbconfig"] , hs["log_fname"] )
|
9
|
+
register_time = Dbutil::DbMgr.init( hs["db_dir"], hs["migrate_dir"] , hs["config_dir"], hs["dbconfig"] , hs["env"] , hs["log_fname"] )
|
10
10
|
|
11
11
|
if block
|
12
12
|
ret = block.call( register_time )
|
data/lib/arxutils/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arxutils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.36
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yasuo kominami
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
168
|
version: '0'
|
169
169
|
requirements: []
|
170
170
|
rubyforge_project:
|
171
|
-
rubygems_version: 2.
|
171
|
+
rubygems_version: 2.5.2
|
172
172
|
signing_key:
|
173
173
|
specification_version: 4
|
174
174
|
summary: utility functions for ActiveRecord.
|