pokotarou 1.1.3 → 1.1.4
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/README.md +3 -3
- data/lib/pokotarou/arguments/arguments.rb +1 -0
- data/lib/pokotarou/data_register.rb +4 -36
- data/lib/pokotarou/expression_parser.rb +0 -1
- data/lib/pokotarou/option.rb +2 -2
- data/lib/pokotarou/pokotarou_handler.rb +1 -1
- data/lib/pokotarou/seeder.rb +3 -3
- data/lib/pokotarou/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9f75bcc0cbeeed32c48874cf3ea41817cfe359d82a0aecdc1b5062365bf48d23
|
|
4
|
+
data.tar.gz: bd97590057da55d8a5f6f9e907c7f718030524172a545afb9f00059deb1e0fb5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0777afe90ef3099ebe61bc5956ac9dbf0eb1eb62c4a84658f078af80ae6c40577c24eabfb35b3997b4474bb897e47ed031aab0455c9ad96c9bc2cf6ae0667083
|
|
7
|
+
data.tar.gz: 8c24b5afe74f74a7d2ad274c88b97fdf669c0cc5da1f3cf9d7e997569287ff53c5163a324f23b550827b8e27f1c5c699f0c19d098bdf52ca5bfd1830e7a1fa11
|
data/README.md
CHANGED
|
@@ -27,7 +27,7 @@ If you use __Pokotarou__ about following table.
|
|
|
27
27
|
|created_at|datetime|NO|
|
|
28
28
|
|updated_at|datetime|NO|
|
|
29
29
|
|
|
30
|
-
__Pokotarou__ can register in 0.41s on average.
|
|
30
|
+
__Pokotarou__ can register 10,000 records in 0.41s on average.
|
|
31
31
|
|
|
32
32
|
## Getting started
|
|
33
33
|
Add this line to your application's Gemfile:
|
|
@@ -38,7 +38,7 @@ gem 'pokotarou'
|
|
|
38
38
|
|
|
39
39
|
And then execute:
|
|
40
40
|
```bash
|
|
41
|
-
$ bundle
|
|
41
|
+
$ bundle install
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
Or install it yourself as:
|
|
@@ -101,4 +101,4 @@ Pref.all.count => 3
|
|
|
101
101
|
You can read a lot more about Pokotarou in its [official docs](https://kashiwara0205.github.io/PokotarouDocs/)
|
|
102
102
|
|
|
103
103
|
## License
|
|
104
|
-
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
104
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
@@ -14,7 +14,7 @@ class DataRegister
|
|
|
14
14
|
begin
|
|
15
15
|
data.each do |sym_block, model_data|
|
|
16
16
|
next if is_dush?(sym_block.to_s)
|
|
17
|
-
|
|
17
|
+
register_val_by_bulk(sym_block, model_data, maked, model_cache, maked_col)
|
|
18
18
|
end
|
|
19
19
|
rescue => e
|
|
20
20
|
raise StandardError.new("#{e.message}")
|
|
@@ -26,39 +26,7 @@ class DataRegister
|
|
|
26
26
|
|
|
27
27
|
private
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
Commented because the influence range was large
|
|
31
|
-
Used in later versions
|
|
32
|
-
|
|
33
|
-
def merge_block data
|
|
34
|
-
bulk_hash = {}
|
|
35
|
-
data.each do |block, val|
|
|
36
|
-
next if is_dush?(block.to_s)
|
|
37
|
-
val.each do |model, config|
|
|
38
|
-
if bulk_hash[model].nil?
|
|
39
|
-
bulk_hash[model] = config
|
|
40
|
-
else
|
|
41
|
-
merge_loop(model, config, bulk_hash) if config[:loop].present?
|
|
42
|
-
merge_seed_data(model, config, bulk_hash) if config[:col].present?
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
bulk_hash
|
|
48
|
-
end
|
|
49
|
-
=end
|
|
50
|
-
|
|
51
|
-
def merge_loop model, config, bulk_hash
|
|
52
|
-
bulk_hash[model][:loop] += config[:loop]
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def merge_seed_data model, config, bulk_hash
|
|
56
|
-
config[:col].each do |col_name, seed|
|
|
57
|
-
bulk_hash[model][:col][col_name].concat(seed)
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def setting_register_val_for_bulk sym_block, model_data, maked, model_cache, maked_col
|
|
29
|
+
def register_val_by_bulk sym_block, model_data, maked, model_cache, maked_col
|
|
62
30
|
begin
|
|
63
31
|
model_data.each do |e|
|
|
64
32
|
str_model = e.first.to_s
|
|
@@ -77,7 +45,7 @@ class DataRegister
|
|
|
77
45
|
set_seed_arr(model, sym_block, sym_model, config_data, maked, maked_col)
|
|
78
46
|
|
|
79
47
|
output_log(config_data[:log])
|
|
80
|
-
|
|
48
|
+
insert_record(sym_block, str_model, config_data ,model_cache)
|
|
81
49
|
end
|
|
82
50
|
rescue => e
|
|
83
51
|
raise SettingError.new("
|
|
@@ -90,7 +58,7 @@ class DataRegister
|
|
|
90
58
|
end
|
|
91
59
|
end
|
|
92
60
|
|
|
93
|
-
def
|
|
61
|
+
def insert_record sym_block, str_model, config_data, model_cache
|
|
94
62
|
# col_arr: [:col1, :col2, :col3]
|
|
95
63
|
col_arr = config_data[:col].keys
|
|
96
64
|
# seed_arr: [[elem1, elem2, elem3...]]
|
data/lib/pokotarou/option.rb
CHANGED
|
@@ -37,8 +37,8 @@ class Option
|
|
|
37
37
|
def add option, val, cnt
|
|
38
38
|
# if val is nil, return nil
|
|
39
39
|
return nil if val.nil?
|
|
40
|
-
#
|
|
41
|
-
return val
|
|
40
|
+
# not use '<<' to avoid destructive effect
|
|
41
|
+
return "#{val}_#{cnt}" if option == "add_id"
|
|
42
42
|
|
|
43
43
|
val
|
|
44
44
|
end
|
data/lib/pokotarou/seeder.rb
CHANGED
|
@@ -9,11 +9,11 @@ class Seeder
|
|
|
9
9
|
return make_array(n, ->(){ rand(100) }) if type == "integer"
|
|
10
10
|
return make_array(n, ->(){ rand(0.0..100.0) }) if type == "float"
|
|
11
11
|
return make_array(n, ->(){ rand(0.0..1_000_000_000.0) }) if type == "decimal"
|
|
12
|
-
return make_array(n, ->(){
|
|
13
|
-
return make_array(n, ->(){
|
|
12
|
+
return make_array(n, ->(){ "test_text test_text" }) if type == "string"
|
|
13
|
+
return make_array(n, ->(){ "test_long_text test_long_text test_long_text" }) if ["text", "binary"].include?(type)
|
|
14
14
|
return make_array(n, ->(){ [true, false].sample }) if type == "boolean"
|
|
15
15
|
return make_string_array(n, enum) if type == "string"
|
|
16
|
-
return make_datetime_array() if ["
|
|
16
|
+
return make_datetime_array() if ["datetime", "date", "time"].include?(type)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
private
|
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.1.
|
|
4
|
+
version: 1.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kashiwara
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-02-
|
|
11
|
+
date: 2020-02-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|