umu 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: 776a0b0480f5df2a0f5095127e34ca0f0169c9a81ea22b6130e04790dc4eac6f
4
- data.tar.gz: 1ea8a941c281359c41ef34ceb04be4daeb40f125a906d4d65ba5232dcd33255a
3
+ metadata.gz: b732fe56cc1c56176ef9053e8a5dfb30b4f814b5626b789dd083bec905b46043
4
+ data.tar.gz: fe9a20417e6f41e321be0514d99b3d584de03d961cf277dcf1a4b95bb428d633
5
5
  SHA512:
6
- metadata.gz: f661264d1664608362cc0d0cb76f76e9b45a96402e080cdafd1594d148f3a904ac19fdb23038091abff8967447ffe1aa3299ae5a4bbb8856bb67cec83cbedffc
7
- data.tar.gz: 8dcbd4d54d81fc84637a086725d18e96887c9c8482fb48df9d9ccfc9435acab14cadc7643fa8ce5a251dfe773235ec24bf5586212e3a34d2d6a1f3728acb9505
6
+ metadata.gz: cefd9243e9c650c721e77476aeb6e68fa2ca4c2c76eea6612880b6cccede1e6d04ee8e5b03465a7270302773054b5b14b98655c878ad045742b5a10867fcd42a
7
+ data.tar.gz: de2eaa14281f6fc86dd38ba056eddbe34233ffa8ba0a120daee866f24cb78d8b18cb4d3fbb7444bff52b0d8eb2b8c2a3d46d84745402b181f4d98c6b14baf09d
data/.rubocop.yml CHANGED
@@ -1,13 +1,22 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 2.6
3
+ Exclude:
4
+ - 'Gemfile'
5
+ - 'Rakefile'
6
+ - 'umu.gemspec'
7
+ - 'bin/console'
8
+ - 'exe/umu'
9
+ - 'lib/umu/version.rb'
3
10
 
4
- Style/StringLiterals:
5
- Enabled: true
6
- EnforcedStyle: double_quotes
11
+ # Style/StringLiterals:
12
+ # Enabled: true
13
+ # EnforcedStyle: single_quotes
7
14
 
8
- Style/StringLiteralsInInterpolation:
9
- Enabled: true
10
- EnforcedStyle: double_quotes
15
+ # Style/StringLiteralsInInterpolation:
16
+ # Enabled: true
17
+ # EnforcedStyle: double_quotes
18
+ Style/FrozenStringLiteralComment:
19
+ Enabled: false
11
20
 
12
21
  Layout/LineLength:
13
22
  Max: 120
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## [Unreleased]
2
2
 
3
+ - Language setting
4
+
5
+ ## [0.1.4] - 2023-03-05
6
+
7
+ - fix some bug
8
+ - refactor
9
+ - fill spec
10
+ - modify some setting
11
+
3
12
  ## [0.1.3] - 2023-03-01
4
13
 
5
14
  - fix:folder name && some bug is RoR
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- umu (0.1.2)
4
+ umu (0.1.3)
5
5
  activesupport (>= 3.0.0)
6
6
 
7
7
  GEM
@@ -58,6 +58,7 @@ GEM
58
58
 
59
59
  PLATFORMS
60
60
  x86_64-darwin-19
61
+ x86_64-darwin-21
61
62
 
62
63
  DEPENDENCIES
63
64
  rake (~> 13.0)
data/README.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # Umu (prototype)
2
2
 
3
3
  Umu is a framework that supports you to make & run command in Ruby on Rails
4
+
5
+
6
+
7
+ https://user-images.githubusercontent.com/78460152/222332886-50337710-4fc8-4437-b82a-f1a64edd95f3.mov
8
+
9
+
4
10
  ## Installation
5
11
 
6
12
  Install the gem and add to the application's Gemfile by executing:
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Color module is a module for colorizing string.
3
4
  module Color
