umu 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fc358244dbed887c19a5a954cb6314ced6739ff50980fe4dd4added11ec66dbc
4
+ data.tar.gz: '05578e56b5300f6f8dc9ea06a7166719aef822b52c8a14b22ba79b5024b1b974'
5
+ SHA512:
6
+ metadata.gz: e7697a2cebe7c2430af6ce4c62cc7fce3c3637aa526054f4bc5c3a9e67a449e450ba4d4388f0c14a38bc11b1877201c03e39d762ea05ffc358f6cbdf5ae1e422
7
+ data.tar.gz: 0fb048792fc8165ed839baae4fef64eb9fa131352d26c2a474ab6c8ca29c3cf623baa9753d6692ce55d033b4b64367661a7a1968c074cde4026f8c35f03a0b14
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-02-28
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at kankou.chin@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in umu.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,57 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ umu (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ diff-lcs (1.5.0)
11
+ json (2.6.3)
12
+ parallel (1.22.1)
13
+ parser (3.2.1.0)
14
+ ast (~> 2.4.1)
15
+ rainbow (3.1.1)
16
+ rake (13.0.6)
17
+ regexp_parser (2.7.0)
18
+ rexml (3.2.5)
19
+ rspec (3.12.0)
20
+ rspec-core (~> 3.12.0)
21
+ rspec-expectations (~> 3.12.0)
22
+ rspec-mocks (~> 3.12.0)
23
+ rspec-core (3.12.1)
24
+ rspec-support (~> 3.12.0)
25
+ rspec-expectations (3.12.2)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.12.0)
28
+ rspec-mocks (3.12.3)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.12.0)
31
+ rspec-support (3.12.0)
32
+ rubocop (1.46.0)
33
+ json (~> 2.3)
34
+ parallel (~> 1.10)
35
+ parser (>= 3.2.0.0)
36
+ rainbow (>= 2.2.2, < 4.0)
37
+ regexp_parser (>= 1.8, < 3.0)
38
+ rexml (>= 3.2.5, < 4.0)
39
+ rubocop-ast (>= 1.26.0, < 2.0)
40
+ ruby-progressbar (~> 1.7)
41
+ unicode-display_width (>= 2.4.0, < 3.0)
42
+ rubocop-ast (1.26.0)
43
+ parser (>= 3.2.1.0)
44
+ ruby-progressbar (1.11.0)
45
+ unicode-display_width (2.4.2)
46
+
47
+ PLATFORMS
48
+ x86_64-darwin-19
49
+
50
+ DEPENDENCIES
51
+ rake (~> 13.0)
52
+ rspec (~> 3.0)
53
+ rubocop (~> 1.21)
54
+ umu!
55
+
56
+ BUNDLED WITH
57
+ 2.3.18
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 196
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # Umu
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.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Install the gem and add to the application's Gemfile by executing:
10
+
11
+ $ bundle add umu
12
+
13
+ If bundler is not being used to manage dependencies, install the gem by executing:
14
+
15
+ $ gem install umu
16
+
17
+ ## Usage
18
+
19
+ TODO: Write usage instructions here
20
+
21
+ ## Development
22
+
23
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
24
+
25
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
26
+
27
+ ## Contributing
28
+
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).
30
+
31
+ ## License
32
+
33
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
34
+
35
+ ## Code of Conduct
36
+
37
+ Everyone interacting in the Umu project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/umu/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Color
4
+ COLORS = {
5
+ black: 30,
6
+ red: 31,
7
+ green: 32,
8
+ yellow: 33,
9
+ blue: 34,
10
+ magenta: 35,
11
+ syan: 36,
12
+ white: 37
13
+ }.freeze
14
+ COLORS.map do |k, v|
15
+ define_method(k) do |str|
16
+ "\e[#{v}m#{str}\e[0m"
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'color'
4
+
5
+ module Template
6
+ include Color
7
+ def pointer(boolean)
8
+ boolean ? ' > ' : ' '
9
+ end
10
+
11
+ def cover(num)
12
+ puts "\e[#{num}A\e[0J\e[1A"
13
+ end
14
+
15
+ def checker(boolean, str)
16
+ boolean ? "(○) #{blue(str)}" : "( ) #{str}"
17
+ end
18
+
19
+ def hover(boolen, str)
20
+ boolen ? green(str) : str
21
+ end
22
+ module_function :pointer, :checker, :hover, :cover
23
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'assets/color'
4
+ require_relative 'assets/template'
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'validation'
4
+ require_relative '../beautifica/beautifica'
5
+
6
+ module Umu
7
+ class Inputter
8
+ extend Template
9
+ def self.input(content, has_vaild = false, check_target = [])
10
+ puts content.to_s
11
+ input_val = gets
12
+ is_empty = input_val.chomp == ''
13
+ while is_empty
14
+ cover(2)
15
+ puts "\e[1A"
16
+ puts "#{content} #{red('必須項目です')}"
17
+ input_val = gets
18
+ is_empty = input_val.chomp == ''
19
+ end
20
+
21
+ if has_vaild
22
+ is_overlap = Umu::Validation.check_overlap(check_target, input_val.chomp)
23
+ while is_overlap
24
+ cover(2)
25
+ puts "\e[1A"
26
+ puts "#{content} #{red("#{input_val.chomp}は重複です")}"
27
+ input_val = gets
28
+
29
+ is_empty = input_val.chomp == ''
30
+ while is_empty
31
+ cover(2)
32
+ puts "\e[1A"
33
+ puts "#{content} #{red('必須項目です')}"
34
+ input_val = gets
35
+ is_empty = input_val.chomp == ''
36
+ end
37
+
38
+ is_overlap = Umu::Validation.check_overlap(check_target, input_val.chomp)
39
+ end
40
+ end
41
+ puts "\e[2A"
42
+ input_val.chomp
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,122 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'io/console'
4
+ require_relative '../beautifica/beautifica'
5
+
6
+ module Umu
7
+ class Selector
8
+ extend Template
9
+ def self.radio(opts = [], content = '')
10
+ puts content
11
+ options = opts.map(&:to_s)
12
+
13
+ options.each_with_index do |x, idx|
14
+ print pointer(idx.zero?)
15
+ puts hover(idx.zero?, x)
16
+ end
17
+ radio_interactive_menu(options)
18
+ end
19
+
20
+ def self.single_choice(content = '')
21
+ choice = radio(%w[Yes No], content)
22
+ case choice
23
+ when 'Yes'
24
+ true
25
+ when 'No'
26
+ false
27
+ else
28
+ false
29
+ end
30
+ end
31
+
32
+ def self.checkbox(opts = [], content = '')
33
+ puts content
34
+ options = opts.map(&:to_s)
35
+
36
+ options.each_with_index do |x, idx|
37
+ print pointer(idx.zero?)
38
+ puts "( ) #{x}"
39
+ end
40
+
41
+ checkbox_interactive_menu(options)
42
+ end
43
+
44
+ class << self
45
+ def radio_interactive_menu(options)
46
+ index = 0
47
+ while (key = $stdin.getch) != "\C-c"
48
+ if key == "\e"
49
+ second_key = $stdin.getch
50
+
51
+ if second_key == '['
52
+ key = $stdin.getch
53
+ case key
54
+ when 'A', 'D'
55
+ index -= 1 if index != 0
56
+ when 'B', 'C'
57
+ index += 1 if index < (options.size - 1)
58
+ else
59
+ "esc: [#{key}"
60
+ end
61
+ puts "\e[#{options.size + 1}A"
62
+ options.each_with_index do |x, idx|
63
+ print pointer(idx == index)
64
+ puts hover(idx == index, x)
65
+ end
66
+ else
67
+ key = "esc: #{second_key}"
68
+ end
69
+ end
70
+ next unless key == "\r"
71
+
72
+ cover(options.size)
73
+ return options[index]
74
+ end
75
+ end
76
+
77
+ def checkbox_interactive_menu(options)
78
+ return [] if options.empty?
79
+
80
+ index = 0
81
+ ary = []
82
+ while (key = $stdin.getch) != "\C-c"
83
+ if key == "\e"
84
+ second_key = $stdin.getch
85
+
86
+ if second_key == '['
87
+ key = $stdin.getch
88
+ case key
89
+ when 'A', 'D'
90
+ index -= 1 if index != 0
91
+ when 'B', 'C'
92
+ index += 1 if index < (options.size - 1)
93
+ else
94
+ "esc: [#{key}"
95
+ end
96
+ puts "\e[#{options.size + 1}A"
97
+ options.each_with_index do |x, idx|
98
+ print pointer(idx == index)
99
+ puts checker(ary.include?(idx), x)
100
+ end
101
+ else
102
+ key = "esc: #{second_key}"
103
+ end
104
+ end
105
+ if key == ' '
106
+ ary.include?(index) ? ary.delete(index) : (ary << index)
107
+ puts "\e[#{options.size + 1}A"
108
+ options.each_with_index do |x, idx|
109
+ print pointer(idx == index)
110
+ puts checker(ary.include?(idx), x)
111
+ end
112
+ end
113
+ next unless key == "\r"
114
+
115
+ check_items = ary.sort.map { |x| options[x] }
116
+ cover(options.size)
117
+ return check_items
118
+ end
119
+ end
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Umu
4
+ class Validation
5
+ # 重複チェック
6
+ def self.check_overlap(check_target = [], items = '')
7
+ check_target.include?(items)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../core/inputter'
4
+ require_relative '../core/selector'
5
+ require_relative '../beautifica/beautifica'
6
+
7
+ module ApplicationRecord
8
+ class << self
9
+ include Template
10
+ def generator
11
+ puts '#=> rails generate application_record'
12
+ is_make_options = Umu::Selector.single_choice('オプションを追加しますか?')
13
+ cover(1)
14
+ options = ''
15
+ options = Umu::Inputter.input('オプションを入力してください', true) if is_make_options
16
+ cover(1) if is_make_options
17
+ command = "rails generate application_record #{options}"
18
+ cover(1)
19
+ puts command
20
+ confirm_content = '上記コマンド実行しますか?'
21
+ run_command = Umu::Selector.single_choice(confirm_content)
22
+ cover(1)
23
+ puts confirm_content + (run_command ? 'はい' : 'いいえ')
24
+ system(command) if run_command
25
+ true
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,20 @@
1
+ require_relative '../core/inputter'
2
+ require_relative '../core/selector'
3
+ require_relative '../beautifica/beautifica'
4
+
5
+ module Benchmark
6
+ class << self
7
+ include Template
8
+ def generator
9
+ benchmark_name = Umu::Inputter.input('ベンチマーク名を入力してください (例:CreditCard)')
10
+ cover(1)
11
+ puts "#=> rails generate benchmark #{benchmark_name}"
12
+ confirm_content = '上記コマンド実行しますか?'
13
+ run_command = Umu::Selector.single_choice(confirm_content)
14
+ cover(1)
15
+ puts confirm_content + (run_command ? 'はい' : 'いいえ')
16
+ system(command) if run_command
17
+ true
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../core/inputter'
4
+ require_relative '../core/selector'
5
+ require_relative '../beautifica/beautifica'
6
+
7
+ module Channel
8
+ class << self
9
+ include Template
10
+ def generator
11
+ channel_name = Umu::Inputter.input('チャネル名を入力してください (例:ChatChannel)')
12
+ cover(1)
13
+ puts "#=> rails generate channel #{channel_name}"
14
+ make_action = Umu::Selector.single_choice('アクションを追加しますか?')
15
+ cover(1)
16
+ actions = []
17
+ while make_action
18
+ action_name = Umu::Inputter.input('アクション名を入力してください (例:subscribed)')
19
+ cover(1)
20
+ actions << action_name
21
+ cover(1)
22
+ puts "#=> rails generate channel #{channel_name} #{actions.join(' ')}"
23
+ make_action = Umu::Selector.single_choice('追加続きますか?')
24
+ cover(1)
25
+ end
26
+
27
+ is_make_options = Umu::Selector.single_choice('オプションを追加しますか?')
28
+ cover(1)
29
+ options = ''
30
+ options = Umu::Inputter.input('オプションを入力してください', true) if is_make_options
31
+ cover(1) if is_make_options
32
+ command = "rails generate channel #{channel_name} " + actions.join(' ').to_s + " #{options}"
33
+ cover(1)
34
+ puts command
35
+ confirm_content = '上記コマンド実行しますか?'
36
+ run_command = Umu::Selector.single_choice(confirm_content)
37
+ cover(1)
38
+ puts confirm_content + (run_command ? 'はい' : 'いいえ')
39
+ system(command) if run_command
40
+ true
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../core/inputter'
4
+ require_relative '../core/selector'
5
+ require_relative '../beautifica/beautifica'
6
+
7
+ module Controller
8
+ class << self
9
+ include Template
10
+ ACTIONS = %w[
11
+ index
12
+ show
13
+ edit
14
+ create
15
+ update
16
+ destroy
17
+ other
18
+ ].freeze
19
+ def generator
20
+ controller_name = Umu::Inputter.input('コントローラー名を入力してください (複数)')
21
+ cover(1)
22
+ puts "#=> rails generate controller #{controller_name}"
23
+ make_actions = Umu::Selector.single_choice('アクション生成しますか?')
24
+ cover(1)
25
+ actions = []
26
+ if make_actions
27
+ actions = Umu::Selector.checkbox(ACTIONS, 'アクションを選択してください。')
28
+ cover(1)
29
+ cover(1)
30
+ puts "#=> rails generate controller #{controller_name} #{actions.join(' ')}"
31
+ if actions.include?('other')
32
+ make_action = true
33
+ actions.delete('other')
34
+ while make_action
35
+ original_action_name = Umu::Inputter.input('アクション名を入力してください', true, actions)
36
+ actions << original_action_name
37
+ cover(2)
38
+ puts "#=> rails generate controller #{controller_name} #{actions.join(' ')}"
39
+ make_action = Umu::Selector.single_choice('作り続けますか?')
40
+ cover(1)
41
+ end
42
+ end
43
+ end
44
+ is_make_options = Umu::Selector.single_choice('オプションを追加しますか?')
45
+ options = ''
46
+ cover(1)
47
+ options = Umu::Inputter.input('オプションを入力してください', true) if is_make_options
48
+ cover(1) if is_make_options
49
+ command = "rails generate controller #{controller_name} #{actions.join(' ')} #{options}"
50
+ cover(1)
51
+ puts command
52
+ confirm_content = '上記コマンド実行しますか?'
53
+ run_command = Umu::Selector.single_choice(confirm_content)
54
+ cover(1)
55
+ puts confirm_content + (run_command ? 'はい' : 'いいえ')
56
+ system(command) if run_command
57
+ true
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../core/inputter'
4
+ require_relative '../core/selector'
5
+ require_relative '../beautifica/beautifica'
6
+
7
+ module Helper
8
+ class << self
9
+ include Template
10
+ def generator
11
+ helper_name = Umu::Inputter.input('ヘルパー名を入力してください (例:CreditCard)')
12
+ cover(1)
13
+ puts "#=> rails generate helper #{helper_name}"
14
+ is_make_options = Umu::Selector.single_choice('オプションを追加しますか?')
15
+ cover(1)
16
+ options = ''
17
+ options = Umu::Inputter.input('オプションを入力してください', true) if is_make_options
18
+ cover(1) if is_make_options
19
+ command = "rails generate helper #{helper_name} #{options}"
20
+ cover(1)
21
+ puts command
22
+ confirm_content = '上記コマンド実行しますか?'
23
+ run_command = Umu::Selector.single_choice(confirm_content)
24
+ cover(1)
25
+ puts confirm_content + (run_command ? 'はい' : 'いいえ')
26
+ system(command) if run_command
27
+ true
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../core/inputter'
4
+ require_relative '../core/selector'
5
+ require_relative '../beautifica/beautifica'
6
+
7
+ module Job
8
+ class << self
9
+ include Template
10
+ def generator
11
+ job_name = Umu::Inputter.input('ジョブ名を入力してください (例:CreditCard)')
12
+ cover(1)
13
+ puts "#=> rails generate job #{job_name}"
14
+ is_make_options = Umu::Selector.single_choice('オプションを追加しますか?')
15
+ cover(1)
16
+ options = ''
17
+ options = Umu::Inputter.input('オプションを入力してください', true) if is_make_options
18
+ cover(1) if is_make_options
19
+ command = "rails generate job #{job_name} #{options}"
20
+ cover(1)
21
+ puts command
22
+ confirm_content = '上記コマンド実行しますか?'
23
+ run_command = Umu::Selector.single_choice(confirm_content)
24
+ cover(1)
25
+ puts confirm_content + (run_command ? 'はい' : 'いいえ')
26
+ system(command) if run_command
27
+ true
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../core/inputter'
4
+ require_relative '../core/selector'
5
+ require_relative '../beautifica/beautifica'
6
+
7
+ module Mailbox
8
+ class << self
9
+ include Template
10
+ def generator
11
+ mailbox_name = Umu::Inputter.input('メールボックス名を入力してください (例:CreditCard)')
12
+ cover(1)
13
+ puts "#=> rails generate mailbox #{mailbox_name}"
14
+ is_make_options = Umu::Selector.single_choice('オプションを追加しますか?')
15
+ cover(1)
16
+ options = ''
17
+ options = Umu::Inputter.input('オプションを入力してください', true) if is_make_options
18
+ cover(1) if is_make_options
19
+ command = "rails generate mailbox #{mailbox_name} #{options}"
20
+ cover(1)
21
+ puts command
22
+ confirm_content = '上記コマンド実行しますか?'
23
+ run_command = Umu::Selector.single_choice(confirm_content)
24
+ cover(1)
25
+ puts confirm_content + (run_command ? 'はい' : 'いいえ')
26
+ system(command) if run_command
27
+ true
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../core/inputter'
4
+ require_relative '../core/selector'
5
+ require_relative '../beautifica/beautifica'
6
+
7
+ module Mailer
8
+ class << self
9
+ include Template
10
+ def generator
11
+ mailer_name = Umu::Inputter.input('メーラー名を入力してください (例:CreditCard)')
12
+ cover(1)
13
+ puts "#=> rails generate mailer #{mailer_name}"
14
+ make_action = Umu::Selector.single_choice('アクションを追加しますか?')
15
+ cover(1)
16
+ actions = []
17
+ while make_action
18
+ action_name = Umu::Inputter.input('アクション名を入力してください (例:subscribed)')
19
+ cover(1)
20
+ actions << action_name
21
+ cover(1)
22
+ puts "#=> rails generate channel #{mailer_name} #{actions.join(' ')}"
23
+ make_action = Umu::Selector.single_choice('追加続きますか?')
24
+ cover(1)
25
+ end
26
+ is_make_options = Umu::Selector.single_choice('オプションを追加しますか?')
27
+ cover(1)
28
+ options = ''
29
+ options = Umu::Inputter.input('オプションを入力してください', true) if is_make_options
30
+ cover(1) if is_make_options
31
+ command = "rails generate mailer #{mailer_name}" + " #{actions.join(' ')}" + " #{options}"
32
+ cover(1)
33
+ puts command
34
+ confirm_content = '上記コマンド実行しますか?'
35
+ run_command = Umu::Selector.single_choice(confirm_content)
36
+ cover(1)
37
+ puts confirm_content + (run_command ? 'はい' : 'いいえ')
38
+ system(command) if run_command
39
+ true
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../core/inputter'
4
+ require_relative '../core/selector'
5
+ require_relative '../beautifica/beautifica'
6
+
7
+ module Migration
8
+ class << self
9
+ include Template
10
+ COLUMN_TYPE = %w[
11
+ string
12
+ text
13
+ integer
14
+ float
15
+ decimal
16
+ datetime
17
+ timestamp
18
+ time
19
+ date
20
+ binary
21
+ boolean
22
+ primary_key
23
+ ].freeze
24
+ def generator
25
+ migration_name = Umu::Inputter.input('マイグレーション名を入力してください(例: AddNameToUsers・Users)')
26
+ cover(1)
27
+ puts "#=> rails generate migration #{migration_name}"
28
+ is_make_column = Umu::Selector.single_choice('カラム生成しますか?')
29
+ cover(1)
30
+ columns = []
31
+ while is_make_column
32
+ columns << make_column
33
+ puts "#=> rails generate migration #{migration_name} #{columns.join(' ')}"
34
+ is_make_column = Umu::Selector.single_choice('作り続けますか?')
35
+ cover(1)
36
+ end
37
+ puts "rails generate migration #{migration_name} " + columns.join(' ')
38
+ cover(1)
39
+ is_make_options = Umu::Selector.single_choice('オプションを追加しますか?')
40
+ cover(1)
41
+ options = ''
42
+ options = Umu::Inputter.input('オプションを入力してください', true) if is_make_options
43
+ cover(1) if is_make_options
44
+
45
+ command = "rails generate migration #{migration_name} " + columns.join(' ') + " #{options}"
46
+ cover(1)
47
+ puts command
48
+ confirm_content = '上記コマンド実行しますか?'
49
+ run_command = Umu::Selector.single_choice(confirm_content)
50
+ cover(1)
51
+ puts confirm_content + (run_command ? 'はい' : 'いいえ')
52
+ system(command) if run_command
53
+ true
54
+ end
55
+
56
+ def make_column
57
+ column_name = Umu::Inputter.input('カラム名を入力してください')
58
+ cover(1)
59
+ type = Umu::Selector.radio(COLUMN_TYPE, 'タイプを選んでください')
60
+ cover(2)
61
+ "#{column_name}:#{type}"
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../core/inputter'
4
+ require_relative '../core/selector'
5
+ require_relative '../beautifica/beautifica'
6
+
7
+ module Model
8
+ class << self
9
+ include Template
10
+ COLUMN_TYPE = %w[
11
+ string
12
+ text
13
+ integer
14
+ float
15
+ decimal
16
+ datetime
17
+ timestamp
18
+ time
19
+ date
20
+ binary
21
+ boolean
22
+ primary_key
23
+ ].freeze
24
+ def generator
25
+ model_name = Umu::Inputter.input('モデル名を入力してください (単数)')
26
+ cover(1)
27
+ puts "#=> rails generate model #{model_name}"
28
+ is_make_column = Umu::Selector.single_choice('カラム生成しますか?')
29
+ cover(1)
30
+ columns = []
31
+ while is_make_column
32
+ columns << make_colum
33
+ puts "#=> rails generate model #{model_name} #{columns.join(' ')}"
34
+ is_make_column = Umu::Selector.single_choice('作り続けますか?')
35
+ cover(1)
36
+ end
37
+
38
+ puts "#=> rails generate model #{model_name} " + columns.join(' ')
39
+ cover(1)
40
+ is_make_options = Umu::Selector.single_choice('オプションを追加しますか?')
41
+ cover(1)
42
+ options = ''
43
+ options = Umu::Inputter.input('オプションを入力してください', true) if is_make_options
44
+ cover(1) if is_make_options
45
+
46
+ command = "rails generate model #{model_name} #{columns.join(' ')} #{options}"
47
+ cover(1)
48
+ puts command
49
+ confirm_content = '上記コマンド実行しますか?'
50
+ run_command = Umu::Selector.single_choice(confirm_content)
51
+ cover(1)
52
+ puts confirm_content + (run_command ? 'はい' : 'いいえ')
53
+ system(command) if run_command
54
+ true
55
+ end
56
+
57
+ def make_colum
58
+ colum_name = Umu::Inputter.input('カラム名を入力してください')
59
+ cover(1)
60
+ type = Umu::Selector.radio(COLUMN_TYPE, 'タイプを選んでください')
61
+ cover(2)
62
+ "#{colum_name}:#{type}"
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,64 @@
1
+
2
+ require_relative '../core/inputter'
3
+ require_relative '../core/selector'
4
+ require_relative '../beautifica/beautifica'
5
+
6
+ module Resource
7
+ class << self
8
+ include Template
9
+ COLUMN_TYPE = %w[
10
+ string
11
+ text
12
+ integer
13
+ float
14
+ decimal
15
+ datetime
16
+ timestamp
17
+ time
18
+ date
19
+ binary
20
+ boolean
21
+ primary_key
22
+ ].freeze
23
+ def generator
24
+ resource_name = Umu::Inputter.input('リソース名を入力してください (単数)')
25
+ cover(1)
26
+ puts "#=> rails generate resource #{resource_name}"
27
+ is_make_column = Umu::Selector.single_choice('カラム生成しますか?')
28
+ cover(1)
29
+ columns = []
30
+ while is_make_column
31
+ columns << make_colum
32
+ puts "#=> rails generate resource #{resource_name} #{columns.join(' ')}"
33
+ is_make_column = Umu::Selector.single_choice('作り続けますか?')
34
+ cover(1)
35
+ end
36
+ puts "#=> rails generate resource #{resource_name} " + columns.join(' ')
37
+ cover(1)
38
+
39
+ is_make_options = Umu::Selector.single_choice('オプションを追加しますか?')
40
+ cover(1)
41
+ options = ''
42
+ options = Umu::Inputter.input('オプションを入力してください', true) if is_make_options
43
+ cover(1) if is_make_options
44
+
45
+ command = "rails generate resource #{resource_name} " + "#{columns.join(' ')}" + " #{options}"
46
+ cover(1)
47
+ puts command
48
+ confirm_content = '上記コマンド実行しますか?'
49
+ run_command = Umu::Selector.single_choice(confirm_content)
50
+ cover(1)
51
+ puts confirm_content + (run_command ? 'はい' : 'いいえ')
52
+ system(command) if run_command
53
+ true
54
+ end
55
+
56
+ def make_colum
57
+ colum_name = Umu::Inputter.input('カラム名を入力してください')
58
+ cover(1)
59
+ type = Umu::Selector.radio(COLUMN_TYPE, 'タイプを選んでください')
60
+ cover(2)
61
+ "#{colum_name}:#{type}"
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../core/inputter'
4
+ require_relative '../core/selector'
5
+ require_relative '../beautifica/beautifica'
6
+
7
+ module Task
8
+ class << self
9
+ include Template
10
+ def generator
11
+ task_name = Umu::Inputter.input('タスク名を入力してください (例:CreditCard)')
12
+ cover(1)
13
+ puts "#=> rails generate task #{task_name}"
14
+ make_action = Umu::Selector.single_choice('アクションを追加しますか?')
15
+ cover(1)
16
+ actions = []
17
+ while make_action
18
+ action_name = Umu::Inputter.input('アクション名を入力してください (例:action_name)', true, actions)
19
+ cover(1)
20
+ actions << action_name
21
+ cover(1)
22
+ puts "#=> rails generate channel #{task_name} #{actions.join(' ')}"
23
+ make_action = Umu::Selector.single_choice('追加続きますか?')
24
+ cover(1)
25
+ end
26
+
27
+ is_make_options = Umu::Selector.single_choice('オプションを追加しますか?')
28
+ cover(1)
29
+ options = ''
30
+ options = Umu::Inputter.input('オプションを入力してください', true) if is_make_options
31
+ cover(1) if is_make_options
32
+ command = "rails generate task #{task_name}" + " #{actions.join(' ')}" + " #{options}"
33
+ cover(1)
34
+ puts command
35
+ confirm_content = '上記コマンド実行しますか?'
36
+ run_command = Umu::Selector.single_choice(confirm_content)
37
+ cover(1)
38
+ puts confirm_content + (run_command ? 'はい' : 'いいえ')
39
+ system(command) if run_command
40
+ true
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
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'
15
+
16
+ module Umu
17
+ 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
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Umu
4
+ VERSION = "0.1.0"
5
+ end
data/lib/umu.rb ADDED
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'umu/core/selector'
4
+ require_relative 'umu/core/inputter'
5
+ require_relative 'umu/generators'
6
+ require_relative 'umu/beautifica/beautifica'
7
+ require_relative "umu/version"
8
+
9
+ module Umu
10
+ class Error < StandardError; end
11
+ include Umu::Generators
12
+ extend Color
13
+ def self.generator
14
+ items = %w[model controller migration application_record helper channel job task mailer mailbox benchmark resource].freeze
15
+ content = "#{green('?')} 何生成しますか?"
16
+ target = Umu::Selector.radio(items, content)
17
+ puts "\e[2A"
18
+ puts "#{content} #{green(target)}"
19
+ Umu::Generators.send(target)
20
+ end
21
+ end
data/sig/umu.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Umu
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
data/umu.gemspec ADDED
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/umu/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "umu"
7
+ spec.version = Umu::VERSION
8
+ spec.authors = ["196"]
9
+ spec.email = ["kankou.chin@gmail.com"]
10
+
11
+ spec.summary = "A framework for make Ruby on Rails's command."
12
+ spec.description = <<-DESCRIPTION
13
+ Umu is a framework that supports your to make command in Ruby on Rails.
14
+ DESCRIPTION
15
+ spec.homepage = "https://github.com/chen-196-hub/umu"
16
+ spec.license = "MIT"
17
+ spec.required_ruby_version = ">= 2.6.0"
18
+
19
+ # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
20
+
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ spec.metadata["source_code_uri"] = "https://github.com/chen-196-hub/umu"
23
+ spec.metadata["changelog_uri"] = "https://github.com/chen-196-hub/umu/blob/master/CHANGELOG.md"
24
+
25
+ # Specify which files should be added to the gem when it is released.
26
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
+ spec.files = Dir.chdir(__dir__) do
28
+ `git ls-files -z`.split("\x0").reject do |f|
29
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
30
+ end
31
+ end
32
+ spec.bindir = "exe"
33
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
34
+ spec.require_paths = ["lib"]
35
+
36
+ # Uncomment to register a new dependency of your gem
37
+ # spec.add_dependency "example-gem", "~> 1.0"
38
+
39
+ # For more information and examples about making a new gem, check out our
40
+ # guide at: https://bundler.io/guides/creating_gem.html
41
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: umu
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - '196'
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-02-28 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: " Umu is a framework that supports your to make command in Ruby on
14
+ Rails.\n"
15
+ email:
16
+ - kankou.chin@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".rspec"
22
+ - ".rubocop.yml"
23
+ - CHANGELOG.md
24
+ - CODE_OF_CONDUCT.md
25
+ - Gemfile
26
+ - Gemfile.lock
27
+ - LICENSE.txt
28
+ - README.md
29
+ - Rakefile
30
+ - lib/umu.rb
31
+ - lib/umu/beautifica/assets/color.rb
32
+ - lib/umu/beautifica/assets/template.rb
33
+ - lib/umu/beautifica/beautifica.rb
34
+ - lib/umu/core/inputter.rb
35
+ - lib/umu/core/selector.rb
36
+ - lib/umu/core/validation.rb
37
+ - lib/umu/generators.rb
38
+ - lib/umu/generators/application_record.rb
39
+ - lib/umu/generators/benchmark.rb
40
+ - lib/umu/generators/channel.rb
41
+ - lib/umu/generators/controller.rb
42
+ - lib/umu/generators/helper.rb
43
+ - lib/umu/generators/job.rb
44
+ - lib/umu/generators/mailbox.rb
45
+ - lib/umu/generators/mailer.rb
46
+ - lib/umu/generators/migration.rb
47
+ - lib/umu/generators/model.rb
48
+ - lib/umu/generators/resource.rb
49
+ - lib/umu/generators/task.rb
50
+ - lib/umu/version.rb
51
+ - sig/umu.rbs
52
+ - umu.gemspec
53
+ homepage: https://github.com/chen-196-hub/umu
54
+ licenses:
55
+ - MIT
56
+ metadata:
57
+ homepage_uri: https://github.com/chen-196-hub/umu
58
+ source_code_uri: https://github.com/chen-196-hub/umu
59
+ changelog_uri: https://github.com/chen-196-hub/umu/blob/master/CHANGELOG.md
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 2.6.0
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubygems_version: 3.3.10
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: A framework for make Ruby on Rails's command.
79
+ test_files: []