Module: ResourceMaker
- Extended by:
- Template
- Defined in:
- lib/umu/generators/resource_maker.rb
Constant Summary
collapse
- COLUMN_TYPE =
%w[
string
text
integer
float
decimal
datetime
timestamp
time
date
binary
boolean
primary_key
].freeze
Constants included
from Color
Color::COLORS
Class Method Summary
collapse
Methods included from Template
checker, cover, hover, pointer
Class Method Details
.generator ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/umu/generators/resource_maker.rb', line 23
def generator
resource_name = Umu::Inputter.input('リソース名を入力してください (単数)')
cover(1)
puts "#=> rails generate resource #{resource_name}"
is_make_column = Umu::Selector.single_choice('カラム生成しますか?')
cover(1)
columns = []
while is_make_column
columns << make_colum
puts "#=> rails generate resource #{resource_name} #{columns.join(' ')}"
is_make_column = Umu::Selector.single_choice('作り続けますか?')
cover(1)
end
puts "#=> rails generate resource #{resource_name} " + columns.join(' ')
cover(1)
is_make_options = Umu::Selector.single_choice('オプションを追加しますか?')
cover(1)
options = ''
options = Umu::Inputter.input('オプションを入力してください', true) if is_make_options
cover(1) if is_make_options
command = "rails generate resource #{resource_name} " + "#{columns.join(' ')}" + " #{options}"
cover(1)
puts command
confirm_content = '上記コマンド実行しますか?'
run_command = Umu::Selector.single_choice(confirm_content)
cover(1)
puts confirm_content + (run_command ? 'はい' : 'いいえ')
system(command) if run_command
true
end
|
.make_colum ⇒ Object
56
57
58
59
60
61
62
|
# File 'lib/umu/generators/resource_maker.rb', line 56
def make_colum
colum_name = Umu::Inputter.input('カラム名を入力してください')
cover(1)
type = Umu::Selector.radio(COLUMN_TYPE, 'タイプを選んでください')
cover(2)
"#{colum_name}:#{type}"
end
|