mi 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/.rubocop.yml +490 -0
- data/.travis.yml +14 -0
- data/Guardfile +82 -0
- data/README.md +54 -6
- data/lib/generators/mi/mi_generator.rb +26 -6
- data/lib/mi/version.rb +1 -1
- data/mi.gemspec +11 -2
- metadata +106 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d5312b8b93dae6b7ce277263007c40397213704
|
4
|
+
data.tar.gz: f04ce7d04fe4dec0f4346f65da646ead3266169b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 377469978ee9420f5a7fc4b1ba93e135a2138bcc5121e7b39aad1038db563daf9972638076cce6704954c29b2a30f60cdb09ec33db18ac703078bd441f3b5116
|
7
|
+
data.tar.gz: 6a9d385bd1a6e324310aa0b0bf6fdc8edc708ae54446158edf75a473ea87355485818fc681139e39d886e1ef1aa757afd499bf80598d8dfe101e5f4661b12188
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,490 @@
|
|
1
|
+
AllCops:
|
2
|
+
Exclude:
|
3
|
+
- 'vendor/**/*'
|
4
|
+
DisplayCopNames: true
|
5
|
+
TargetRubyVersion: 2.3
|
6
|
+
|
7
|
+
Rails:
|
8
|
+
Enabled: true
|
9
|
+
|
10
|
+
Style/BlockDelimiters:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Style/AccessModifierIndentation:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Style/AccessorMethodName:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Style/Alias:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Style/AlignArray:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Style/AlignHash:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
Style/AlignParameters:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
Style/AndOr:
|
32
|
+
Enabled: false
|
33
|
+
|
34
|
+
Style/ArrayJoin:
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
Style/AsciiComments:
|
38
|
+
Enabled: false
|
39
|
+
|
40
|
+
Style/AsciiIdentifiers:
|
41
|
+
Enabled: false
|
42
|
+
|
43
|
+
Style/Attr:
|
44
|
+
Enabled: false
|
45
|
+
|
46
|
+
Style/BeginBlock:
|
47
|
+
Enabled: false
|
48
|
+
|
49
|
+
Style/BarePercentLiterals:
|
50
|
+
Enabled: false
|
51
|
+
|
52
|
+
Style/BlockComments:
|
53
|
+
Enabled: false
|
54
|
+
|
55
|
+
Style/BlockEndNewline:
|
56
|
+
Enabled: false
|
57
|
+
|
58
|
+
Style/BracesAroundHashParameters:
|
59
|
+
Enabled: false
|
60
|
+
|
61
|
+
Style/CaseEquality:
|
62
|
+
Enabled: true
|
63
|
+
|
64
|
+
Style/CaseIndentation:
|
65
|
+
Enabled: false
|
66
|
+
|
67
|
+
Style/CharacterLiteral:
|
68
|
+
Enabled: false
|
69
|
+
|
70
|
+
Style/ClassAndModuleCamelCase:
|
71
|
+
Enabled: false
|
72
|
+
|
73
|
+
Style/ClassAndModuleChildren:
|
74
|
+
Enabled: false
|
75
|
+
|
76
|
+
Style/ClassCheck:
|
77
|
+
Enabled: false
|
78
|
+
|
79
|
+
Style/ClassMethods:
|
80
|
+
Enabled: false
|
81
|
+
|
82
|
+
Style/ClassVars:
|
83
|
+
Enabled: false
|
84
|
+
|
85
|
+
Style/ColonMethodCall:
|
86
|
+
Enabled: false
|
87
|
+
|
88
|
+
Style/ClosingParenthesisIndentation:
|
89
|
+
Enabled: false
|
90
|
+
|
91
|
+
Style/CommentAnnotation:
|
92
|
+
Enabled: false
|
93
|
+
|
94
|
+
Style/CommentIndentation:
|
95
|
+
Enabled: false
|
96
|
+
|
97
|
+
Style/ConstantName:
|
98
|
+
Enabled: false
|
99
|
+
|
100
|
+
Style/DefWithParentheses:
|
101
|
+
Enabled: false
|
102
|
+
|
103
|
+
Style/DeprecatedHashMethods:
|
104
|
+
Enabled: false
|
105
|
+
|
106
|
+
Style/Documentation:
|
107
|
+
Enabled: false
|
108
|
+
|
109
|
+
Style/DotPosition:
|
110
|
+
Enabled: false
|
111
|
+
|
112
|
+
Style/DoubleNegation:
|
113
|
+
Enabled: false
|
114
|
+
|
115
|
+
Style/EachWithObject:
|
116
|
+
Enabled: false
|
117
|
+
|
118
|
+
Style/ElseAlignment:
|
119
|
+
Enabled: false
|
120
|
+
|
121
|
+
Style/EmptyElse:
|
122
|
+
Enabled: false
|
123
|
+
|
124
|
+
Style/EmptyLineBetweenDefs:
|
125
|
+
Enabled: false
|
126
|
+
|
127
|
+
Style/EmptyLines:
|
128
|
+
Enabled: false
|
129
|
+
|
130
|
+
Style/EmptyLinesAroundAccessModifier:
|
131
|
+
Enabled: false
|
132
|
+
|
133
|
+
Style/EmptyLinesAroundBlockBody:
|
134
|
+
Enabled: false
|
135
|
+
|
136
|
+
Style/EmptyLinesAroundClassBody:
|
137
|
+
Enabled: false
|
138
|
+
|
139
|
+
Style/EmptyLinesAroundModuleBody:
|
140
|
+
Enabled: false
|
141
|
+
|
142
|
+
Style/EmptyLinesAroundMethodBody:
|
143
|
+
Enabled: false
|
144
|
+
|
145
|
+
Style/EmptyLiteral:
|
146
|
+
Enabled: false
|
147
|
+
|
148
|
+
Style/EndBlock:
|
149
|
+
Enabled: false
|
150
|
+
|
151
|
+
Style/EndOfLine:
|
152
|
+
Enabled: false
|
153
|
+
|
154
|
+
Style/EvenOdd:
|
155
|
+
Enabled: false
|
156
|
+
|
157
|
+
Style/ExtraSpacing:
|
158
|
+
Enabled: false
|
159
|
+
|
160
|
+
Style/FileName:
|
161
|
+
Enabled: false
|
162
|
+
|
163
|
+
Style/FirstParameterIndentation:
|
164
|
+
Enabled: false
|
165
|
+
|
166
|
+
Style/FlipFlop:
|
167
|
+
Enabled: false
|
168
|
+
|
169
|
+
Style/For:
|
170
|
+
Enabled: false
|
171
|
+
|
172
|
+
Style/FormatString:
|
173
|
+
Enabled: false
|
174
|
+
|
175
|
+
Style/FrozenStringLiteralComment:
|
176
|
+
Enabled: false
|
177
|
+
|
178
|
+
Style/GlobalVars:
|
179
|
+
Enabled: true
|
180
|
+
|
181
|
+
Style/GuardClause:
|
182
|
+
Enabled: false
|
183
|
+
|
184
|
+
Style/HashSyntax:
|
185
|
+
Enabled: true
|
186
|
+
SupportedStyles:
|
187
|
+
- ruby19
|
188
|
+
- ruby19_no_mixed_keys
|
189
|
+
- hash_rockets
|
190
|
+
UseHashRocketsWithSymbolValues: false
|
191
|
+
|
192
|
+
Style/IfUnlessModifier:
|
193
|
+
Enabled: false
|
194
|
+
|
195
|
+
Style/IfWithSemicolon:
|
196
|
+
Enabled: false
|
197
|
+
|
198
|
+
Style/IndentationConsistency:
|
199
|
+
Enabled: false
|
200
|
+
|
201
|
+
Style/IndentationWidth:
|
202
|
+
Enabled: true
|
203
|
+
Width: 2
|
204
|
+
|
205
|
+
Style/IndentArray:
|
206
|
+
Enabled: false
|
207
|
+
|
208
|
+
Style/IndentHash:
|
209
|
+
Enabled: false
|
210
|
+
|
211
|
+
Style/InfiniteLoop:
|
212
|
+
Enabled: false
|
213
|
+
|
214
|
+
Style/Lambda:
|
215
|
+
Enabled: false
|
216
|
+
|
217
|
+
Style/LambdaCall:
|
218
|
+
Enabled: false
|
219
|
+
|
220
|
+
Style/LeadingCommentSpace:
|
221
|
+
Enabled: false
|
222
|
+
|
223
|
+
Style/LineEndConcatenation:
|
224
|
+
Enabled: false
|
225
|
+
|
226
|
+
Style/MethodCallParentheses:
|
227
|
+
Enabled: false
|
228
|
+
|
229
|
+
Style/MethodDefParentheses:
|
230
|
+
Enabled: false
|
231
|
+
|
232
|
+
Style/MethodName:
|
233
|
+
Enabled: false
|
234
|
+
|
235
|
+
Style/ModuleFunction:
|
236
|
+
Enabled: false
|
237
|
+
|
238
|
+
Style/MultilineBlockChain:
|
239
|
+
Enabled: false
|
240
|
+
|
241
|
+
Style/MultilineBlockLayout:
|
242
|
+
Enabled: false
|
243
|
+
|
244
|
+
Style/MultilineIfThen:
|
245
|
+
Enabled: false
|
246
|
+
|
247
|
+
Style/MultilineOperationIndentation:
|
248
|
+
Enabled: false
|
249
|
+
|
250
|
+
Style/MultilineTernaryOperator:
|
251
|
+
Enabled: false
|
252
|
+
|
253
|
+
Style/NegatedIf:
|
254
|
+
Enabled: false
|
255
|
+
|
256
|
+
Style/NegatedWhile:
|
257
|
+
Enabled: false
|
258
|
+
|
259
|
+
Style/NestedTernaryOperator:
|
260
|
+
Enabled: false
|
261
|
+
|
262
|
+
Style/Next:
|
263
|
+
Enabled: false
|
264
|
+
|
265
|
+
Style/NilComparison:
|
266
|
+
Enabled: false
|
267
|
+
|
268
|
+
Style/NonNilCheck:
|
269
|
+
Enabled: false
|
270
|
+
|
271
|
+
Style/Not:
|
272
|
+
Enabled: false
|
273
|
+
|
274
|
+
Style/NumericLiterals:
|
275
|
+
Enabled: false
|
276
|
+
|
277
|
+
Style/OneLineConditional:
|
278
|
+
Enabled: false
|
279
|
+
|
280
|
+
Style/OpMethod:
|
281
|
+
Enabled: false
|
282
|
+
|
283
|
+
Style/ParenthesesAroundCondition:
|
284
|
+
Enabled: false
|
285
|
+
|
286
|
+
Style/PercentLiteralDelimiters:
|
287
|
+
Enabled: false
|
288
|
+
|
289
|
+
Style/PercentQLiterals:
|
290
|
+
Enabled: false
|
291
|
+
|
292
|
+
Style/PerlBackrefs:
|
293
|
+
Enabled: false
|
294
|
+
|
295
|
+
Style/PredicateName:
|
296
|
+
Enabled: false
|
297
|
+
|
298
|
+
Style/Proc:
|
299
|
+
Enabled: false
|
300
|
+
|
301
|
+
Style/RaiseArgs:
|
302
|
+
Enabled: false
|
303
|
+
|
304
|
+
Style/RedundantBegin:
|
305
|
+
Enabled: false
|
306
|
+
|
307
|
+
Style/RedundantException:
|
308
|
+
Enabled: false
|
309
|
+
|
310
|
+
Style/RedundantReturn:
|
311
|
+
Enabled: false
|
312
|
+
|
313
|
+
Style/RedundantSelf:
|
314
|
+
Enabled: false
|
315
|
+
|
316
|
+
Style/RegexpLiteral:
|
317
|
+
Enabled: false
|
318
|
+
|
319
|
+
Style/RescueModifier:
|
320
|
+
Enabled: false
|
321
|
+
|
322
|
+
Style/SelfAssignment:
|
323
|
+
Enabled: false
|
324
|
+
|
325
|
+
Style/Semicolon:
|
326
|
+
Enabled: false
|
327
|
+
|
328
|
+
Style/SignalException:
|
329
|
+
Enabled: false
|
330
|
+
|
331
|
+
Style/SingleLineBlockParams:
|
332
|
+
Enabled: false
|
333
|
+
|
334
|
+
Style/SingleLineMethods:
|
335
|
+
Enabled: false
|
336
|
+
|
337
|
+
Style/SpaceBeforeFirstArg:
|
338
|
+
Enabled: false
|
339
|
+
|
340
|
+
Style/SpaceAfterColon:
|
341
|
+
Enabled: false
|
342
|
+
|
343
|
+
Style/SpaceAfterComma:
|
344
|
+
Enabled: false
|
345
|
+
|
346
|
+
Style/SpaceAroundKeyword:
|
347
|
+
Enabled: false
|
348
|
+
|
349
|
+
Style/SpaceAfterMethodName:
|
350
|
+
Enabled: false
|
351
|
+
|
352
|
+
Style/SpaceAfterNot:
|
353
|
+
Enabled: false
|
354
|
+
|
355
|
+
Style/SpaceAfterSemicolon:
|
356
|
+
Enabled: false
|
357
|
+
|
358
|
+
Style/SpaceBeforeBlockBraces:
|
359
|
+
Enabled: false
|
360
|
+
|
361
|
+
Style/SpaceBeforeComma:
|
362
|
+
Enabled: false
|
363
|
+
|
364
|
+
Style/SpaceBeforeComment:
|
365
|
+
Enabled: false
|
366
|
+
|
367
|
+
Style/SpaceBeforeSemicolon:
|
368
|
+
Enabled: false
|
369
|
+
|
370
|
+
Style/SpaceInsideBlockBraces:
|
371
|
+
Enabled: false
|
372
|
+
|
373
|
+
Style/SpaceAroundBlockParameters:
|
374
|
+
Enabled: false
|
375
|
+
|
376
|
+
Style/SpaceAroundEqualsInParameterDefault:
|
377
|
+
Enabled: false
|
378
|
+
|
379
|
+
Style/SpaceAroundOperators:
|
380
|
+
Enabled: false
|
381
|
+
|
382
|
+
Style/SpaceInsideBrackets:
|
383
|
+
Enabled: false
|
384
|
+
|
385
|
+
Style/SpaceInsideHashLiteralBraces:
|
386
|
+
Enabled: false
|
387
|
+
|
388
|
+
Style/SpaceInsideParens:
|
389
|
+
Enabled: false
|
390
|
+
|
391
|
+
Style/SpaceInsideRangeLiteral:
|
392
|
+
Enabled: false
|
393
|
+
|
394
|
+
Style/SpecialGlobalVars:
|
395
|
+
Enabled: false
|
396
|
+
|
397
|
+
Style/StringLiterals:
|
398
|
+
Enabled: false
|
399
|
+
|
400
|
+
Style/StringLiteralsInInterpolation:
|
401
|
+
Enabled: false
|
402
|
+
|
403
|
+
Style/StructInheritance:
|
404
|
+
Enabled: false
|
405
|
+
|
406
|
+
Style/SymbolProc:
|
407
|
+
Enabled: false
|
408
|
+
|
409
|
+
Style/Tab:
|
410
|
+
Enabled: false
|
411
|
+
|
412
|
+
Style/TrailingBlankLines:
|
413
|
+
Enabled: false
|
414
|
+
|
415
|
+
Style/TrailingCommaInLiteral:
|
416
|
+
Enabled: true
|
417
|
+
EnforcedStyleForMultiline: comma
|
418
|
+
|
419
|
+
Style/TrailingCommaInArguments:
|
420
|
+
Enabled: true
|
421
|
+
EnforcedStyleForMultiline: comma
|
422
|
+
|
423
|
+
Style/TrailingWhitespace:
|
424
|
+
Enabled: false
|
425
|
+
|
426
|
+
Style/TrivialAccessors:
|
427
|
+
Enabled: false
|
428
|
+
|
429
|
+
Style/UnlessElse:
|
430
|
+
Enabled: false
|
431
|
+
|
432
|
+
Style/UnneededCapitalW:
|
433
|
+
Enabled: false
|
434
|
+
|
435
|
+
Style/UnneededPercentQ:
|
436
|
+
Enabled: false
|
437
|
+
|
438
|
+
Style/VariableInterpolation:
|
439
|
+
Enabled: false
|
440
|
+
|
441
|
+
Style/VariableName:
|
442
|
+
Enabled: false
|
443
|
+
|
444
|
+
Style/WhenThen:
|
445
|
+
Enabled: false
|
446
|
+
|
447
|
+
Style/WhileUntilDo:
|
448
|
+
Enabled: false
|
449
|
+
|
450
|
+
Style/WhileUntilModifier:
|
451
|
+
Enabled: false
|
452
|
+
|
453
|
+
Style/WordArray:
|
454
|
+
Enabled: false
|
455
|
+
|
456
|
+
Lint/EndAlignment:
|
457
|
+
Enabled: false
|
458
|
+
|
459
|
+
Lint/StringConversionInInterpolation:
|
460
|
+
Enabled: false
|
461
|
+
|
462
|
+
Lint/AssignmentInCondition:
|
463
|
+
Enabled: false
|
464
|
+
|
465
|
+
Metrics/AbcSize:
|
466
|
+
Enabled: false
|
467
|
+
|
468
|
+
Metrics/BlockNesting:
|
469
|
+
Enabled: false
|
470
|
+
|
471
|
+
Metrics/ClassLength:
|
472
|
+
Enabled: false
|
473
|
+
|
474
|
+
Metrics/CyclomaticComplexity:
|
475
|
+
Enabled: false
|
476
|
+
|
477
|
+
Metrics/LineLength:
|
478
|
+
Enabled: false
|
479
|
+
|
480
|
+
Metrics/MethodLength:
|
481
|
+
Enabled: false
|
482
|
+
|
483
|
+
Metrics/ModuleLength:
|
484
|
+
Enabled: false
|
485
|
+
|
486
|
+
Metrics/ParameterLists:
|
487
|
+
Enabled: false
|
488
|
+
|
489
|
+
Metrics/PerceivedComplexity:
|
490
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features) \
|
6
|
+
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
guard :bundler do
|
19
|
+
require 'guard/bundler'
|
20
|
+
require 'guard/bundler/verify'
|
21
|
+
helper = Guard::Bundler::Verify.new
|
22
|
+
|
23
|
+
files = ['Gemfile']
|
24
|
+
files += Dir['*.gemspec'] if files.any? { |f| helper.uses_gemspec?(f) }
|
25
|
+
|
26
|
+
# Assume files are symlinked from somewhere
|
27
|
+
files.each { |file| watch(helper.real_path(file)) }
|
28
|
+
end
|
29
|
+
|
30
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
31
|
+
# rspec may be run, below are examples of the most common uses.
|
32
|
+
# * bundler: 'bundle exec rspec'
|
33
|
+
# * bundler binstubs: 'bin/rspec'
|
34
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
35
|
+
# installed the spring binstubs per the docs)
|
36
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
37
|
+
# * 'just' rspec: 'rspec'
|
38
|
+
|
39
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
40
|
+
require "guard/rspec/dsl"
|
41
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
42
|
+
|
43
|
+
# Feel free to open issues for suggestions and improvements
|
44
|
+
|
45
|
+
# RSpec files
|
46
|
+
rspec = dsl.rspec
|
47
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
48
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
49
|
+
watch(rspec.spec_files)
|
50
|
+
|
51
|
+
# Ruby files
|
52
|
+
ruby = dsl.ruby
|
53
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
54
|
+
|
55
|
+
# Rails files
|
56
|
+
rails = dsl.rails(view_extensions: %w(erb haml slim))
|
57
|
+
dsl.watch_spec_files_for(rails.app_files)
|
58
|
+
dsl.watch_spec_files_for(rails.views)
|
59
|
+
|
60
|
+
watch(rails.controllers) do |m|
|
61
|
+
[
|
62
|
+
rspec.spec.("routing/#{m[1]}_routing"),
|
63
|
+
rspec.spec.("controllers/#{m[1]}_controller"),
|
64
|
+
rspec.spec.("acceptance/#{m[1]}")
|
65
|
+
]
|
66
|
+
end
|
67
|
+
|
68
|
+
# Rails config changes
|
69
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
70
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
71
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
72
|
+
|
73
|
+
# Capybara features specs
|
74
|
+
watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
|
75
|
+
watch(rails.layouts) { |m| rspec.spec.("features/#{m[1]}") }
|
76
|
+
|
77
|
+
# Turnip features and steps
|
78
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
79
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
80
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
81
|
+
end
|
82
|
+
end
|
data/README.md
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
# Mi
|
2
2
|
|
3
|
-
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/mi.svg)](https://badge.fury.io/rb/mi)
|
4
|
+
[![Build Status](https://travis-ci.org/pocke/mi.svg?branch=master)](https://travis-ci.org/pocke/mi)
|
4
5
|
|
5
|
-
|
6
|
+
`mi` is a generator of migration file instead of `rails generate migration`.
|
7
|
+
|
8
|
+
- Simple Syntax
|
9
|
+
- Automatically generate class name.
|
6
10
|
|
7
11
|
## Installation
|
8
12
|
|
@@ -22,13 +26,57 @@ Or install it yourself as:
|
|
22
26
|
|
23
27
|
## Usage
|
24
28
|
|
25
|
-
|
29
|
+
### add_column
|
30
|
+
|
31
|
+
```sh
|
32
|
+
$ bin/rails g mi users +email:string
|
33
|
+
create db/migrate/20160429062420_add_email_to_users.rb
|
34
|
+
```
|
35
|
+
|
36
|
+
`db/migrate/20160429062420_add_email_to_users.rb`
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
class AddEmailToUsers < ActiveRecord::Migration
|
40
|
+
def change
|
41
|
+
add_column :users, :email, :string
|
42
|
+
end
|
43
|
+
end
|
44
|
+
```
|
26
45
|
|
27
|
-
|
46
|
+
### remove_column
|
28
47
|
|
29
|
-
|
48
|
+
```sh
|
49
|
+
$ bin/rails g mi users -email
|
50
|
+
create db/migrate/20160429124502_remove_email_to_users.rb
|
51
|
+
```
|
30
52
|
|
31
|
-
|
53
|
+
`db/migrate/20160429124502_remove_email_to_users.rb`
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
class RemoveEmailToUsers < ActiveRecord::Migration
|
57
|
+
def change
|
58
|
+
remove_column :users, :email
|
59
|
+
end
|
60
|
+
end
|
61
|
+
```
|
62
|
+
|
63
|
+
|
64
|
+
### change_column
|
65
|
+
|
66
|
+
```sh
|
67
|
+
$ bin/rails g mi users %email:string:{null:true}
|
68
|
+
create db/migrate/20160429124852_change_email_to_users.rb
|
69
|
+
```
|
70
|
+
|
71
|
+
`db/migrate/20160429124852_change_email_to_users.rb`
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
class ChangeEmailToUsers < ActiveRecord::Migration
|
75
|
+
def change
|
76
|
+
change_column :users, :email, :string, null: true
|
77
|
+
end
|
78
|
+
end
|
79
|
+
```
|
32
80
|
|
33
81
|
## Contributing
|
34
82
|
|
@@ -1,5 +1,8 @@
|
|
1
1
|
require 'rails'
|
2
|
-
require 'rails/generators
|
2
|
+
require 'rails/generators'
|
3
|
+
require 'active_record'
|
4
|
+
require 'strscan'
|
5
|
+
|
3
6
|
|
4
7
|
class MiGenerator < Rails::Generators::Base
|
5
8
|
include Rails::Generators::Migration
|
@@ -26,7 +29,7 @@ class MiGenerator < Rails::Generators::Base
|
|
26
29
|
|
27
30
|
def arg_groups
|
28
31
|
@arg_groups ||= (
|
29
|
-
args = @_initializer[0..1].flatten
|
32
|
+
args = @_initializer[0..1].flatten.reject{|x| x.start_with?('--')}
|
30
33
|
|
31
34
|
current = nil
|
32
35
|
res = args.group_by do |a|
|
@@ -45,7 +48,13 @@ class MiGenerator < Rails::Generators::Base
|
|
45
48
|
# TODO: parse options
|
46
49
|
# @param [String] col +COL_NAME:TYPE:{OPTIONS}
|
47
50
|
def parse_column(col)
|
48
|
-
|
51
|
+
sc = StringScanner.new(col)
|
52
|
+
name = sc.scan(/[^:]+/)
|
53
|
+
sc.scan(/:/)
|
54
|
+
type = sc.scan(/[^:]+/)
|
55
|
+
sc.scan(/:/)
|
56
|
+
options = sc.scan(/\{.+\}$/)
|
57
|
+
|
49
58
|
method = name[0]
|
50
59
|
name = name[1..-1]
|
51
60
|
{name: name, type: type, options: options, method: method}
|
@@ -54,8 +63,14 @@ class MiGenerator < Rails::Generators::Base
|
|
54
63
|
# @param [String] col +COL_NAME:TYPE:{OPTIONS}
|
55
64
|
def to_method(table, col)
|
56
65
|
info = parse_column(col)
|
57
|
-
res = "#{Methods[info[:method]]} :#{table}, :#{info[:name]}
|
58
|
-
|
66
|
+
res = "#{Methods[info[:method]]} :#{table}, :#{info[:name]}"
|
67
|
+
|
68
|
+
return res unless info[:type]
|
69
|
+
res << ", :#{info[:type]}"
|
70
|
+
|
71
|
+
return res unless info[:options]
|
72
|
+
res << ", #{info[:options][1..-2].gsub(':', ': ').gsub(',', ', ')}"
|
73
|
+
|
59
74
|
res
|
60
75
|
end
|
61
76
|
|
@@ -75,9 +90,14 @@ class MiGenerator < Rails::Generators::Base
|
|
75
90
|
|
76
91
|
def destination
|
77
92
|
table, columns = *arg_groups.first
|
93
|
+
c = {
|
94
|
+
'+' => 'to',
|
95
|
+
'-' => 'from',
|
96
|
+
'%' => 'of'
|
97
|
+
}[parse_column(columns.last)[:method]]
|
78
98
|
[
|
79
99
|
columns.map{|c| to_dest(c)}.inject{|sum, x| sum.concat(['and', x].flatten)},
|
80
|
-
|
100
|
+
c,
|
81
101
|
table.tableize,
|
82
102
|
].flatten.join('_')
|
83
103
|
end
|
data/lib/mi/version.rb
CHANGED
data/mi.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Masataka Kuwabara"]
|
10
10
|
spec.email = ["p.ck.t22@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{}
|
13
|
-
spec.description = %q{}
|
12
|
+
spec.summary = %q{Better `rails g migration`}
|
13
|
+
spec.description = %q{Mi is a generator of migration file instead of `rails generate migration`.}
|
14
14
|
spec.homepage = "https://github.com/pocke/mi"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
@@ -24,4 +24,13 @@ Gem::Specification.new do |spec|
|
|
24
24
|
|
25
25
|
spec.add_development_dependency "bundler", "~> 1.11"
|
26
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency 'rubocop', '~> 0.39.0'
|
28
|
+
|
29
|
+
# testing
|
30
|
+
spec.add_development_dependency "rspec", "~> 3.4.0"
|
31
|
+
spec.add_development_dependency 'guard', '~> 2.13.0'
|
32
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.6.5'
|
33
|
+
spec.add_development_dependency 'guard-bundler', '~> 2.1.0'
|
34
|
+
spec.add_development_dependency 'pry', '~> 0.10.3'
|
35
|
+
spec.add_development_dependency 'rspec-power_assert', '~> 0.3.0'
|
27
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masataka Kuwabara
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -66,7 +66,105 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '10.0'
|
69
|
-
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.39.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.39.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 3.4.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 3.4.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 2.13.0
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 2.13.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: guard-rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 4.6.5
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 4.6.5
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: guard-bundler
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 2.1.0
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 2.1.0
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: pry
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 0.10.3
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 0.10.3
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rspec-power_assert
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 0.3.0
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 0.3.0
|
167
|
+
description: Mi is a generator of migration file instead of `rails generate migration`.
|
70
168
|
email:
|
71
169
|
- p.ck.t22@gmail.com
|
72
170
|
executables: []
|
@@ -74,7 +172,11 @@ extensions: []
|
|
74
172
|
extra_rdoc_files: []
|
75
173
|
files:
|
76
174
|
- ".gitignore"
|
175
|
+
- ".rspec"
|
176
|
+
- ".rubocop.yml"
|
177
|
+
- ".travis.yml"
|
77
178
|
- Gemfile
|
179
|
+
- Guardfile
|
78
180
|
- LICENSE
|
79
181
|
- README.md
|
80
182
|
- Rakefile
|
@@ -108,5 +210,5 @@ rubyforge_project:
|
|
108
210
|
rubygems_version: 2.5.1
|
109
211
|
signing_key:
|
110
212
|
specification_version: 4
|
111
|
-
summary:
|
213
|
+
summary: Better `rails g migration`
|
112
214
|
test_files: []
|