pokotarou 1.1.9 → 1.2.0
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 +158 -76
- data/lib/pokotarou/data_register.rb +7 -4
- data/lib/pokotarou/version.rb +1 -1
- metadata +2 -3
- data/lib/pokotarou/pokotarou_handler.rb +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0313ae9034a4b9ed1a64829a7d16a1811df5da6937f5639a8e3700a7c658a211
|
4
|
+
data.tar.gz: b7b90ac0f1fd81f2fb11e015ee0cfd6b8b38544f4e0ed272ee1a834dc05cf340
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79b8112bd089213e28269d6cced5a1cc4157453079a3502218d4afecc01864393a6aab6dad7dc238dd257c8b47e0ba53c0fface455e2f32fa590bab8fa6fda02
|
7
|
+
data.tar.gz: 27462bd7caa6e7173a623fdbabaa406141a6cbd80618c70e7581355f2521d3921b75b0225f1503b3236aad45efab3645b8505b92033cabd21163c93ea9102028
|
data/lib/pokotarou.rb
CHANGED
@@ -5,108 +5,190 @@ end
|
|
5
5
|
require "activerecord-import"
|
6
6
|
|
7
7
|
module Pokotarou
|
8
|
-
class
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
8
|
+
class Operater
|
9
|
+
class NotFoundLoader < StandardError; end
|
10
|
+
class << self
|
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
|
21
|
+
|
22
|
+
AdditionalMethods.remove_filepathes_from_yml()
|
23
|
+
|
24
|
+
return_val
|
25
|
+
end
|
26
|
+
|
27
|
+
def pipeline_execute input_arr
|
28
|
+
init_proc()
|
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
|
39
40
|
end
|
40
41
|
end
|
41
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()
|
42
50
|
end
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
51
|
+
|
52
|
+
return_vals
|
53
|
+
end
|
54
|
+
|
55
|
+
def import filepath
|
56
|
+
init_proc()
|
57
|
+
|
58
|
+
AdditionalMethods.import(filepath)
|
59
|
+
end
|
60
|
+
|
61
|
+
def set_args hash
|
62
|
+
Arguments.import(hash)
|
63
|
+
end
|
64
|
+
|
65
|
+
def reset
|
66
|
+
AdditionalMethods.remove()
|
67
|
+
Arguments.remove()
|
68
|
+
AdditionalVariables.remove()
|
69
|
+
@handler_chache = {}
|
70
|
+
end
|
71
|
+
|
72
|
+
def gen_handler filepath
|
73
|
+
init_proc()
|
74
|
+
|
75
|
+
PokotarouHandler.new(gen_config(filepath))
|
76
|
+
end
|
77
|
+
|
78
|
+
def gen_handler_with_cache filepath
|
79
|
+
init_proc()
|
80
|
+
|
81
|
+
@handler_cache ||= {}
|
82
|
+
@handler_cache[filepath] ||= PokotarouHandler.new(gen_config(filepath))
|
83
|
+
|
84
|
+
@handler_cache[filepath].deep_dup
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
def init_proc
|
89
|
+
AdditionalMethods.init()
|
50
90
|
end
|
91
|
+
|
92
|
+
def gen_config filepath
|
93
|
+
contents = load_file(filepath)
|
94
|
+
set_const_val_config(contents)
|
95
|
+
DataStructure.gen(contents)
|
96
|
+
end
|
97
|
+
|
98
|
+
def set_const_val_config contents
|
99
|
+
AdditionalVariables.set_const(contents)
|
100
|
+
end
|
101
|
+
|
102
|
+
def load_file filepath
|
103
|
+
case File.extname(filepath)
|
104
|
+
when ".yml"
|
105
|
+
return YmlLoader.load(filepath)
|
106
|
+
else
|
107
|
+
raise NotFoundLoader.new("not found loader")
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
51
113
|
|
52
|
-
|
114
|
+
module Pokotarou
|
115
|
+
class << self
|
116
|
+
def execute input
|
117
|
+
Operater.execute(input)
|
53
118
|
end
|
54
119
|
|
55
|
-
def
|
56
|
-
|
120
|
+
def pipeline_execute input_arr
|
121
|
+
Operater.pipeline_execute(input_arr)
|
122
|
+
end
|
57
123
|
|
58
|
-
|
124
|
+
def import filepath
|
125
|
+
Operater.import(filepath)
|
59
126
|
end
|
60
127
|
|
61
128
|
def set_args hash
|
62
|
-
|
129
|
+
Operater.set_args(hash)
|
63
130
|
end
|
64
131
|
|
65
132
|
def reset
|
66
|
-
|
67
|
-
Arguments.remove()
|
68
|
-
AdditionalVariables.remove()
|
69
|
-
@handler_chache = {}
|
133
|
+
Operater.reset()
|
70
134
|
end
|
71
135
|
|
72
136
|
def gen_handler filepath
|
73
|
-
|
74
|
-
|
75
|
-
PokotarouHandler.new(gen_config(filepath))
|
137
|
+
Operater.gen_handler(filepath)
|
76
138
|
end
|
77
139
|
|
78
140
|
def gen_handler_with_cache filepath
|
79
|
-
|
141
|
+
Operater.gen_handler_with_cache(filepath)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
80
145
|
|
81
|
-
|
82
|
-
|
146
|
+
class PokotarouHandler
|
147
|
+
def initialize data
|
148
|
+
@data = data
|
149
|
+
end
|
83
150
|
|
84
|
-
|
85
|
-
|
151
|
+
def make
|
152
|
+
::Pokotarou::Operater.execute(get_data())
|
153
|
+
end
|
86
154
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
end
|
155
|
+
def delete_block sym_block
|
156
|
+
@data.delete(sym_block)
|
157
|
+
end
|
91
158
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
DataStructure.gen(contents)
|
96
|
-
end
|
159
|
+
def delete_model sym_block, sym_class
|
160
|
+
@data[sym_block].delete(sym_class)
|
161
|
+
end
|
97
162
|
|
98
|
-
|
99
|
-
|
100
|
-
end
|
163
|
+
def delete_col sym_block, sym_class, sym_col
|
164
|
+
exists_content = ->(key){ @data[sym_block][sym_class][key].present? }
|
101
165
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
else
|
107
|
-
raise NotFoundLoader.new("not found loader")
|
108
|
-
end
|
109
|
-
end
|
166
|
+
@data[sym_block][sym_class][:col].delete(sym_col) if exists_content.call(:col)
|
167
|
+
@data[sym_block][sym_class][:option].delete(sym_col) if exists_content.call(:option)
|
168
|
+
@data[sym_block][sym_class][:convert].delete(sym_col) if exists_content.call(:convert)
|
169
|
+
end
|
110
170
|
|
171
|
+
def change_loop sym_block, sym_class, n
|
172
|
+
@data[sym_block][sym_class][:loop] = n
|
111
173
|
end
|
112
|
-
|
174
|
+
|
175
|
+
def change_seed sym_block, sym_class, sym_col, arr
|
176
|
+
@data[sym_block][sym_class][:col][sym_col] = arr
|
177
|
+
end
|
178
|
+
|
179
|
+
def get_data
|
180
|
+
@data.deep_dup
|
181
|
+
end
|
182
|
+
|
183
|
+
def set_data data
|
184
|
+
@data = data
|
185
|
+
end
|
186
|
+
|
187
|
+
def set_randomincrement sym_block, sym_class, status
|
188
|
+
@data[sym_block][sym_class][:randomincrement] = status
|
189
|
+
end
|
190
|
+
|
191
|
+
def set_autoincrement sym_block, sym_class, status
|
192
|
+
@data[sym_block][sym_class][:autoincrement] = status
|
193
|
+
end
|
194
|
+
end
|
@@ -171,20 +171,23 @@ class DataRegister
|
|
171
171
|
end
|
172
172
|
|
173
173
|
def set_autoincrement config_data, model, loop_size, prev_id_arr
|
174
|
-
|
174
|
+
max_id = model.maximum(:id)
|
175
|
+
|
175
176
|
current_id =
|
176
177
|
if prev_id_arr.present?
|
177
178
|
prev_id_arr.last
|
178
|
-
elsif
|
179
|
+
elsif max_id.nil?
|
179
180
|
0
|
180
181
|
else
|
181
|
-
|
182
|
+
max_id
|
182
183
|
end
|
183
184
|
|
184
185
|
additions = current_id + loop_size
|
185
186
|
next_id = current_id + 1
|
186
187
|
|
187
|
-
|
188
|
+
ids = [*next_id..additions]
|
189
|
+
ids.shuffle! if config_data[:randomincrement]
|
190
|
+
config_data[:col][:id] = ids
|
188
191
|
end
|
189
192
|
|
190
193
|
def set_expand_expression config_data, key, val, maked, maked_col
|
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.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kashiwara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -62,7 +62,6 @@ files:
|
|
62
62
|
- lib/pokotarou/file_loader.rb
|
63
63
|
- lib/pokotarou/option.rb
|
64
64
|
- lib/pokotarou/p_tool.rb
|
65
|
-
- lib/pokotarou/pokotarou_handler.rb
|
66
65
|
- lib/pokotarou/seeder.rb
|
67
66
|
- lib/pokotarou/version.rb
|
68
67
|
- lib/tasks/pokotarou_tasks.rake
|
@@ -1,37 +0,0 @@
|
|
1
|
-
class PokotarouHandler
|
2
|
-
def initialize data
|
3
|
-
@data = data
|
4
|
-
end
|
5
|
-
|
6
|
-
def delete_block sym_block
|
7
|
-
@data.delete(sym_block)
|
8
|
-
end
|
9
|
-
|
10
|
-
def delete_model sym_block, sym_class
|
11
|
-
@data[sym_block].delete(sym_class)
|
12
|
-
end
|
13
|
-
|
14
|
-
def delete_col sym_block, sym_class, sym_col
|
15
|
-
exists_content = ->(key){ @data[sym_block][sym_class][key].present? }
|
16
|
-
|
17
|
-
@data[sym_block][sym_class][:col].delete(sym_col) if exists_content.call(:col)
|
18
|
-
@data[sym_block][sym_class][:option].delete(sym_col) if exists_content.call(:option)
|
19
|
-
@data[sym_block][sym_class][:convert].delete(sym_col) if exists_content.call(:convert)
|
20
|
-
end
|
21
|
-
|
22
|
-
def change_loop sym_block, sym_class, n
|
23
|
-
@data[sym_block][sym_class][:loop] = n
|
24
|
-
end
|
25
|
-
|
26
|
-
def change_seed sym_block, sym_class, sym_col, arr
|
27
|
-
@data[sym_block][sym_class][:col][sym_col] = arr
|
28
|
-
end
|
29
|
-
|
30
|
-
def get_data
|
31
|
-
@data.deep_dup
|
32
|
-
end
|
33
|
-
|
34
|
-
def set_data data
|
35
|
-
@data = data
|
36
|
-
end
|
37
|
-
end
|