pokotarou 1.1.8 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pokotarou.rb +72 -82
- data/lib/pokotarou/additional_arguments/main.rb +24 -0
- data/lib/pokotarou/additional_methods/main.rb +49 -0
- data/lib/pokotarou/additional_variables/main.rb +28 -0
- 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/const_parser.rb +25 -0
- data/lib/pokotarou/parser/loop_expression_parser.rb +32 -0
- data/lib/pokotarou/parser/parser.rb +108 -0
- data/lib/pokotarou/parser/parser_domain.rb +40 -0
- data/lib/pokotarou/parser/return_expression_parser..rb +27 -0
- data/lib/pokotarou/parser/seed_data_expression_parser.rb +18 -0
- data/lib/pokotarou/registration_config_maker/column_domain.rb +17 -0
- data/lib/pokotarou/registration_config_maker/config_domain.rb +48 -0
- data/lib/pokotarou/registration_config_maker/grouping_option_setter.rb +28 -0
- data/lib/pokotarou/registration_config_maker/import_option_setter.rb +13 -0
- data/lib/pokotarou/registration_config_maker/main.rb +71 -0
- data/lib/pokotarou/registration_config_maker/model_option_setter.rb +112 -0
- data/lib/pokotarou/registration_config_maker/preset_option_setter.rb +73 -0
- data/lib/pokotarou/registration_config_maker/template_option_setter.rb +63 -0
- data/lib/pokotarou/registration_config_updater/array_utils.rb +14 -0
- data/lib/pokotarou/registration_config_updater/convert_config.rb +28 -0
- data/lib/pokotarou/registration_config_updater/default_value_maker.rb +32 -0
- data/lib/pokotarou/registration_config_updater/main.rb +170 -0
- data/lib/pokotarou/registration_config_updater/option_config.rb +53 -0
- data/lib/pokotarou/seed_data_register/main.rb +68 -0
- data/lib/pokotarou/version.rb +1 -1
- metadata +30 -18
- data/lib/pokotarou/additional_methods.rb +0 -40
- data/lib/pokotarou/additional_variables/additional_variables.rb +0 -33
- data/lib/pokotarou/additional_variables/def_variable.rb +0 -3
- data/lib/pokotarou/arguments/arguments.rb +0 -24
- data/lib/pokotarou/arguments/def_args.rb +0 -1
- data/lib/pokotarou/array_operation.rb +0 -13
- data/lib/pokotarou/converter.rb +0 -23
- data/lib/pokotarou/data_register.rb +0 -230
- data/lib/pokotarou/data_structure.rb +0 -187
- data/lib/pokotarou/expression_parser.rb +0 -233
- data/lib/pokotarou/file_loader.rb +0 -16
- data/lib/pokotarou/option.rb +0 -46
- data/lib/pokotarou/pokotarou_handler.rb +0 -37
- data/lib/pokotarou/seeder.rb +0 -29
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,112 +1,102 @@
|
|
1
|
-
Dir[File.expand_path('../pokotarou', __FILE__) << '/*.rb'].each do |file|
|
2
|
-
require file
|
3
|
-
end
|
4
|
-
|
5
1
|
require "activerecord-import"
|
2
|
+
require "pokotarou/handler_factory"
|
3
|
+
require "pokotarou/operator"
|
6
4
|
|
7
5
|
module Pokotarou
|
8
|
-
class
|
9
|
-
|
10
|
-
|
11
|
-
def execute input
|
12
|
-
init_proc()
|
13
|
-
|
14
|
-
# if input is filepath, generate config_data
|
15
|
-
return_val =
|
16
|
-
if input.kind_of?(String)
|
17
|
-
DataRegister.register(gen_config(input))
|
18
|
-
else
|
19
|
-
DataRegister.register(input)
|
20
|
-
end
|
6
|
+
class V2
|
7
|
+
def initialize filepath
|
8
|
+
@handler = Pokotarou::HandlerFactory.gen_handler(filepath)
|
21
9
|
|
22
|
-
|
23
|
-
|
24
|
-
return_val
|
10
|
+
return self
|
25
11
|
end
|
26
12
|
|
27
|
-
def
|
28
|
-
|
29
|
-
|
30
|
-
return_vals = []
|
31
|
-
input_arr.each do |e|
|
32
|
-
handler = gen_handler_with_cache(e[:filepath])
|
33
|
-
|
34
|
-
if e[:change_data].present?
|
35
|
-
e[:change_data].each do |block, config|
|
36
|
-
config.each do |model, seed|
|
37
|
-
seed.each do |col_name, val|
|
38
|
-
handler.change_seed(block, model, col_name, val)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
e[:args] ||= {}
|
45
|
-
e[:args][:passed_return_val] = return_vals.last
|
46
|
-
set_args(e[:args])
|
47
|
-
|
48
|
-
return_vals << Pokotarou.execute(handler.get_data())
|
49
|
-
AdditionalMethods.remove_filepathes_from_yml()
|
50
|
-
end
|
51
|
-
|
52
|
-
return_vals
|
13
|
+
def make
|
14
|
+
@handler.make()
|
53
15
|
end
|
54
16
|
|
55
|
-
def
|
56
|
-
|
17
|
+
def delete_block sym_block
|
18
|
+
@handler.delete_block(sym_block)
|
57
19
|
|
58
|
-
|
20
|
+
self
|
59
21
|
end
|
60
22
|
|
61
|
-
def
|
62
|
-
|
63
|
-
end
|
23
|
+
def delete_model sym_block, sym_class
|
24
|
+
@handler.delete_model(sym_block, sym_class)
|
64
25
|
|
65
|
-
|
66
|
-
AdditionalMethods.remove()
|
67
|
-
Arguments.remove()
|
68
|
-
AdditionalVariables.remove()
|
69
|
-
@handler_chache = {}
|
26
|
+
self
|
70
27
|
end
|
71
28
|
|
72
|
-
def
|
73
|
-
|
29
|
+
def delete_col sym_block, sym_class, sym_col
|
30
|
+
@handler.delete_col(sym_block, sym_class, sym_col)
|
74
31
|
|
75
|
-
|
32
|
+
self
|
76
33
|
end
|
77
34
|
|
78
|
-
def
|
79
|
-
|
35
|
+
def change_loop sym_block, sym_class, n
|
36
|
+
@handler.change_loop(sym_block, sym_class, n)
|
37
|
+
|
38
|
+
self
|
39
|
+
end
|
80
40
|
|
81
|
-
|
82
|
-
@
|
41
|
+
def change_seed sym_block, sym_class, sym_col, arr
|
42
|
+
@handler.change_seed(sym_block, sym_class, sym_col, arr)
|
83
43
|
|
84
|
-
|
44
|
+
self
|
85
45
|
end
|
86
46
|
|
87
|
-
|
88
|
-
|
89
|
-
AdditionalMethods.init()
|
47
|
+
def get_data
|
48
|
+
@handler.get_data
|
90
49
|
end
|
91
50
|
|
92
|
-
def
|
93
|
-
|
94
|
-
set_const_val_config(contents)
|
95
|
-
DataStructure.gen(contents)
|
51
|
+
def set_data data
|
52
|
+
@handler.set_data(data)
|
96
53
|
end
|
54
|
+
|
55
|
+
def set_randomincrement sym_block, sym_class, status
|
56
|
+
@handler.set_randomincrement(sym_block, sym_class, status)
|
97
57
|
|
98
|
-
|
99
|
-
AdditionalVariables.set_const(contents)
|
58
|
+
self
|
100
59
|
end
|
101
60
|
|
102
|
-
def
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
else
|
107
|
-
raise NotFoundLoader.new("not found loader")
|
108
|
-
end
|
61
|
+
def set_autoincrement sym_block, sym_class, status
|
62
|
+
@handler.set_autoincrement(sym_block, sym_class, status)
|
63
|
+
|
64
|
+
self
|
109
65
|
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# データ作成メソッドはmakeで統一させる
|
69
|
+
# executeはレガシー扱いに設定する
|
70
|
+
def self.make input
|
71
|
+
Operator.execute(input)
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.execute input
|
75
|
+
Operator.execute(input)
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.pipeline_execute input_arr
|
79
|
+
Operator.pipeline_execute(input_arr)
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.import filepath
|
83
|
+
Operator.import(filepath)
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.set_args hash
|
87
|
+
Operator.set_args(hash)
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.reset
|
91
|
+
Operator.reset()
|
92
|
+
end
|
110
93
|
|
94
|
+
def self.gen_handler filepath
|
95
|
+
HandlerFactory.gen_handler(filepath)
|
111
96
|
end
|
112
|
-
|
97
|
+
|
98
|
+
def self.gen_handler_with_cache filepath
|
99
|
+
HandlerFactory.gen_handler_with_cache(filepath)
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Pokotarou
|
2
|
+
class MisMatchArgType < StandardError; end
|
3
|
+
class AdditionalArguments
|
4
|
+
module Main
|
5
|
+
class << self
|
6
|
+
@args = nil
|
7
|
+
attr_reader :args
|
8
|
+
|
9
|
+
def import hash_data
|
10
|
+
unless hash_data.kind_of?(Hash)
|
11
|
+
raise MisMatchArgType.new("Please use Hash for args")
|
12
|
+
end
|
13
|
+
|
14
|
+
@args = hash_data
|
15
|
+
end
|
16
|
+
|
17
|
+
def remove
|
18
|
+
@args = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Pokotarou
|
2
|
+
module ::Pokotarou::AdditionalMethods
|
3
|
+
module Main
|
4
|
+
class << self
|
5
|
+
attr_reader :filepathes
|
6
|
+
attr_reader :filepathes_from_yml
|
7
|
+
|
8
|
+
@filepathes = []
|
9
|
+
@filepathes_from_yml = []
|
10
|
+
|
11
|
+
def init
|
12
|
+
@filepathes ||= []
|
13
|
+
@filepathes_from_yml = []
|
14
|
+
end
|
15
|
+
|
16
|
+
def import filepath
|
17
|
+
add(@filepathes, filepath)
|
18
|
+
end
|
19
|
+
|
20
|
+
def import_from_yml filepath
|
21
|
+
add(@filepathes_from_yml, filepath)
|
22
|
+
end
|
23
|
+
|
24
|
+
def remove
|
25
|
+
@filepathes = []
|
26
|
+
@filepathes_from_yml = []
|
27
|
+
end
|
28
|
+
|
29
|
+
def remove_filepathes_from_yml
|
30
|
+
@filepathes_from_yml = []
|
31
|
+
end
|
32
|
+
|
33
|
+
def load
|
34
|
+
@filepathes.each do |filepath|; require filepath end
|
35
|
+
@filepathes_from_yml.each do |filepath|; require filepath end
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def add filepath_arr, filepath
|
40
|
+
if filepath.instance_of?(Array)
|
41
|
+
filepath_arr.concat(filepath)
|
42
|
+
else
|
43
|
+
filepath_arr.push(filepath)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Pokotarou
|
2
|
+
class AdditionalVariables
|
3
|
+
module Main
|
4
|
+
class << self
|
5
|
+
CONST_KEY = :"const'"
|
6
|
+
@const = {}
|
7
|
+
attr_reader :const
|
8
|
+
|
9
|
+
def set_const data
|
10
|
+
return {} unless data.has_key?(CONST_KEY)
|
11
|
+
@const = data[CONST_KEY]
|
12
|
+
|
13
|
+
# parse expression configlation
|
14
|
+
@const.each do |key, val|
|
15
|
+
@const[key] = ConstParser.parse(val)
|
16
|
+
end
|
17
|
+
|
18
|
+
data.delete(CONST_KEY)
|
19
|
+
end
|
20
|
+
|
21
|
+
def remove
|
22
|
+
@const = {}
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
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
|