pokotarou 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ac5ca9e6a97f214d20ea830f738f3b444ab696dd83005d0e469bc7f42f2d7d0
4
- data.tar.gz: 8e58ee4c95f0465de660f5c188e9f3b46d3311a4391b0ec1076a855d8d2bb927
3
+ metadata.gz: 52567b76f0cf89c860119076ad2a316aea9d81ab59dda0a93f5ac8ada6f679a2
4
+ data.tar.gz: bd033c9c0f52d2fa01952d4d80923771e6c3311e59979317403cad0baea7e484
5
5
  SHA512:
6
- metadata.gz: 01761775a3d8204d369de8aab3e7bcc52554e96ba89b1aa164b6c25a11a090f99d90f4c9a37fc0426143c0ff24ee8e409adc8b735ddafca0b8f5ebf35d400c0d
7
- data.tar.gz: 608db2c1580ea6151b370e6cb8fb0c97e9f7b902232f6bd73cec988674cb52d7f4e20189092bdc926937d1694307bcae6e03ea825778ab5d37184d8bea0a0aca
6
+ metadata.gz: 27063c77ea44e57f3cf91f7d9e3dc55ebb3da46d223f6db760603616d6bd9abcf35c595f1499dd0bdd7021be33e0761d6035e6efead088a205e751a2251d0251
7
+ data.tar.gz: 3c2087fc63e1ff6f88735c389aa5fcbb2015f8c69450deb00d1011362db62faa8ebec84f17ddb3b91d4d8181a504a810f4f6b1adebbbf96d03eade9bbb5009ab
data/README.md CHANGED
@@ -2,17 +2,17 @@
2
2
  [![Gem Version](https://badge.fury.io/rb/pokotarou.svg)](https://badge.fury.io/rb/pokotarou)
3
3
  [![Build Status](https://travis-ci.org/Tamatebako0205/Pokotarou.svg?branch=master)](https://travis-ci.org/Tamatebako0205/Pokotarou)
4
4
 
5
- Pokotarou is convenient seeder of 'Ruby on Rails' that uses .yml
5
+ Pokotarou is convenient seeder of 'Ruby on Rails'
6
6
  Currently only mysql supported
7
7
 
8
8
  ## Features
9
9
 
10
10
  ### Easy to use
11
- Currently can be used only for simple configuration file settings
12
- You don't have to write a program for seeder
11
+ You don't have to write a program for seed
12
+ Can be set simply by writing a yml file!
13
13
 
14
14
  ### Fast speed
15
- If it is the following table, 10,000 records can regist in 0.4s on average
15
+ If it is the following table, 10,000 records can regist in 0.41s on average
16
16
 
17
17
  |Field|Type|NULL|
18
18
  |:---|:---|:---|
@@ -42,20 +42,34 @@ $ gem install pokotarou
42
42
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
43
43
 
44
44
  ## Usage
45
- Introduce how to execute and write configuration file.
46
- If you want to know more information file settings, please refer to the test
47
45
 
48
- ### Extecute
49
- After write configuration file, execute the following source code in seeds.rb of Ruby on Rails
46
+ Set following configration_file in somewhere.
50
47
 
48
+ ```yml
49
+ Default:
50
+ Pref:
51
+ loop: 3
52
+ ```
53
+
54
+ execute the following ruby code in seeds.rb.
55
+
56
+ ```ruby
57
+ Pokotarou.execute("./config_filepath")
51
58
  ```
52
- Pokotarou.execute(ConfigrationFilePath)
59
+
60
+ run rails db:seed
61
+
62
+ ```bash
63
+ $ rails db:seed
53
64
  ```
65
+
66
+ finish
67
+
54
68
  ### Configration file
55
69
 
56
- Introduce how to write yml configuration file
70
+ Introduce how to write config file
57
71
 
58
- #### Definition for explanation
72
+ #### Model used for explanation
59
73
  Table name below is 'prefs' and model name is 'Pref'
60
74
 
61
75
  |Field|Type|NULL|
@@ -79,20 +93,22 @@ Table name below is 'members' and model name is 'Member'
79
93
  |updated_at|datetime|NO|
80
94
 
81
95
 
82
- #### Default data
83
- If there is no column definition, prepared data is registerd three times
84
- id column is basically registerd by autoincrement
96
+ #### Basic
97
+ If there is no column definition, prepared data is registerd.
85
98
 
86
- ```
99
+ Registered 3 times in the following cases.
100
+
101
+ and id column is basically registerd by autoincrement.
102
+
103
+ ```yml
87
104
  Default:
88
105
  Pref:
89
106
  loop: 3
90
107
  ```
91
108
 
109
+ Also you can set seed_data by yourself.
92
110
 
93
- In the following source code, id, created_at, updated_at will be registerd with the prepared data
94
-
95
- ```
111
+ ```yml
96
112
  Default:
97
113
  Pref:
98
114
  loop: 3
@@ -101,9 +117,11 @@ Default:
101
117
  ```
102
118
 
103
119
  #### Array
104
- Array data is registerd one by one
120
+ You can set array_data.
105
121
 
106
- ```
122
+ Array data is registerd one by one.
123
+
124
+ ```yml
107
125
  Default:
108
126
  Pref:
109
127
  loop: 3
@@ -112,9 +130,13 @@ Default:
112
130
  ```
113
131
 
114
132
  #### Maked data
133
+ 'maked' is very useful function.
134
+
115
135
  Registration is possible using registerd data
116
136
 
117
- ```
137
+ Use maked in different model area in the following cases.
138
+
139
+ ```yml
118
140
  Default:
119
141
  Pref:
120
142
  loop: 2
@@ -127,7 +149,9 @@ Default:
127
149
  pref_id: F|Pref
128
150
  ```
129
151
 
130
- ```
152
+ Use maked in same model area in the following cases.
153
+
154
+ ```yml
131
155
  Default:
132
156
  Pref:
133
157
  loop: 3
@@ -142,7 +166,9 @@ Default:
142
166
 
143
167
  ```
144
168
 
145
- ```
169
+ Use maked in diffrent block area in the following cases.
170
+
171
+ ```yml
146
172
  Default:
147
173
  Pref:
148
174
  loop: 2
@@ -160,10 +186,11 @@ Default2:
160
186
 
161
187
  **※ If you set association(belongs_to, has_many...), Pokotarou automatically register foreign keys**
162
188
 
163
- What a means is ' F| ' foreign key
164
- In the following source code, Foreign key of prefectures is registerd
189
+ ' F| ' means foreign key.
165
190
 
166
- ```
191
+ In the following source code, id of Pref is registerd with Member
192
+
193
+ ```yml
167
194
  Default:
168
195
  Pref:
169
196
  loop: 3
@@ -176,10 +203,11 @@ Default:
176
203
  ```
177
204
 
178
205
  #### Expression expansion
179
- What a means is '< >' expression expansion
206
+ '< >' means expression expansion
207
+
180
208
  You can run ruby code in '< >'
181
209
 
182
- ```
210
+ ```yml
183
211
  Default:
184
212
  Pref:
185
213
  loop: 3
@@ -191,7 +219,7 @@ Default:
191
219
  #### Add method
192
220
  You can add method and use it in pokotarou
193
221
 
194
- ```
222
+ ```yml
195
223
  Default:
196
224
  Pref:
197
225
  loop: 3
@@ -200,16 +228,18 @@ Default:
200
228
  ```
201
229
 
202
230
  Prepare the following ruby file
203
- ```
231
+
232
+ ```ruby
204
233
  def pref_name
205
234
  ["Hokkaido", "Aomori", "Iwate"]
206
235
  end
207
236
  ```
208
- and execute the following source code in seeds.rb of Ruby on Rails
209
237
 
210
- ```
211
- Pokotarou.import(MethodFilePath)
212
- Pokotarou.execute(ConfigrationFilePath)
238
+ and execute the following source code in seeds.rb.
239
+
240
+ ```ruby
241
+ Pokotarou.import("./method_filepath")
242
+ Pokotarou.execute("./config_filepath")
213
243
  ```
214
244
 
215
245
 
@@ -217,7 +247,7 @@ Pokotarou.execute(ConfigrationFilePath)
217
247
 
218
248
  Registration is possible using two blocks
219
249
 
220
- ```
250
+ ```yml
221
251
  Default:
222
252
  Pref:
223
253
  loop: 3
@@ -228,7 +258,7 @@ Default2:
228
258
 
229
259
  and, You can change the name of the block
230
260
 
231
- ```
261
+ ```yml
232
262
  Hoge:
233
263
  Pref:
234
264
  loop: 3
@@ -237,11 +267,10 @@ Fuga:
237
267
  loop: 3
238
268
  ```
239
269
 
240
-
241
270
  #### Random
242
271
  Shuffle seed data when regist
243
272
 
244
- ```
273
+ ```yml
245
274
  Default:
246
275
  Pref:
247
276
  loop: 3
@@ -253,14 +282,14 @@ Default:
253
282
 
254
283
  The following results change from run to run
255
284
 
256
- ```
285
+ ```ruby
257
286
  ["Aomori", "Iwate", "Iwate"]
258
287
  ```
259
288
 
260
289
  #### Add_id
261
290
  Add individual number to seed data of String type
262
291
 
263
- ```
292
+ ```yml
264
293
  Default:
265
294
  Pref:
266
295
  loop: 3
@@ -270,14 +299,14 @@ Default:
270
299
  name: ["add_id"]
271
300
  ```
272
301
 
273
- ```
302
+ ```ruby
274
303
  ["Hokkaido_0", "Aomori"_1, "Iwate_2"]
275
304
  ```
276
305
 
277
306
  #### Combine serveral options
278
307
  Combination of options is possible
279
308
 
280
- ```
309
+ ```yml
281
310
  Default:
282
311
  Pref:
283
312
  loop: 3
@@ -289,7 +318,7 @@ Default:
289
318
 
290
319
  The following results change from run to run
291
320
 
292
- ```
321
+ ```ruby
293
322
  ["Hokkaido_0", "Iwate_1", "Hokkaido_2"]
294
323
  ```
295
324
 
@@ -297,20 +326,20 @@ The following results change from run to run
297
326
 
298
327
  Run validation when regist
299
328
 
300
- ```
329
+ ```yml
301
330
  Default:
302
331
  Pref:
303
332
  loop: 3
304
333
  validate: true
305
334
  ```
306
335
 
307
- #### Autoincrement
336
+ #### Disable Autoincrement
308
337
 
309
338
  You can disable the autoincrement setting
310
339
 
311
- If you disable the setting, you can register id data prepared by myself
340
+ If you disable the setting, you can register id data prepared by yourself
312
341
 
313
- ```
342
+ ```yml
314
343
  Default:
315
344
  Pref:
316
345
  loop: 3
@@ -323,21 +352,53 @@ Default:
323
352
 
324
353
  if you use Pokotarou handler, can update pokotarou's parameter
325
354
 
355
+
356
+ <b>Change Operation</b>
357
+
326
358
  In the following example, the number of loops is changed
327
359
 
328
- ```
329
- handler = Pokotarou.gen_handler("ConfigrationFilePath")
330
- # change loop number
360
+ ```ruby
361
+ handler = Pokotarou.gen_handler("./config_filepath")
362
+ # change loop config
331
363
  handler.change_loop(:Default, :Pref, 6)
332
364
  Pokotarou.execute(handler.get_data)
333
365
  ```
334
366
 
335
- In the following example, delete class in parameter
336
367
 
368
+ In the following example, seed data is changed
369
+
370
+ ```ruby
371
+ handler = Pokotarou.gen_handler("./config_filepath")
372
+ # change seed data config number
373
+ handler.change_seed(:Default, :Pref, :name, ["a", "b", "c"])
374
+ Pokotarou.execute(handler.get_data)
337
375
  ```
338
- handler = Pokotarou.gen_handler("ConfigrationFilePath")
339
- # delete class in parameter
340
- handler.delete(:Default, :Member)
376
+
377
+ <b>Delete Operation</b>
378
+ In the following example, delete block config
379
+
380
+ ```ruby
381
+ handler = Pokotarou.gen_handler("./config_filepath")
382
+ # delete model config in parameter
383
+ handler.delete_block(:Default)
384
+ Pokotarou.execute(handler.get_data)
385
+ ```
386
+
387
+ In the following example, delete model config
388
+
389
+ ```ruby
390
+ handler = Pokotarou.gen_handler("./config_filepath")
391
+ # delete model config in parameter
392
+ handler.delete_model(:Default, :Pref)
393
+ Pokotarou.execute(handler.get_data)
394
+ ```
395
+
396
+ In the following example, delete col config
397
+
398
+ ```ruby
399
+ handler = Pokotarou.gen_handler("./config_filepath")
400
+ # delete col config in parameter
401
+ handler.delete_col(:Default, :Pref, :name)
341
402
  Pokotarou.execute(handler.get_data)
342
403
  ```
343
404
 
@@ -345,7 +406,16 @@ In the following example, delete class in parameter
345
406
 
346
407
  You can convert seed data
347
408
 
348
- ```
409
+ |convert |description |
410
+ |:---------|------------------------------------------|
411
+ | empty | convert val to empty |
412
+ | nil | convert val to nil |
413
+ | big_text | convert val to big_text("text" * 50) |
414
+ | br_text | convert val to br_text("text\n" * 5) |
415
+
416
+ For example, following configfile register seed data while replacing with nil
417
+
418
+ ```yml
349
419
  Default:
350
420
  Pref:
351
421
  loop: 3
@@ -355,13 +425,13 @@ Default:
355
425
  name: ["nil(0..2)"]
356
426
  ```
357
427
 
358
- ```
428
+ ```ruby
359
429
  [nil, nil, nil]
360
430
  ```
361
431
 
362
432
  complex version
363
433
 
364
- ```
434
+ ```yml
365
435
  Default:
366
436
  Pref:
367
437
  loop: 3
@@ -371,13 +441,6 @@ Default:
371
441
  name: ["empty(0..0)", "nil(1..2)"]
372
442
  ```
373
443
 
374
- ```
444
+ ```ruby
375
445
  ["", nil, nil]
376
- ```
377
-
378
- |convert |description |
379
- |:---------|------------------------------------------|
380
- | empty | convert val to empty |
381
- | nil | convert val to nil |
382
- | big_text | convert val to big_text("text" * 50) |
383
- | br_text | convert val to br_text("text\n" * 5) |
446
+ ```
@@ -23,7 +23,7 @@ class PokotarouHandler
23
23
  @data[sym_block][sym_class][:loop] = n
24
24
  end
25
25
 
26
- def change_col sym_block, sym_class, sym_col, arr
26
+ def change_seed sym_block, sym_class, sym_col, arr
27
27
  @data[sym_block][sym_class][:col][sym_col] = arr
28
28
  end
29
29
 
@@ -1,3 +1,3 @@
1
1
  module Pokotarou
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
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.3
4
+ version: 0.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: 2019-08-10 00:00:00.000000000 Z
11
+ date: 2019-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails