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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0db660cdf41eaaaab3cc142711afb8186b10c06e
4
- data.tar.gz: 20a8b02d69969d52a37cfddda3c721d0d628762d
3
+ metadata.gz: 1b719f143307e145df60195bc5e2670aa7fb2474
4
+ data.tar.gz: 00c4f031d2555d54eb937523eb8b02c7f5a57e52
5
5
  SHA512:
6
- metadata.gz: 7e38ecbe696e36c4e4975fcf304beb86d49056edb6df241448232d7e8b987041f45514ece568c1449f4155fde058521c55a71e221e3de4f3d8a76bf5bd0e9f35
7
- data.tar.gz: bc11ab615060d8d3eaff76d5e582258adf766d78cde23852403ba4c3f05ae54440c2853f047675a59c8389a802cb9b3d648ca730aea8d49200a8c117dbf16ee7
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 = dbconfig[: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[:kind]}.yaml"
24
- @dbconfig_src_fname = "#{dbconfig[:kind]}.tmpl"
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
- puts dbconfig[ ENV['ENV'] ]
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
- def initialize( hier_symbol , base_klass , hier_klass , current_klass )
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
@@ -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 , count_field , dbconfig , forced )
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", "end_count_id" )
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 , count_field )
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 )
@@ -1,3 +1,3 @@
1
1
  module Arxutils
2
- VERSION = "0.1.35"
2
+ VERSION = "0.1.36"
3
3
  end
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.35
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: 2016-07-12 00:00:00.000000000 Z
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.6.4
171
+ rubygems_version: 2.5.2
172
172
  signing_key:
173
173
  specification_version: 4
174
174
  summary: utility functions for ActiveRecord.