pokotarou 1.2.2 → 1.2.3
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.
- checksums.yaml +4 -4
- data/lib/pokotarou.rb +64 -139
- data/lib/pokotarou/handler.rb +66 -0
- data/lib/pokotarou/handler_factory.rb +29 -0
- data/lib/pokotarou/operator.rb +79 -0
- data/lib/pokotarou/parser/seed_data_expression_parser.rb +1 -1
- data/lib/pokotarou/registration_config_maker/main.rb +10 -4
- data/lib/pokotarou/registration_config_maker/model_option_setter.rb +67 -20
- data/lib/pokotarou/registration_config_maker/preset_option_setter.rb +37 -9
- data/lib/pokotarou/registration_config_updater/array_utils.rb +1 -2
- data/lib/pokotarou/registration_config_updater/main.rb +4 -4
- data/lib/pokotarou/seed_data_register/main.rb +2 -15
- data/lib/pokotarou/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1a8dbadc1f72b24fc4ae994e3334a8e8c78725536a2dbc5437d7203ab77a69c5
|
|
4
|
+
data.tar.gz: 58f19fcfcd76b2f7df6c0065b3816ef5062735a92390dcdb94804bb9608ca699
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2d74d989306dfc6800a7409ee940ed171de101f8e26ddfe0c7e2a657eba695d92a054022b7ddaabc80dda234ca1ecca05da2f1154b1c6622507e94eea35e6626
|
|
7
|
+
data.tar.gz: ef45d33242aed49e59a23c216d3964e468414ab0d6d62d230229407673b6cb74a3709ad272a1767815c10e23c123ce44223e392d077bfba68272eb338efae078
|
data/lib/pokotarou.rb
CHANGED
|
@@ -1,177 +1,102 @@
|
|
|
1
1
|
require "activerecord-import"
|
|
2
|
-
require "pokotarou/
|
|
3
|
-
require "pokotarou/
|
|
4
|
-
require "pokotarou/parser/const_parser.rb"
|
|
2
|
+
require "pokotarou/handler_factory"
|
|
3
|
+
require "pokotarou/operator"
|
|
5
4
|
|
|
6
5
|
module Pokotarou
|
|
7
|
-
class
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
# if input is filepath, generate config_data
|
|
14
|
-
return_val =
|
|
15
|
-
if input.kind_of?(String)
|
|
16
|
-
SeedDataRegister::Main.register(gen_config(input))
|
|
17
|
-
else
|
|
18
|
-
SeedDataRegister::Main.register(input)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
AdditionalMethods::Main.remove_filepathes_from_yml()
|
|
22
|
-
|
|
23
|
-
return_val
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def pipeline_execute input_arr
|
|
27
|
-
AdditionalMethods::Main.init()
|
|
28
|
-
|
|
29
|
-
return_vals = []
|
|
30
|
-
input_arr.each do |e|
|
|
31
|
-
handler = gen_handler_with_cache(e[:filepath])
|
|
32
|
-
|
|
33
|
-
if e[:change_data].present?
|
|
34
|
-
e[:change_data].each do |block, config|
|
|
35
|
-
config.each do |model, seed|
|
|
36
|
-
seed.each do |col_name, val|
|
|
37
|
-
handler.change_seed(block, model, col_name, val)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
e[:args] ||= {}
|
|
44
|
-
e[:args][:passed_return_val] = return_vals.last
|
|
45
|
-
set_args(e[:args])
|
|
46
|
-
|
|
47
|
-
return_vals << Pokotarou.execute(handler.get_data())
|
|
48
|
-
AdditionalMethods::Main.remove_filepathes_from_yml()
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
return_vals
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def import filepath
|
|
55
|
-
AdditionalMethods::Main.init()
|
|
56
|
-
AdditionalMethods::Main.import(filepath)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def set_args hash
|
|
60
|
-
AdditionalArguments::Main.import(hash)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def reset
|
|
64
|
-
AdditionalMethods::Main.remove()
|
|
65
|
-
AdditionalArguments::Main.remove()
|
|
66
|
-
AdditionalVariables::Main.remove()
|
|
67
|
-
@handler_chache = {}
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def gen_handler filepath
|
|
71
|
-
AdditionalMethods::Main.init()
|
|
72
|
-
|
|
73
|
-
PokotarouHandler.new(gen_config(filepath))
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def gen_handler_with_cache filepath
|
|
77
|
-
AdditionalMethods::Main.init()
|
|
78
|
-
|
|
79
|
-
@handler_cache ||= {}
|
|
80
|
-
@handler_cache[filepath] ||= PokotarouHandler.new(gen_config(filepath))
|
|
81
|
-
|
|
82
|
-
@handler_cache[filepath].deep_dup
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
private
|
|
86
|
-
|
|
87
|
-
def gen_config filepath
|
|
88
|
-
contents = YAML.load_file(filepath).deep_symbolize_keys!
|
|
89
|
-
AdditionalVariables::Main.set_const(contents)
|
|
90
|
-
RegistrationConfigMaker::Main.gen(contents)
|
|
91
|
-
end
|
|
92
|
-
|
|
6
|
+
class V2
|
|
7
|
+
def initialize filepath
|
|
8
|
+
@handler = Pokotarou::HandlerFactory.gen_handler(filepath)
|
|
9
|
+
|
|
10
|
+
return self
|
|
93
11
|
end
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
12
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
def execute input
|
|
100
|
-
Operater.execute(input)
|
|
13
|
+
def make
|
|
14
|
+
@handler.make()
|
|
101
15
|
end
|
|
102
16
|
|
|
103
|
-
def
|
|
104
|
-
|
|
17
|
+
def delete_block sym_block
|
|
18
|
+
@handler.delete_block(sym_block)
|
|
19
|
+
|
|
20
|
+
self
|
|
105
21
|
end
|
|
106
22
|
|
|
107
|
-
def
|
|
108
|
-
|
|
23
|
+
def delete_model sym_block, sym_class
|
|
24
|
+
@handler.delete_model(sym_block, sym_class)
|
|
25
|
+
|
|
26
|
+
self
|
|
109
27
|
end
|
|
110
28
|
|
|
111
|
-
def
|
|
112
|
-
|
|
29
|
+
def delete_col sym_block, sym_class, sym_col
|
|
30
|
+
@handler.delete_col(sym_block, sym_class, sym_col)
|
|
31
|
+
|
|
32
|
+
self
|
|
113
33
|
end
|
|
114
34
|
|
|
115
|
-
def
|
|
116
|
-
|
|
35
|
+
def change_loop sym_block, sym_class, n
|
|
36
|
+
@handler.change_loop(sym_block, sym_class, n)
|
|
37
|
+
|
|
38
|
+
self
|
|
117
39
|
end
|
|
118
40
|
|
|
119
|
-
def
|
|
120
|
-
|
|
41
|
+
def change_seed sym_block, sym_class, sym_col, arr
|
|
42
|
+
@handler.change_seed(sym_block, sym_class, sym_col, arr)
|
|
43
|
+
|
|
44
|
+
self
|
|
121
45
|
end
|
|
122
46
|
|
|
123
|
-
def
|
|
124
|
-
|
|
47
|
+
def get_data
|
|
48
|
+
@handler.get_data
|
|
125
49
|
end
|
|
126
|
-
end
|
|
127
|
-
end
|
|
128
50
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
51
|
+
def set_data data
|
|
52
|
+
@handler.set_data(data)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def set_randomincrement sym_block, sym_class, status
|
|
56
|
+
@handler.set_randomincrement(sym_block, sym_class, status)
|
|
133
57
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
end
|
|
58
|
+
self
|
|
59
|
+
end
|
|
137
60
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
end
|
|
61
|
+
def set_autoincrement sym_block, sym_class, status
|
|
62
|
+
@handler.set_autoincrement(sym_block, sym_class, status)
|
|
141
63
|
|
|
142
|
-
|
|
143
|
-
|
|
64
|
+
self
|
|
65
|
+
end
|
|
144
66
|
end
|
|
145
67
|
|
|
146
|
-
|
|
147
|
-
|
|
68
|
+
# データ作成メソッドはmakeで統一させる
|
|
69
|
+
# executeはレガシー扱いに設定する
|
|
70
|
+
def self.make input
|
|
71
|
+
Operator.execute(input)
|
|
72
|
+
end
|
|
148
73
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
@data[sym_block][sym_class][:convert].delete(sym_col) if exists_content.call(:convert)
|
|
74
|
+
def self.execute input
|
|
75
|
+
Operator.execute(input)
|
|
152
76
|
end
|
|
153
77
|
|
|
154
|
-
def
|
|
155
|
-
|
|
78
|
+
def self.pipeline_execute input_arr
|
|
79
|
+
Operator.pipeline_execute(input_arr)
|
|
156
80
|
end
|
|
157
81
|
|
|
158
|
-
def
|
|
159
|
-
|
|
82
|
+
def self.import filepath
|
|
83
|
+
Operator.import(filepath)
|
|
160
84
|
end
|
|
161
85
|
|
|
162
|
-
def
|
|
163
|
-
|
|
86
|
+
def self.set_args hash
|
|
87
|
+
Operator.set_args(hash)
|
|
164
88
|
end
|
|
165
89
|
|
|
166
|
-
def
|
|
167
|
-
|
|
90
|
+
def self.reset
|
|
91
|
+
Operator.reset()
|
|
168
92
|
end
|
|
169
|
-
|
|
170
|
-
def
|
|
171
|
-
|
|
93
|
+
|
|
94
|
+
def self.gen_handler filepath
|
|
95
|
+
HandlerFactory.gen_handler(filepath)
|
|
172
96
|
end
|
|
173
97
|
|
|
174
|
-
def
|
|
175
|
-
|
|
98
|
+
def self.gen_handler_with_cache filepath
|
|
99
|
+
HandlerFactory.gen_handler_with_cache(filepath)
|
|
176
100
|
end
|
|
101
|
+
|
|
177
102
|
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
module Pokotarou
|
|
2
|
+
|
|
3
|
+
class Handler
|
|
4
|
+
def initialize data
|
|
5
|
+
@data = data
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def make
|
|
9
|
+
data = get_data()
|
|
10
|
+
|
|
11
|
+
AdditionalMethods::Main.init()
|
|
12
|
+
|
|
13
|
+
# if input is filepath, generate config_data
|
|
14
|
+
return_val =
|
|
15
|
+
if data.kind_of?(String)
|
|
16
|
+
SeedDataRegister::Main.register(gen_config(data))
|
|
17
|
+
else
|
|
18
|
+
SeedDataRegister::Main.register(data)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
AdditionalMethods::Main.remove_filepathes_from_yml()
|
|
22
|
+
|
|
23
|
+
return_val
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def delete_block sym_block
|
|
27
|
+
@data.delete(sym_block)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def delete_model sym_block, sym_class
|
|
31
|
+
@data[sym_block].delete(sym_class)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def delete_col sym_block, sym_class, sym_col
|
|
35
|
+
exists_content = ->(key){ @data[sym_block][sym_class][key].present? }
|
|
36
|
+
|
|
37
|
+
@data[sym_block][sym_class][:col].delete(sym_col) if exists_content.call(:col)
|
|
38
|
+
@data[sym_block][sym_class][:option].delete(sym_col) if exists_content.call(:option)
|
|
39
|
+
@data[sym_block][sym_class][:convert].delete(sym_col) if exists_content.call(:convert)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def change_loop sym_block, sym_class, n
|
|
43
|
+
@data[sym_block][sym_class][:loop] = n
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def change_seed sym_block, sym_class, sym_col, arr
|
|
47
|
+
@data[sym_block][sym_class][:col][sym_col] = arr
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def get_data
|
|
51
|
+
@data.deep_dup
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def set_data data
|
|
55
|
+
@data = data
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def set_randomincrement sym_block, sym_class, status
|
|
59
|
+
@data[sym_block][sym_class][:randomincrement] = status
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def set_autoincrement sym_block, sym_class, status
|
|
63
|
+
@data[sym_block][sym_class][:autoincrement] = status
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require "pokotarou/handler"
|
|
2
|
+
require "pokotarou/registration_config_maker/main"
|
|
3
|
+
|
|
4
|
+
module Pokotarou
|
|
5
|
+
|
|
6
|
+
class HandlerFactory
|
|
7
|
+
class << self
|
|
8
|
+
def gen_handler filepath
|
|
9
|
+
AdditionalMethods::Main.init()
|
|
10
|
+
|
|
11
|
+
Handler.new(gen_config(filepath))
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def gen_handler_with_cache filepath
|
|
15
|
+
AdditionalMethods::Main.init()
|
|
16
|
+
|
|
17
|
+
@handler_cache ||= {}
|
|
18
|
+
@handler_cache[filepath] ||= Handler.new(gen_config(filepath))
|
|
19
|
+
|
|
20
|
+
@handler_cache[filepath].deep_dup
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
def gen_config filepath
|
|
25
|
+
RegistrationConfigMaker::Main.gen(filepath)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
require "pokotarou/handler_factory"
|
|
2
|
+
require "pokotarou/registration_config_maker/main"
|
|
3
|
+
require "pokotarou/additional_arguments/main"
|
|
4
|
+
require "pokotarou/additional_methods/main"
|
|
5
|
+
require "pokotarou/additional_variables/main"
|
|
6
|
+
require "pokotarou/seed_data_register/main.rb"
|
|
7
|
+
require "pokotarou/parser/const_parser.rb"
|
|
8
|
+
|
|
9
|
+
module Pokotarou
|
|
10
|
+
class Operator
|
|
11
|
+
class NotFoundLoader < StandardError; end
|
|
12
|
+
class << self
|
|
13
|
+
def execute input
|
|
14
|
+
AdditionalMethods::Main.init()
|
|
15
|
+
|
|
16
|
+
# if input is filepath, generate config_data
|
|
17
|
+
return_val =
|
|
18
|
+
if input.kind_of?(String)
|
|
19
|
+
SeedDataRegister::Main.register(gen_config(input))
|
|
20
|
+
else
|
|
21
|
+
SeedDataRegister::Main.register(input)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
AdditionalMethods::Main.remove_filepathes_from_yml()
|
|
25
|
+
|
|
26
|
+
return_val
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def pipeline_execute input_arr
|
|
30
|
+
AdditionalMethods::Main.init()
|
|
31
|
+
|
|
32
|
+
return_vals = []
|
|
33
|
+
input_arr.each do |e|
|
|
34
|
+
handler = HandlerFactory.gen_handler_with_cache(e[:filepath])
|
|
35
|
+
|
|
36
|
+
if e[:change_data].present?
|
|
37
|
+
e[:change_data].each do |block, config|
|
|
38
|
+
config.each do |model, seed|
|
|
39
|
+
seed.each do |col_name, val|
|
|
40
|
+
handler.change_seed(block, model, col_name, val)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
e[:args] ||= {}
|
|
47
|
+
e[:args][:passed_return_val] = return_vals.last
|
|
48
|
+
set_args(e[:args])
|
|
49
|
+
|
|
50
|
+
return_vals << Pokotarou.execute(handler.get_data())
|
|
51
|
+
AdditionalMethods::Main.remove_filepathes_from_yml()
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
return_vals
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def import filepath
|
|
58
|
+
AdditionalMethods::Main.init()
|
|
59
|
+
AdditionalMethods::Main.import(filepath)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def set_args hash
|
|
63
|
+
AdditionalArguments::Main.import(hash)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def reset
|
|
67
|
+
AdditionalMethods::Main.remove()
|
|
68
|
+
AdditionalArguments::Main.remove()
|
|
69
|
+
AdditionalVariables::Main.remove()
|
|
70
|
+
@handler_chache = {}
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def gen_config filepath
|
|
74
|
+
RegistrationConfigMaker::Main.gen(filepath)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -5,14 +5,19 @@ require "pokotarou/registration_config_maker/template_option_setter.rb"
|
|
|
5
5
|
require "pokotarou/registration_config_maker/grouping_option_setter.rb"
|
|
6
6
|
require "pokotarou/registration_config_maker/model_option_setter.rb"
|
|
7
7
|
require "pokotarou/registration_config_maker/preset_option_setter.rb"
|
|
8
|
+
require "pokotarou/additional_variables/main.rb"
|
|
8
9
|
|
|
9
10
|
module Pokotarou
|
|
10
11
|
module RegistrationConfigMaker
|
|
12
|
+
class FailedGenerateConfigError < StandardError; end
|
|
11
13
|
class Main
|
|
12
14
|
class << self
|
|
13
|
-
def gen
|
|
15
|
+
def gen filepath
|
|
16
|
+
all_content = YAML.load_file(filepath).deep_symbolize_keys!
|
|
17
|
+
AdditionalVariables::Main.set_const(all_content)
|
|
14
18
|
set_header_config(all_content)
|
|
15
19
|
all_content.reduce({}) do |acc, block_content|
|
|
20
|
+
|
|
16
21
|
block_name = block_content.first
|
|
17
22
|
block_config = block_content.second
|
|
18
23
|
|
|
@@ -23,6 +28,7 @@ module Pokotarou
|
|
|
23
28
|
end
|
|
24
29
|
|
|
25
30
|
acc
|
|
31
|
+
|
|
26
32
|
end
|
|
27
33
|
end
|
|
28
34
|
|
|
@@ -50,12 +56,12 @@ module Pokotarou
|
|
|
50
56
|
end
|
|
51
57
|
|
|
52
58
|
def set_model_config_to_acc acc, block_content
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
set_grouping_option(block_content.second)
|
|
60
|
+
ModelOptionSetter.set(acc, block_content)
|
|
55
61
|
end
|
|
56
62
|
|
|
57
63
|
def set_grouping_option block_content
|
|
58
|
-
block_content.each do |
|
|
64
|
+
block_content.each do |model_name, model_content|
|
|
59
65
|
GroupingOptionSetter.set(model_content) if ConfigDomain.has_grouping_syntax?(model_content)
|
|
60
66
|
end
|
|
61
67
|
end
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
module Pokotarou
|
|
2
2
|
module RegistrationConfigMaker
|
|
3
|
+
class UnexistsModelError < StandardError; end
|
|
4
|
+
class UnexistsModelConfigError < StandardError; end
|
|
3
5
|
class ModelOptionSetter
|
|
4
6
|
class << self
|
|
5
7
|
def set acc, block_content
|
|
@@ -18,31 +20,76 @@ module Pokotarou
|
|
|
18
20
|
private
|
|
19
21
|
|
|
20
22
|
def set_column_type model_config, model_name
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
begin
|
|
24
|
+
model = eval_model(model_name)
|
|
25
|
+
foreign_key_data = get_foreign_key_data(model)
|
|
26
|
+
|
|
27
|
+
if model_config.nil?
|
|
28
|
+
raise UnexistsModelConfigError.new("Unexists model config")
|
|
29
|
+
end
|
|
23
30
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
model_config[:col] ||= {}
|
|
32
|
+
model.columns.each do |e|
|
|
33
|
+
symbol_col_name = e.name.to_sym
|
|
27
34
|
|
|
28
|
-
|
|
35
|
+
next if ConfigDomain.has_seed_data_syntax?(model_config[:col], symbol_col_name)
|
|
29
36
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
# set foreign_key info
|
|
38
|
+
if ColumnDomain.is_foreign_key?(symbol_col_name, foreign_key_data)
|
|
39
|
+
# don't set :type val for don't run default seeder
|
|
40
|
+
# use F function for set foreign key
|
|
41
|
+
model_config[:col][symbol_col_name] = "F|#{foreign_key_data[symbol_col_name].to_s}"
|
|
42
|
+
else
|
|
43
|
+
model_config[:type] ||= {}
|
|
44
|
+
model_config[:type][symbol_col_name] = e.type.to_s
|
|
45
|
+
end
|
|
39
46
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
# set enum info
|
|
48
|
+
model_config[:enum] ||= {}
|
|
49
|
+
if ColumnDomain.is_enum?(e.sql_type.to_s)
|
|
50
|
+
model_config[:enum][symbol_col_name] = e.sql_type.to_s[5..-2].tr("'", "").split(",")
|
|
51
|
+
end
|
|
45
52
|
|
|
53
|
+
end
|
|
54
|
+
rescue UnexistsModelError => e
|
|
55
|
+
print "\e[31m"
|
|
56
|
+
puts "[ERROR]"
|
|
57
|
+
puts "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+"
|
|
58
|
+
puts "MESSAGE: Unexists Model #{model_name.to_s}"
|
|
59
|
+
puts "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+"
|
|
60
|
+
print "\e[0m"
|
|
61
|
+
puts ""
|
|
62
|
+
|
|
63
|
+
raise e
|
|
64
|
+
rescue UnexistsModelConfigError => e
|
|
65
|
+
print "\e[31m"
|
|
66
|
+
puts "[ERROR]"
|
|
67
|
+
puts "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+"
|
|
68
|
+
puts "MESSAGE: Unexists model config #{model_name.to_s}"
|
|
69
|
+
puts "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+"
|
|
70
|
+
print "\e[0m"
|
|
71
|
+
puts ""
|
|
72
|
+
|
|
73
|
+
raise e
|
|
74
|
+
rescue => e
|
|
75
|
+
print "\e[31m"
|
|
76
|
+
puts "[ERROR]"
|
|
77
|
+
puts "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+"
|
|
78
|
+
puts "MESSAGE: This model config is broken"
|
|
79
|
+
puts " #{e}"
|
|
80
|
+
puts "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+"
|
|
81
|
+
print "\e[0m"
|
|
82
|
+
puts ""
|
|
83
|
+
|
|
84
|
+
raise e
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def eval_model model_name
|
|
89
|
+
begin
|
|
90
|
+
eval(model_name.to_s)
|
|
91
|
+
rescue
|
|
92
|
+
raise UnexistsModelError.new("Unexists Model #{model_name.to_s} ")
|
|
46
93
|
end
|
|
47
94
|
end
|
|
48
95
|
|
|
@@ -1,40 +1,68 @@
|
|
|
1
1
|
require "pokotarou/registration_config_maker/config_domain.rb"
|
|
2
2
|
module Pokotarou
|
|
3
3
|
module RegistrationConfigMaker
|
|
4
|
+
class PresetError < StandardError; end
|
|
4
5
|
class PresetOptionSetter
|
|
5
6
|
class << self
|
|
6
7
|
def set all_content
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
new_preset_config = {}
|
|
9
|
+
preset_path = []
|
|
9
10
|
all_content[:"preset_path'"].each do |path|
|
|
10
11
|
YAML.load_file(path).deep_symbolize_keys!.each do |preset|
|
|
11
|
-
|
|
12
|
+
if :"preset_path'" == preset.first
|
|
13
|
+
preset_path.concat(preset.second)
|
|
14
|
+
else
|
|
15
|
+
new_preset_config[preset.first] = preset.second
|
|
16
|
+
end
|
|
12
17
|
end
|
|
13
18
|
end
|
|
14
19
|
|
|
15
|
-
#
|
|
20
|
+
# preset_pathを更新
|
|
16
21
|
all_content.delete(:"preset_path'")
|
|
17
|
-
|
|
22
|
+
if preset_path.size != 0
|
|
23
|
+
preset_path.uniq!
|
|
24
|
+
all_content[:"preset_path'"] = preset_path
|
|
25
|
+
end
|
|
26
|
+
|
|
18
27
|
# hashの順番を更新するために一度全てのKeyを消す
|
|
19
|
-
|
|
28
|
+
copy_config = {}
|
|
20
29
|
all_content.each do |config|
|
|
21
30
|
key = config.first
|
|
22
31
|
value = config.second
|
|
23
|
-
|
|
32
|
+
copy_config[key] = value
|
|
24
33
|
|
|
25
34
|
all_content.delete(key)
|
|
26
35
|
end
|
|
27
36
|
|
|
28
37
|
# presetを先に展開する必要があるので、再代入して順番を変更する
|
|
29
|
-
merge(all_content,
|
|
30
|
-
merge(all_content,
|
|
38
|
+
merge(all_content, new_preset_config)
|
|
39
|
+
merge(all_content, copy_config)
|
|
40
|
+
|
|
41
|
+
# presetを展開してpresetが入っていた場合には再度展開する
|
|
42
|
+
if all_content.has_key?(:"preset_path'")
|
|
43
|
+
set(all_content)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
all_content
|
|
31
47
|
end
|
|
32
48
|
|
|
33
49
|
private
|
|
50
|
+
|
|
34
51
|
def merge all_content, merge_hash
|
|
35
52
|
merge_hash.each do |config|
|
|
36
53
|
key = config.first
|
|
37
54
|
value = config.second
|
|
55
|
+
if(all_content.has_key?(key))
|
|
56
|
+
print "\e[31m"
|
|
57
|
+
puts "[ERROR]"
|
|
58
|
+
puts "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+"
|
|
59
|
+
puts "BLOCK: #{key}"
|
|
60
|
+
puts "MESSAGE: Block name conflict has occurred"
|
|
61
|
+
puts "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+"
|
|
62
|
+
print "\e[0m"
|
|
63
|
+
puts ""
|
|
64
|
+
raise PresetError.new("Block name [ #{key} ] conflict has occurred")
|
|
65
|
+
end
|
|
38
66
|
all_content[key] = value
|
|
39
67
|
end
|
|
40
68
|
end
|
|
@@ -4,8 +4,7 @@ module Pokotarou
|
|
|
4
4
|
module ArrayUtils
|
|
5
5
|
# return rotated val in passed array
|
|
6
6
|
def get_rotated_val array, size, cnt
|
|
7
|
-
raise NothingDataError.new("
|
|
8
|
-
raise NothingDataError.new("Seed data is empty") if size.zero?
|
|
7
|
+
raise NothingDataError.new("Seed data is empty") if array.nil? || size.zero?
|
|
9
8
|
x = (size + cnt) / size
|
|
10
9
|
|
|
11
10
|
array[ size + cnt - size * x ]
|
|
@@ -8,6 +8,7 @@ require "pokotarou/parser/return_expression_parser..rb"
|
|
|
8
8
|
|
|
9
9
|
module Pokotarou
|
|
10
10
|
module RegistrationConfigUpdater
|
|
11
|
+
class SeedError < StandardError; end
|
|
11
12
|
class Main
|
|
12
13
|
class << self
|
|
13
14
|
include ArrayUtils
|
|
@@ -98,12 +99,11 @@ module Pokotarou
|
|
|
98
99
|
update_maked_data(maked, sym_block, sym_model, key, seeds )
|
|
99
100
|
update_maked_col(maked_col, sym_model, key, config_data[:col][key])
|
|
100
101
|
config_data[:col][key] = seeds
|
|
101
|
-
|
|
102
|
+
|
|
102
103
|
rescue => e
|
|
103
104
|
print "\e[31m"
|
|
104
|
-
puts "[
|
|
105
|
+
puts "[ERROR]"
|
|
105
106
|
puts "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+"
|
|
106
|
-
puts "Failed Generating seed"
|
|
107
107
|
puts "BLOCK: #{sym_block}"
|
|
108
108
|
puts "MODEL: #{sym_model}"
|
|
109
109
|
puts "COLUMN: #{key}"
|
|
@@ -112,7 +112,7 @@ module Pokotarou
|
|
|
112
112
|
print "\e[0m"
|
|
113
113
|
puts ""
|
|
114
114
|
|
|
115
|
-
raise SeedError.new
|
|
115
|
+
raise SeedError.new("Failed generate seed data")
|
|
116
116
|
end
|
|
117
117
|
end
|
|
118
118
|
|
|
@@ -4,8 +4,6 @@ require "pokotarou/registration_config_updater/main.rb"
|
|
|
4
4
|
module Pokotarou
|
|
5
5
|
module SeedDataRegister
|
|
6
6
|
class Main
|
|
7
|
-
class RegisterError < StandardError; end
|
|
8
|
-
class SeedError < StandardError; end
|
|
9
7
|
|
|
10
8
|
class << self
|
|
11
9
|
def register data
|
|
@@ -21,7 +19,7 @@ module Pokotarou
|
|
|
21
19
|
register_val_by_bulk(sym_block, model_data, maked, model_cache, maked_col)
|
|
22
20
|
end
|
|
23
21
|
rescue => e
|
|
24
|
-
raise
|
|
22
|
+
raise e
|
|
25
23
|
end
|
|
26
24
|
end
|
|
27
25
|
|
|
@@ -39,18 +37,7 @@ module Pokotarou
|
|
|
39
37
|
output_log(model_config[:log])
|
|
40
38
|
insert_record(block_name_sym, model_name, model_config ,model_cache)
|
|
41
39
|
rescue => e
|
|
42
|
-
|
|
43
|
-
puts "[Pokotarou ERROR]"
|
|
44
|
-
puts "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+"
|
|
45
|
-
puts "Failed Register record"
|
|
46
|
-
puts "BLOCK: #{block_name_sym}"
|
|
47
|
-
puts "MODEL: #{model_name}"
|
|
48
|
-
puts "MESSAGE: #{e.message}"
|
|
49
|
-
puts "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+"
|
|
50
|
-
print "\e[0m"
|
|
51
|
-
puts ""
|
|
52
|
-
|
|
53
|
-
raise RegisterError.new
|
|
40
|
+
raise e
|
|
54
41
|
end
|
|
55
42
|
end
|
|
56
43
|
end
|
data/lib/pokotarou/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pokotarou
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.2.
|
|
4
|
+
version: 1.2.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kashiwara
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-05-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -52,6 +52,9 @@ files:
|
|
|
52
52
|
- lib/pokotarou/additional_arguments/main.rb
|
|
53
53
|
- lib/pokotarou/additional_methods/main.rb
|
|
54
54
|
- lib/pokotarou/additional_variables/main.rb
|
|
55
|
+
- lib/pokotarou/handler.rb
|
|
56
|
+
- lib/pokotarou/handler_factory.rb
|
|
57
|
+
- lib/pokotarou/operator.rb
|
|
55
58
|
- lib/pokotarou/p_tool.rb
|
|
56
59
|
- lib/pokotarou/parser/const_parser.rb
|
|
57
60
|
- lib/pokotarou/parser/loop_expression_parser.rb
|
|
@@ -94,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
94
97
|
- !ruby/object:Gem::Version
|
|
95
98
|
version: '0'
|
|
96
99
|
requirements: []
|
|
97
|
-
rubygems_version: 3.0.1
|
|
100
|
+
rubygems_version: 3.0.3.1
|
|
98
101
|
signing_key:
|
|
99
102
|
specification_version: 4
|
|
100
103
|
summary: This gem is seeder which is very usefull
|