umu 0.1.2 → 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: 2b6bd15f7fd4e437693df71d46c9dd068bd0224edca8394b53c65df9e8a81cc7
4
- data.tar.gz: 99713ddf9f6ff60f39caf6e345d4aafb81c21e20fd363dd8ee9f4f66397c41fb
3
+ metadata.gz: b732fe56cc1c56176ef9053e8a5dfb30b4f814b5626b789dd083bec905b46043
4
+ data.tar.gz: fe9a20417e6f41e321be0514d99b3d584de03d961cf277dcf1a4b95bb428d633
5
5
  SHA512:
6
- metadata.gz: 71dc03a548d5d8fea197a7bf32bbfdc9289b1b4ce0fa27bb163912efca488e5dbb75e42ad96227dc16e21ba9bffd274209328535f58e343c2e4251cbe3016c6e
7
- data.tar.gz: 620dd1f677efb19bed094ff68f54a8a8440862228aadf4a648f505ba2d46054ab3b59b17d36b05793b64145ee7be099b384a8178f4b48ef09a9f876c19e9636a
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,26 @@
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
+
12
+ ## [0.1.3] - 2023-03-01
13
+
14
+ - fix:folder name && some bug is RoR
15
+
16
+ ## [0.1.2] - 2023-02-28
17
+
18
+ - add activesupport in to .gemspec
19
+
20
+ ## [0.1.1] - 2023-02-28
21
+
22
+ - add run command
23
+
3
24
  ## [0.1.0] - 2023-02-28
4
25
 
5
- - Initial release
26
+ - Initial release
data/Gemfile.lock CHANGED
@@ -1,14 +1,24 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- umu (0.1.0)
4
+ umu (0.1.3)
5
+ activesupport (>= 3.0.0)
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
10
+ activesupport (7.0.4.2)
11
+ concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ i18n (>= 1.6, < 2)
13
+ minitest (>= 5.1)
14
+ tzinfo (~> 2.0)
9
15
  ast (2.4.2)
16
+ concurrent-ruby (1.2.2)
10
17
  diff-lcs (1.5.0)
18
+ i18n (1.12.0)
19
+ concurrent-ruby (~> 1.0)
11
20
  json (2.6.3)
21
+ minitest (5.17.0)
12
22
  parallel (1.22.1)
13
23
  parser (3.2.1.0)
14
24
  ast (~> 2.4.1)
@@ -42,10 +52,13 @@ GEM
42
52
  rubocop-ast (1.26.0)
43
53
  parser (>= 3.2.1.0)
44
54
  ruby-progressbar (1.11.0)
55
+ tzinfo (2.0.6)
56
+ concurrent-ruby (~> 1.0)
45
57
  unicode-display_width (2.4.2)
46
58
 
47
59
  PLATFORMS
48
60
  x86_64-darwin-19
61
+ x86_64-darwin-21
49
62
 
50
63
  DEPENDENCIES
51
64
  rake (~> 13.0)