4
5
  COLORS = {
5
6
  black: 30,
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'color'
4
-
4
+ # Template module is a module for stringIO.
5
5
  module Template
6
6
  include Color
7
7
  def pointer(boolean)
@@ -13,11 +13,23 @@ module Template
13
13
  end
14
14
 
15
15
  def checker(boolean, str)
16
- boolean ? "(○) #{blue(str)}" : "( ) #{str}"
16
+ boolean ? "(○) #{syan(str)}" : "( ) #{str}"
17
17
  end
18
18
 
19
19
  def hover(boolen, str)
20
20
  boolen ? green(str) : str
21
21
  end
22
- module_function :pointer, :checker, :hover, :cover
22
+
23
+ def command(generator_name, target_name = '', sub_items = '', options = '')
24
+ target_name = " #{target_name}" unless target_name.empty?
25
+ sub_items = " #{sub_items}" unless sub_items.empty?
26
+ options = " #{options}" unless options.empty?
27
+ "rails generate #{generator_name}" + target_name + sub_items + options
28
+ end
29
+
30
+ def show_command(generator_name, target_name = '', sub_items = '', options = '')
31
+ puts green('>') + " #{command(generator_name, target_name, sub_items, options)}"
32
+ end
33
+
34
+ module_function :pointer, :checker, :hover, :cover, :show_command, :command
23
35
  end
@@ -4,6 +4,7 @@ require_relative 'validation'
4
4
  require_relative '../beautifica/beautifica'
5
5
 
6
6
  module Umu
7
+ # Inputter is a module for inputting.
7
8
  class Inputter
8
9
  extend Template
9
10
  def self.input(content, has_vaild = false, check_target = [])
@@ -4,6 +4,7 @@ require 'io/console'
4
4
  require_relative '../beautifica/beautifica'
5
5
 
6
6
  module Umu
7
+ # Selector is a module for selecting items.
7
8
  class Selector
8
9
  extend Template
9
10
  def self.radio(opts = [], content = '')
@@ -47,7 +48,6 @@ module Umu
47
48
  while (key = $stdin.getch) != "\C-c"
48
49
  if key == "\e"
49
50
  second_key = $stdin.getch
50
-
51
51
  if second_key == '['
52
52
  key = $stdin.getch
53
53
  case key
@@ -4,20 +4,21 @@ require_relative '../core/inputter'
4
4
  require_relative '../core/selector'
5
5
  require_relative '../beautifica/beautifica'
6
6
 
7
+ # ApplicationRecordMaker is a module for generating application_record.
7
8
  module ApplicationRecordMaker
8
9
  class << self
9
10
  include Template
10
11
  def generator
11
- puts '#=> rails generate application_record'
12
+ show_command('application_record')
12
13
  is_make_options = Umu::Selector.single_choice('オプションを追加しますか?')
13
14
  cover(1)
14
15
  options = ''
15
16
  options = Umu::Inputter.input('オプションを入力してください', true) if is_make_options
16
17
  cover(1) if is_make_options
17
- command = "rails generate application_record #{options}"
18
+ command = command('application_record', options)
18
19
  cover(1)
19
20
  puts command
20
- confirm_content = '上記コマンド実行しますか?'
21
+ confirm_content = '上記コマンドを実行しますか?'
21
22
  run_command = Umu::Selector.single_choice(confirm_content)
22
23
  cover(1)
23
24
  puts confirm_content + (run_command ? 'はい' : 'いいえ')
@@ -2,19 +2,21 @@ require_relative '../core/inputter'
2
2
  require_relative '../core/selector'
3
3
  require_relative '../beautifica/beautifica'
4
4
 
5
+ # BenchmarkMaker is a module for generating benchmark.
5
6
  module BenchmarkMaker
6
7
  class << self
7
8
  include Template
8
9
  def generator
9
- benchmark_name = Umu::Inputter.input('ベンチマーク名を入力してください (例:CreditCard)')
10
+ benchmark_name = Umu::Inputter.input('ベンチマーク名を入力してください (例:benchmark_name)')
10
11
  cover(1)
11
- puts "#=> rails generate benchmark #{benchmark_name}"
12
- confirm_content = '上記コマンド実行しますか?'
12
+ show_command('benchmark', benchmark_name)
13
+ confirm_content = '上記コマンドを実行しますか?'
13
14
  run_command = Umu::Selector.single_choice(confirm_content)
14
15
  cover(1)
16
+ command = command('benchmark', benchmark_name)
15
17
  puts confirm_content + (run_command ? 'はい' : 'いいえ')
16
18
  system(command) if run_command
17
19
  true
18
20
  end
19
21
  end
20
- end
22
+ end
@@ -4,13 +4,14 @@ require_relative '../core/inputter'
4
4
  require_relative '../core/selector'
5
5
  require_relative '../beautifica/beautifica'
6
6
 
7
+ # ChannelMaker is a module for generating channel.
7
8
  module ChannelMaker
8
9
  class << self
9
10
  include Template
10
11
  def generator
11
- channel_name = Umu::Inputter.input('チャネル名を入力してください (例:ChatChannel)')
12
+ channel_name = Umu::Inputter.input('チャネル名を入力してください (例:channel_name)')
12
13
  cover(1)
13
- puts "#=> rails generate channel #{channel_name}"
14
+ show_command('channel', channel_name)
14
15
  make_action = Umu::Selector.single_choice('アクションを追加しますか?')
15
16
  cover(1)
16
17
  actions = []
@@ -19,7 +20,7 @@ module ChannelMaker
19
20
  cover(1)
20
21
  actions << action_name
21
22
  cover(1)
22
- puts "#=> rails generate channel #{channel_name} #{actions.join(' ')}"
23
+ show_command('channel', channel_name, actions.join(' '))
23
24
  make_action = Umu::Selector.single_choice('追加続きますか?')
24
25
  cover(1)
25
26
  end
@@ -29,7 +30,7 @@ module ChannelMaker
29
30
  options = ''
30
31
  options = Umu::Inputter.input('オプションを入力してください', true) if is_make_options
31
32
  cover(1) if is_make_options
32
- command = "rails generate channel #{channel_name} " + actions.join(' ').to_s + " #{options}"
33
+ command = command('channel', channel_name, actions.join(' '), options)
33
34
  cover(1)
34
35
  puts command
35
36
  confirm_content = '上記コマンド実行しますか?'
@@ -4,6 +4,7 @@ require_relative '../core/inputter'
4
4
  require_relative '../core/selector'
5
5
  require_relative '../beautifica/beautifica'
6
6
 
7
+ # ControllerMaker is a module for generating controller.
7
8
  module ControllerMaker
8
9
  class << self
9
10
  include Template
@@ -20,14 +21,15 @@ module ControllerMaker
20
21
  controller_name = Umu::Inputter.input('コントローラー名を入力してください (複数)')
21
22
  cover(1)
22
23
  puts "#=> rails generate controller #{controller_name}"
24
+ show_command('controller', controller_name)
23
25
  make_actions = Umu::Selector.single_choice('アクション生成しますか?')
24
26
  cover(1)
25
27
  actions = []
26
28
  if make_actions
27
- actions = Umu::Selector.checkbox(ACTIONS, 'アクションを選択してください。')
29
+ actions = Umu::Selector.checkbox(ACTIONS, 'アクションを選択してください。<スペースキーで選択できます>')
28
30
  cover(1)
29
31
  cover(1)
30
- puts "#=> rails generate controller #{controller_name} #{actions.join(' ')}"
32
+ show_command('controller', controller_name, actions.join(' '))
31
33
  if actions.include?('other')
32
34
  make_action = true
33
35
  actions.delete('other')
@@ -35,7 +37,7 @@ module ControllerMaker
35
37
  original_action_name = Umu::Inputter.input('アクション名を入力してください', true, actions)
36
38
  actions << original_action_name
37
39
  cover(2)
38
- puts "#=> rails generate controller #{controller_name} #{actions.join(' ')}"
40
+ show_command('controller', controller_name, actions.join(' '))
39
41
  make_action = Umu::Selector.single_choice('作り続けますか?')
40
42
  cover(1)
41
43
  end
@@ -46,7 +48,7 @@ module ControllerMaker
46
48
  cover(1)
47
49
  options = Umu::Inputter.input('オプションを入力してください', true) if is_make_options
48
50
  cover(1) if is_make_options
49
- command = "rails generate controller #{controller_name} #{actions.join(' ')} #{options}"
51
+ command = command('controller', controller_name, actions.join(' '), options)
50
52
  cover(1)
51
53
  puts command
52
54
  confirm_content = '上記コマンド実行しますか?'
@@ -4,19 +4,20 @@ require_relative '../core/inputter'
4
4
  require_relative '../core/selector'
5
5
  require_relative '../beautifica/beautifica'
6
6
 
7
+ # HelperMaker is a module for generating helper.
7
8
  module HelperMaker
8
9
  class << self
9
10
  include Template
10
11
  def generator
11
- helper_name = Umu::Inputter.input('ヘルパー名を入力してください (例:CreditCard)')
12
+ helper_name = Umu::Inputter.input('ヘルパー名を入力してください (例:helper_name)')
12
13
  cover(1)
13
- puts "#=> rails generate helper #{helper_name}"
14
+ show_command('helper', helper_name)
14
15
  is_make_options = Umu::Selector.single_choice('オプションを追加しますか?')
15
16
  cover(1)
16
17
  options = ''
17
18
  options = Umu::Inputter.input('オプションを入力してください', true) if is_make_options
18
19
  cover(1) if is_make_options
19
- command = "rails generate helper #{helper_name} #{options}"
20
+ command = command('helper', helper_name, options)
20
21
  cover(1)
21
22
  puts command
22
23
  confirm_content = '上記コマンド実行しますか?'
@@ -4,19 +4,20 @@ require_relative '../core/inputter'
4
4
  require_relative '../core/selector'
5
5
  require_relative '../beautifica/beautifica'
6
6
 
7
+ # JobMaker is a module for generating job.
7
8
  module JobMaker
8
9
  class << self
9
10
  include Template
10
11
  def generator
11
- job_name = Umu::Inputter.input('ジョブ名を入力してください (例:CreditCard)')
12
+ job_name = Umu::Inputter.input('ジョブ名を入力してください (例:job_name)')
12
13
  cover(1)
13
- puts "#=> rails generate job #{job_name}"
14
+ show_command('job', job_name)
14
15
  is_make_options = Umu::Selector.single_choice('オプションを追加しますか?')
15
16
  cover(1)
16
17
  options = ''
17
18
  options = Umu::Inputter.input('オプションを入力してください', true) if is_make_options
18
19
  cover(1) if is_make_options
19
- command = "rails generate job #{job_name} #{options}"
20
+ command = command('job', job_name, options)
20
21
  cover(1)
21
22
  puts command
22
23
  confirm_content = '上記コマンド実行しますか?'
@@ -4,19 +4,20 @@ require_relative '../core/inputter'
4
4
  require_relative '../core/selector'
5
5
  require_relative '../beautifica/beautifica'
6
6
 
7
+ # MailboxMaker is a module for generating mailbox.
7
8
  module MailboxMaker
8
9
  class << self
9
10
  include Template
10
11
  def generator
11
- mailbox_name = Umu::Inputter.input('メールボックス名を入力してください (例:CreditCard)')
12
+ mailbox_name = Umu::Inputter.input('メールボックス名を入力してください (例:mailbox_name)')
12
13
  cover(1)
13
- puts "#=> rails generate mailbox #{mailbox_name}"
14
+ show_command('mailbox', mailbox_name)
14
15
  is_make_options = Umu::Selector.single_choice('オプションを追加しますか?')
15
16
  cover(1)
16
17
  options = ''
17
18
  options = Umu::Inputter.input('オプションを入力してください', true) if is_make_options
18
19
  cover(1) if is_make_options
19
- command = "rails generate mailbox #{mailbox_name} #{options}"
20
+ command = command('mailbox', mailbox_name, options)
20
21
  cover(1)
21
22
  puts command
22
23
  confirm_content = '上記コマンド実行しますか?'
@@ -27,4 +28,4 @@ module MailboxMaker
27
28
  true
28
29
  end
29
30
  end
30
- end
31
+ end
@@ -4,13 +4,14 @@ require_relative '../core/inputter'
4
4
  require_relative '../core/selector'
5
5
  require_relative '../beautifica/beautifica'
6
6
 
7
+ # MailerMaker is a module for generating mailer.
7
8
  module MailerMaker
8
9
  class << self
9
10
  include Template
10
11
  def generator
11
- mailer_name = Umu::Inputter.input('メーラー名を入力してください (例:CreditCard)')
12
+ mailer_name = Umu::Inputter.input('メーラー名を入力してください (例:mailer_name)')
12
13
  cover(1)
13
- puts "#=> rails generate mailer #{mailer_name}"
14
+ show_command('mailer', mailer_name)
14
15
  make_action = Umu::Selector.single_choice('アクションを追加しますか?')
15
16
  cover(1)
16
17
  actions = []
@@ -19,7 +20,7 @@ module MailerMaker
19
20
  cover(1)
20
21
  actions << action_name
21
22
  cover(1)
22
- puts "#=> rails generate channel #{mailer_name} #{actions.join(' ')}"
23
+ show_command('mailer', mailer_name, actions.join(' '))
23
24
  make_action = Umu::Selector.single_choice('追加続きますか?')
24
25
  cover(1)
25
26
  end
@@ -28,7 +29,7 @@ module MailerMaker
28
29
  options = ''
29
30
  options = Umu::Inputter.input('オプションを入力してください', true) if is_make_options
30
31
  cover(1) if is_make_options
31
- command = "rails generate mailer #{mailer_name}" + " #{actions.join(' ')}" + " #{options}"
32
+ command = command('mailer', mailer_name, actions.join(' '), options)
32
33
  cover(1)
33
34
  puts command
34
35
  confirm_content = '上記コマンド実行しますか?'
@@ -4,6 +4,7 @@ require_relative '../core/inputter'
4
4
  require_relative '../core/selector'
5
5
  require_relative '../beautifica/beautifica'
6
6
 
7
+ # MigrationMaker is a module for generating migration.
7
8
  module MigrationMaker
8
9
  class << self
9
10
  include Template
@@ -24,25 +25,24 @@ module MigrationMaker
24
25
  def generator
25
26
  migration_name = Umu::Inputter.input('マイグレーション名を入力してください(例: AddNameToUsers・Users)')
26
27
  cover(1)
27
- puts "#=> rails generate migration #{migration_name}"
28
+ show_command('migration', migration_name)
28
29
  is_make_column = Umu::Selector.single_choice('カラム生成しますか?')
29
30
  cover(1)
30
31
  columns = []
31
32
  while is_make_column
32
33
  columns << make_column
33
- puts "#=> rails generate migration #{migration_name} #{columns.join(' ')}"
34
+ show_command('migration', migration_name, columns.join(' '))
34
35
  is_make_column = Umu::Selector.single_choice('作り続けますか?')
35
36
  cover(1)
36
37
  end
37
- puts "rails generate migration #{migration_name} " + columns.join(' ')
38
+ show_command('migration', migration_name, columns.join(' '))
38
39
  cover(1)
39
40
  is_make_options = Umu::Selector.single_choice('オプションを追加しますか?')
40
41
  cover(1)
41
42
  options = ''
42
43
  options = Umu::Inputter.input('オプションを入力してください', true) if is_make_options
43
44
  cover(1) if is_make_options
44
-
45
- command = "rails generate migration #{migration_name} " + columns.join(' ') + " #{options}"
45
+ command = command('migration', migration_name, columns.join(' '), options)
46
46
  cover(1)
47
47
  puts command
48
48
  confirm_content = '上記コマンド実行しますか?'
@@ -4,6 +4,7 @@ require_relative '../core/inputter'
4
4
  require_relative '../core/selector'
5
5
  require_relative '../beautifica/beautifica'
6
6
 
7
+ # ModelMaker is a module for generating model.
7
8
  module ModelMaker
8
9
  class << self
9
10
  include Template
@@ -24,18 +25,18 @@ module ModelMaker
24
25
  def generator
25
26
  model_name = Umu::Inputter.input('モデル名を入力してください (単数)')
26
27
  cover(1)
27
- puts "#=> rails generate model #{model_name}"
28
+ show_command('model', model_name)
28
29
  is_make_column = Umu::Selector.single_choice('カラム生成しますか?')
29
30
  cover(1)
30
31
  columns = []
31
32
  while is_make_column
32
- columns << make_colum
33
- puts "#=> rails generate model #{model_name} #{columns.join(' ')}"
33
+ columns << make_column
34
+ show_command('model', model_name, columns.join(' '))
34
35
  is_make_column = Umu::Selector.single_choice('作り続けますか?')
35
36
  cover(1)
36
37
  end
37
38
 
38
- puts "#=> rails generate model #{model_name} " + columns.join(' ')
39
+ show_command('model', model_name, columns.join(' '))
39
40
  cover(1)
40
41
  is_make_options = Umu::Selector.single_choice('オプションを追加しますか?')
41
42
  cover(1)
@@ -43,7 +44,7 @@ module ModelMaker
43
44
  options = Umu::Inputter.input('オプションを入力してください', true) if is_make_options
44
45
  cover(1) if is_make_options
45
46
 
46
- command = "rails generate model #{model_name} #{columns.join(' ')} #{options}"
47
+ command = command('model', model_name, columns.join(' '), options)
47
48
  cover(1)
48
49
  puts command
49
50
  confirm_content = '上記コマンド実行しますか?'
@@ -54,7 +55,7 @@ module ModelMaker
54
55
  true
55
56
  end
56
57
 
57
- def make_colum
58
+ def make_column
58
59
  colum_name = Umu::Inputter.input('カラム名を入力してください')
59
60
  cover(1)
60
61
  type = Umu::Selector.radio(COLUMN_TYPE, 'タイプを選んでください')
@@ -1,8 +1,8 @@
1
-
2
1
  require_relative '../core/inputter'
3
2
  require_relative '../core/selector'
4
3
  require_relative '../beautifica/beautifica'
5
4
 
5
+ # ResourceMaker is a module for generating resource.
6
6
  module ResourceMaker
7
7
  class << self
8
8
  include Template
@@ -23,17 +23,17 @@ module ResourceMaker
23
23
  def generator
24
24
  resource_name = Umu::Inputter.input('リソース名を入力してください (単数)')
25
25
  cover(1)
26
- puts "#=> rails generate resource #{resource_name}"
26
+ show_command('resource', resource_name)
27
27
  is_make_column = Umu::Selector.single_choice('カラム生成しますか?')
28
28
  cover(1)
29
29
  columns = []
30
30
  while is_make_column
31
31
  columns << make_colum
32
- puts "#=> rails generate resource #{resource_name} #{columns.join(' ')}"
32
+ show_command('resource', resource_name, columns.join(' '))
33
33
  is_make_column = Umu::Selector.single_choice('作り続けますか?')
34
34
  cover(1)
35
35
  end
36
- puts "#=> rails generate resource #{resource_name} " + columns.join(' ')
36
+ show_command('resource', resource_name, columns.join(' '))
37
37
  cover(1)
38
38
 
39
39
  is_make_options = Umu::Selector.single_choice('オプションを追加しますか?')
@@ -41,8 +41,7 @@ module ResourceMaker
41
41
  options = ''
42
42
  options = Umu::Inputter.input('オプションを入力してください', true) if is_make_options
43
43
  cover(1) if is_make_options
44
-
45
- command = "rails generate resource #{resource_name} " + "#{columns.join(' ')}" + " #{options}"
44
+ command = command('resource', resource_name, columns.join(' '), options)
46
45
  cover(1)
47
46
  puts command
48
47
  confirm_content = '上記コマンド実行しますか?'
@@ -61,4 +60,4 @@ module ResourceMaker
61
60
  "#{colum_name}:#{type}"
62
61
  end
63
62
  end
64
- end
63
+ end
@@ -4,13 +4,14 @@ require_relative '../core/inputter'
4
4
  require_relative '../core/selector'
5
5
  require_relative '../beautifica/beautifica'
6
6
 
7
+ # TaskMaker is a module for generating task.
7
8
  module TaskMaker
8
9
  class << self
9
10
  include Template
10
11
  def generator
11
- task_name = Umu::Inputter.input('タスク名を入力してください (例:CreditCard)')
12
+ task_name = Umu::Inputter.input('タスク名を入力してください (例:task_name)')
12
13
  cover(1)
13
- puts "#=> rails generate task #{task_name}"
14
+ show_command('task', task_name)
14
15
  make_action = Umu::Selector.single_choice('アクションを追加しますか?')
15
16
  cover(1)
16
17
  actions = []
@@ -19,7 +20,7 @@ module TaskMaker
19
20
  cover(1)
20
21
  actions << action_name
21
22
  cover(1)
22
- puts "#=> rails generate channel #{task_name} #{actions.join(' ')}"
23
+ show_command('task', task_name, actions.join(' '))
23
24
  make_action = Umu::Selector.single_choice('追加続きますか?')
24
25
  cover(1)
25
26
  end
@@ -29,7 +30,7 @@ module TaskMaker
29
30
  options = ''
30
31
  options = Umu::Inputter.input('オプションを入力してください', true) if is_make_options
31
32
  cover(1) if is_make_options
32
- command = "rails generate task #{task_name}" + " #{actions.join(' ')}" + " #{options}"
33
+ command = command('task', task_name, actions.join(' '), options)
33
34
  cover(1)
34
35
  puts command
35
36
  confirm_content = '上記コマンド実行しますか?'
@@ -14,53 +14,29 @@ require_relative 'generators/benchmark_maker'
14
14
  require_relative 'generators/resource_maker'
15
15
 
16
16
  module Umu
17
+ ##
18
+ # Umu is a tool for automatically generating Rails code.
17
19
  module Generators
18
- def self.model
19
- ModelMaker.generator
20
- end
21
-
22
- def self.controller
23
- ControllerMaker.generator
24
- end
25
-
26
- def self.migration
27
- MigrationMaker.generator
28
- end
29
-
30
- def self.application_record
31
- ApplicationRecordMaker.generator
32
- end
33
-
34
- def self.helper
35
- HelperMaker.generator
36
- end
37
-
38
- def self.channel
39
- ChannelMaker.generator
40
- end
41
-
42
- def self.job
43
- JobMaker.generator
44
- end
45
-
46
- def self.task
47
- TaskMaker.generator
48
- end
49
-
50
- def self.mailer
51
- MailerMaker.generator
52
- end
53
-
54
- def self.mailbox
55
- MailboxMaker.generator
56
- end
57
-
58
- def self.benchmark
59
- BenchmarkMaker.generator
60
- end
61
-
62
- def self.resource
63
- ResourceMaker.generator
20
+ GENERATORS = {
21
+ model: ModelMaker,
22
+ controller: ControllerMaker,
23
+ migration: MigrationMaker,
24
+ application_record: ApplicationRecordMaker,
25
+ helper: HelperMaker,
26
+ channel: ChannelMaker,
27
+ job: JobMaker,
28
+ task: TaskMaker,
29
+ mailer: MailerMaker,
30
+ mailbox: MailboxMaker,
31
+ benchmark: BenchmarkMaker,
32
+ resource: ResourceMaker
33
+ }.freeze
34
+
35
+ def self.run(target)
36
+ generator = GENERATORS[target.to_sym].generator
37
+ raise "Invalid target #{target}" unless generator
38
+
39
+ generator
64
40
  end
65
41
  end
66
42
  end
data/lib/umu/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Umu
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
data/lib/umu.rb CHANGED
@@ -4,18 +4,21 @@ require_relative 'umu/core/selector'
4
4
  require_relative 'umu/core/inputter'
5
5
  require_relative 'umu/generators'
6
6
  require_relative 'umu/beautifica/beautifica'
7
- require_relative "umu/version"
7
+ require_relative 'umu/version'
8
8
 
9
+ ##
10
+ # UmuはRailsのコードを自動生成するためのツールです。
9
11
  module Umu
10
12
  class Error < StandardError; end
11
13
  include Umu::Generators
12
14
  extend Color
13
15
  def self.generator
14
- items = %w[model controller migration application_record helper channel job task mailer mailbox benchmark resource].freeze
15
- content = "#{green('?')} 何生成しますか?"
16
+ items = %w[model controller migration application_record helper channel job task mailer mailbox benchmark
17
+ resource].freeze
18
+ content = "#{green('?')} 何を生成しますか?"
16
19
  target = Umu::Selector.radio(items, content)
17
20
  puts "\e[2A"
18
21
  puts "#{content} #{green(target)}"
19
- Umu::Generators.send(target)
22
+ Umu::Generators.run(target)
20
23
  end
21
24
  end
data/umu.gemspec CHANGED
@@ -5,12 +5,12 @@ require_relative "lib/umu/version"
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "umu"
7
7
  spec.version = Umu::VERSION
8
- spec.authors = ["196"]
8
+ spec.authors = ["Kuan-Hung Chen"]
9
9
  spec.email = ["kankou.chin@gmail.com"]
10
10
 
11
11
  spec.summary = "A framework for make Ruby on Rails's command."
12
12
  spec.description = <<-DESCRIPTION
13
- Umu is a framework that supports your to make command in Ruby on Rails.
13
+ Umu is a framework that supports you to make command in Ruby on Rails.
14
14
  DESCRIPTION
15
15
  spec.homepage = "https://github.com/chen-196-hub/umu"
16
16
  spec.license = "MIT"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: umu
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
- - '196'
8
- autorequire:
7
+ - Kuan-Hung Chen
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-01 00:00:00.000000000 Z
11
+ date: 2023-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -24,7 +24,7 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.0.0
27
- description: " Umu is a framework that supports your to make command in Ruby on
27
+ description: " Umu is a framework that supports you to make command in Ruby on
28
28
  Rails.\n"
29
29
  email:
30
30
  - kankou.chin@gmail.com
@@ -73,7 +73,7 @@ metadata:
73
73
  homepage_uri: https://github.com/chen-196-hub/umu
74
74
  source_code_uri: https://github.com/chen-196-hub/umu
75
75
  changelog_uri: https://github.com/chen-196-hub/umu/blob/master/CHANGELOG.md
76
- post_install_message:
76
+ post_install_message:
77
77
  rdoc_options: []
78
78
  require_paths:
79
79
  - lib
@@ -88,8 +88,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  requirements: []
91
- rubygems_version: 3.3.10
92
- signing_key:
91
+ rubygems_version: 3.4.6
92
+ signing_key:
93
93
  specification_version: 4
94
94
  summary: A framework for make Ruby on Rails's command.
95
95
  test_files: []