pokotarou 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -14
- data/lib/pokotarou/array_operation.rb +13 -0
- data/lib/pokotarou/data_register.rb +1 -1
- data/lib/pokotarou/expression_parser.rb +0 -2
- data/lib/pokotarou/option.rb +5 -1
- data/lib/pokotarou/pokotarou_handler.rb +16 -0
- data/lib/pokotarou/version.rb +1 -1
- metadata +3 -3
- data/lib/pokotarou/my_mthods.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ac5ca9e6a97f214d20ea830f738f3b444ab696dd83005d0e469bc7f42f2d7d0
|
4
|
+
data.tar.gz: 8e58ee4c95f0465de660f5c188e9f3b46d3311a4391b0ec1076a855d8d2bb927
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01761775a3d8204d369de8aab3e7bcc52554e96ba89b1aa164b6c25a11a090f99d90f4c9a37fc0426143c0ff24ee8e409adc8b735ddafca0b8f5ebf35d400c0d
|
7
|
+
data.tar.gz: 608db2c1580ea6151b370e6cb8fb0c97e9f7b902232f6bd73cec988674cb52d7f4e20189092bdc926937d1694307bcae6e03ea825778ab5d37184d8bea0a0aca
|
data/README.md
CHANGED
@@ -13,7 +13,6 @@ You don't have to write a program for seeder
|
|
13
13
|
|
14
14
|
### Fast speed
|
15
15
|
If it is the following table, 10,000 records can regist in 0.4s on average
|
16
|
-
Also, If you enable 'optimize option', 10,000 records can regist in 0.23s on average
|
17
16
|
|
18
17
|
|Field|Type|NULL|
|
19
18
|
|:---|:---|:---|
|
@@ -320,17 +319,6 @@ Default:
|
|
320
319
|
id: [100, 101, 102]
|
321
320
|
```
|
322
321
|
|
323
|
-
#### Optimize
|
324
|
-
|
325
|
-
If you enable 'optimize', Pokotarou Run a query builder, but disable validation
|
326
|
-
|
327
|
-
```
|
328
|
-
Default:
|
329
|
-
Pref:
|
330
|
-
loop: 3
|
331
|
-
optimaize: true
|
332
|
-
```
|
333
|
-
|
334
322
|
#### Pokotarou Handler
|
335
323
|
|
336
324
|
if you use Pokotarou handler, can update pokotarou's parameter
|
@@ -378,7 +366,7 @@ Default:
|
|
378
366
|
Pref:
|
379
367
|
loop: 3
|
380
368
|
col:
|
381
|
-
name: ["
|
369
|
+
name: ["Hokkaido", "Aomori", "Iwate"]
|
382
370
|
convert:
|
383
371
|
name: ["empty(0..0)", "nil(1..2)"]
|
384
372
|
```
|
@@ -392,4 +380,4 @@ Default:
|
|
392
380
|
| empty | convert val to empty |
|
393
381
|
| nil | convert val to nil |
|
394
382
|
| big_text | convert val to big_text("text" * 50) |
|
395
|
-
| br_text | convert val to br_text("text\n" * 5) |
|
383
|
+
| br_text | convert val to br_text("text\n" * 5) |
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class NothingDataError < StandardError; end
|
2
|
+
class ArrayOperation
|
3
|
+
class << self
|
4
|
+
# return rotated val in passed array
|
5
|
+
def get_rotated_val array, size, cnt
|
6
|
+
raise NothingDataError.new("Nothing seed data") if array.nil?
|
7
|
+
raise NothingDataError.new("Seed data is empty") if size.zero?
|
8
|
+
x = (size + cnt) / size
|
9
|
+
|
10
|
+
array[ size + cnt - size * x ]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/pokotarou/option.rb
CHANGED
@@ -9,6 +9,7 @@ class Option
|
|
9
9
|
|
10
10
|
def apply arr, size, option_conf, cnt = 0
|
11
11
|
selected_val = select(option_conf[:select], arr, size, cnt)
|
12
|
+
|
12
13
|
add(option_conf[:add], selected_val, cnt)
|
13
14
|
end
|
14
15
|
|
@@ -28,11 +29,14 @@ class Option
|
|
28
29
|
|
29
30
|
def select option, arr, size, cnt
|
30
31
|
return arr.sample if option == "random"
|
32
|
+
|
31
33
|
# default return rotate
|
32
|
-
get_rotated_val(arr, size, cnt)
|
34
|
+
ArrayOperation.get_rotated_val(arr, size, cnt)
|
33
35
|
end
|
34
36
|
|
35
37
|
def add option, val, cnt
|
38
|
+
# if val is nil, return nil
|
39
|
+
return nil if val.nil?
|
36
40
|
# use '+', not use '<<' to avoid destructive effect
|
37
41
|
return val + "_#{cnt}" if option == "add_id"
|
38
42
|
|
@@ -3,14 +3,30 @@ class PokotarouHandler
|
|
3
3
|
@data = data
|
4
4
|
end
|
5
5
|
|
6
|
+
def delete_block sym_block
|
7
|
+
@data.delete(sym_block)
|
8
|
+
end
|
9
|
+
|
6
10
|
def delete_model sym_block, sym_class
|
7
11
|
@data[sym_block].delete(sym_class)
|
8
12
|
end
|
9
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
|
+
|
10
22
|
def change_loop sym_block, sym_class, n
|
11
23
|
@data[sym_block][sym_class][:loop] = n
|
12
24
|
end
|
13
25
|
|
26
|
+
def change_col sym_block, sym_class, sym_col, arr
|
27
|
+
@data[sym_block][sym_class][:col][sym_col] = arr
|
28
|
+
end
|
29
|
+
|
14
30
|
def get_data
|
15
31
|
@data
|
16
32
|
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: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kashiwara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -50,12 +50,12 @@ files:
|
|
50
50
|
- Rakefile
|
51
51
|
- lib/pokotarou.rb
|
52
52
|
- lib/pokotarou/additional_methods.rb
|
53
|
+
- lib/pokotarou/array_operation.rb
|
53
54
|
- lib/pokotarou/converter.rb
|
54
55
|
- lib/pokotarou/data_register.rb
|
55
56
|
- lib/pokotarou/data_structure.rb
|
56
57
|
- lib/pokotarou/expression_parser.rb
|
57
58
|
- lib/pokotarou/loader.rb
|
58
|
-
- lib/pokotarou/my_mthods.rb
|
59
59
|
- lib/pokotarou/option.rb
|
60
60
|
- lib/pokotarou/pokotarou_handler.rb
|
61
61
|
- lib/pokotarou/query_builder.rb
|
data/lib/pokotarou/my_mthods.rb
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
class NothingDataError < StandardError; end
|
2
|
-
|
3
|
-
# return rotated val in passed array
|
4
|
-
def get_rotated_val array, size, cnt
|
5
|
-
raise NothingDataError.new("Nothing seed data") if array.nil?
|
6
|
-
raise NothingDataError.new("Seed data is empty") if size.zero?
|
7
|
-
x = (size + cnt) / size
|
8
|
-
array[ size + cnt - size * x ]
|
9
|
-
end
|