data/README.md CHANGED
@@ -1,8 +1,11 @@
1
- # Umu
1
+ # Umu (prototype)
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/umu`. To experiment with that code, run `bin/console` for an interactive prompt.
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
4
8
 
5
- TODO: Delete this and the text above, and describe your gem
6
9
 
7
10
  ## Installation
8
11
 
@@ -10,13 +13,14 @@ Install the gem and add to the application's Gemfile by executing:
10
13
 
11
14
  $ bundle add umu
12
15
 
13
- If bundler is not being used to manage dependencies, install the gem by executing:
14
-
15
- $ gem install umu
16
-
16
+ or
17
+ ```ruby
18
+ group :development, :test do
19
+ gem 'umu'
20
+ end
21
+ ```
17
22
  ## Usage
18
-
19
- TODO: Write usage instructions here
23
+ bundle exec umu
20
24
 
21
25
  ## Development
22
26
 
@@ -26,7 +30,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
26
30
 
27
31
  ## Contributing
28
32
 
29
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/umu. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/umu/blob/main/CODE_OF_CONDUCT.md).
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/chen-196-hub/umu. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/chen-196-hub/umu/blob/main/CODE_OF_CONDUCT.md).
30
34
 
31
35
  ## License
32
36
 
@@ -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
- module ApplicationRecord
7
+ # ApplicationRecordMaker is a module for generating application_record.
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
- module Benchmark
5
+ # BenchmarkMaker is a module for generating benchmark.
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
- module Channel
7
+ # ChannelMaker is a module for generating channel.
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 Channel
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 Channel
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,7 +4,8 @@ require_relative '../core/inputter'
4
4
  require_relative '../core/selector'
5
5
  require_relative '../beautifica/beautifica'
6
6
 
7
- module Controller
7
+ # ControllerMaker is a module for generating controller.
8
+ module ControllerMaker
8
9
  class << self
9
10
  include Template
10
11
  ACTIONS = %w[
@@ -20,14 +21,15 @@ module Controller
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 Controller
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 Controller
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
- module Helper
7
+ # HelperMaker is a module for generating helper.
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
- module Job
7
+ # JobMaker is a module for generating job.
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
- module Mailbox
7
+ # MailboxMaker is a module for generating mailbox.
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 Mailbox
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
- module Mailer
7
+ # MailerMaker is a module for generating mailer.
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 Mailer
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 Mailer
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,7 +4,8 @@ require_relative '../core/inputter'
4
4
  require_relative '../core/selector'
5
5
  require_relative '../beautifica/beautifica'
6
6
 
7
- module Migration
7
+ # MigrationMaker is a module for generating migration.
8
+ module MigrationMaker
8
9
  class << self
9
10
  include Template
10
11
  COLUMN_TYPE = %w[
@@ -24,25 +25,24 @@ module Migration
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,7 +4,8 @@ require_relative '../core/inputter'
4
4
  require_relative '../core/selector'
5
5
  require_relative '../beautifica/beautifica'
6
6
 
7
- module Model
7
+ # ModelMaker is a module for generating model.
8
+ module ModelMaker
8
9
  class << self
9
10
  include Template
10
11
  COLUMN_TYPE = %w[
@@ -24,18 +25,18 @@ module Model
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 Model
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 Model
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,9 +1,9 @@
1
-
2
1
  require_relative '../core/inputter'
3
2
  require_relative '../core/selector'
4
3
  require_relative '../beautifica/beautifica'
5
4
 
6
- module Resource
5
+ # ResourceMaker is a module for generating resource.
6
+ module ResourceMaker
7
7
  class << self
8
8
  include Template
9
9
  COLUMN_TYPE = %w[
@@ -23,17 +23,17 @@ module Resource
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 Resource
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 Resource
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
- module Task
7
+ # TaskMaker is a module for generating task.
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 Task
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 Task
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 = '上記コマンド実行しますか?'
@@ -1,66 +1,42 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'generators/model'
4
- require_relative 'generators/controller'
5
- require_relative 'generators/migration'
6
- require_relative 'generators/application_record'
7
- require_relative 'generators/helper'
8
- require_relative 'generators/channel'
9
- require_relative 'generators/job'
10
- require_relative 'generators/task'
11
- require_relative 'generators/mailer'
12
- require_relative 'generators/mailbox'
13
- require_relative 'generators/benchmark'
14
- require_relative 'generators/resource'
3
+ require_relative 'generators/model_maker'
4
+ require_relative 'generators/controller_maker'
5
+ require_relative 'generators/migration_maker'
6
+ require_relative 'generators/application_record_maker'
7
+ require_relative 'generators/helper_maker'
8
+ require_relative 'generators/channel_maker'
9
+ require_relative 'generators/job_maker'
10
+ require_relative 'generators/task_maker'
11
+ require_relative 'generators/mailer_maker'
12
+ require_relative 'generators/mailbox_maker'
13
+ require_relative 'generators/benchmark_maker'
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
- Model.generator
20
- end
21
-
22
- def self.controller
23
- Controller.generator
24
- end
25
-
26
- def self.migration
27
- Migration.generator
28
- end
29
-
30
- def self.application_record
31
- ApplicationRecord.generator
32
- end
33
-
34
- def self.helper
35
- Helper.generator
36
- end
37
-
38
- def self.channel
39
- Channel.generator
40
- end
41
-
42
- def self.job
43
- Job.generator
44
- end
45
-
46
- def self.task
47
- Task.generator
48
- end
49
-
50
- def self.mailer
51
- Mailer.generator
52
- end
53
-
54
- def self.mailbox
55
- Mailbox.generator
56
- end
57
-
58
- def self.benchmark
59
- Benchmark.generator
60
- end
61
-
62
- def self.resource
63
- Resource.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.2"
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.2
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-02-28 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
@@ -51,18 +51,18 @@ files:
51
51
  - lib/umu/core/selector.rb
52
52
  - lib/umu/core/validation.rb
53
53
  - lib/umu/generators.rb
54
- - lib/umu/generators/application_record.rb
55
- - lib/umu/generators/benchmark.rb
56
- - lib/umu/generators/channel.rb
57
- - lib/umu/generators/controller.rb
58
- - lib/umu/generators/helper.rb
59
- - lib/umu/generators/job.rb
60
- - lib/umu/generators/mailbox.rb
61
- - lib/umu/generators/mailer.rb
62
- - lib/umu/generators/migration.rb
63
- - lib/umu/generators/model.rb
64
- - lib/umu/generators/resource.rb
65
- - lib/umu/generators/task.rb
54
+ - lib/umu/generators/application_record_maker.rb
55
+ - lib/umu/generators/benchmark_maker.rb
56
+ - lib/umu/generators/channel_maker.rb
57
+ - lib/umu/generators/controller_maker.rb
58
+ - lib/umu/generators/helper_maker.rb
59
+ - lib/umu/generators/job_maker.rb
60
+ - lib/umu/generators/mailbox_maker.rb
61
+ - lib/umu/generators/mailer_maker.rb
62
+ - lib/umu/generators/migration_maker.rb
63
+ - lib/umu/generators/model_maker.rb
64
+ - lib/umu/generators/resource_maker.rb
65
+ - lib/umu/generators/task_maker.rb
66
66
  - lib/umu/version.rb
67
67
  - sig/umu.rbs
68
68
  - umu.gemspec
@@ -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: []