rails-interactive 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/cli/{categories.rb → category.rb} +1 -1
- data/lib/cli/{commands.rb → command.rb} +8 -1
- data/lib/cli/command_handler.rb +32 -0
- data/lib/cli/utils.rb +0 -10
- data/lib/cli/version.rb +1 -1
- data/lib/rails_interactive.rb +10 -6
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 482ad6f26a28d35ab5a4d58ea8f0f56bfe977bd1096bfc25a26bed05cf318b1f
|
4
|
+
data.tar.gz: fad72c7fec9fe01a3e28ba23e370f1c200155ad2207dc32e8c57b969c0b4e882
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a91c4823bd9b5322c5e72b3fb402edba3d8d90f951aeb5c9b4e7762ea14a50bb91669995b2171a6a478d70b2e4234f5b55870d7c3eaa1ef159535cdd08c3a3f
|
7
|
+
data.tar.gz: 17c8c28bfa9286d09bb0e72a56372f40438a68ff594836fbca9e1146a7709f443ae37ccfeddce8e4cd842ac83025018b1171f98a8a6799b4d5918aed384bc2b1
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
](https://asciinema.org/a/mFutWNTzym5aZPqK7AgBSMjLE)
|
2
2
|
|
3
3
|
# Rails::Interactive
|
4
4
|
[](https://badge.fury.io/rb/rails-interactive)
|
@@ -5,7 +5,7 @@ require "yaml"
|
|
5
5
|
module RailsInteractive
|
6
6
|
class CLI
|
7
7
|
# Commands class for the interactive CLI module
|
8
|
-
class
|
8
|
+
class Command
|
9
9
|
def initialize
|
10
10
|
@commands = YAML.load_file("#{__dir__}/config/commands.yml").uniq
|
11
11
|
end
|
@@ -17,6 +17,13 @@ module RailsInteractive
|
|
17
17
|
def find_by_identifier(identifier)
|
18
18
|
@commands.find { |command| command["identifier"] == identifier }
|
19
19
|
end
|
20
|
+
|
21
|
+
def dependencies(identifier)
|
22
|
+
identifier = identifier.is_a?(Array) ? identifier.join("") : identifier
|
23
|
+
command ||= find_by_identifier(identifier)
|
24
|
+
|
25
|
+
command["dependencies"]
|
26
|
+
end
|
20
27
|
end
|
21
28
|
end
|
22
29
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "cli/command"
|
4
|
+
require "yaml"
|
5
|
+
|
6
|
+
module RailsInteractive
|
7
|
+
class CLI
|
8
|
+
# Commands class for the interactive CLI module
|
9
|
+
class CommandHandler
|
10
|
+
def initialize
|
11
|
+
@commands = Command.new.all
|
12
|
+
end
|
13
|
+
|
14
|
+
def handle_multi_options(options, dependencies = nil)
|
15
|
+
handle_dependencies(dependencies)
|
16
|
+
options.each { |option| system("bin/rails app:template LOCATION=templates/setup_#{option}.rb") }
|
17
|
+
end
|
18
|
+
|
19
|
+
def handle_option(option, dependencies = nil)
|
20
|
+
handle_dependencies(dependencies)
|
21
|
+
system("bin/rails app:template LOCATION=templates/setup_#{option}.rb")
|
22
|
+
end
|
23
|
+
|
24
|
+
def handle_dependencies(dependencies)
|
25
|
+
dependencies&.each do |dependency|
|
26
|
+
puts ">> Dependency Detected: #{dependency} "
|
27
|
+
system("bin/rails app:template LOCATION=templates/setup_#{dependency}.rb")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/cli/utils.rb
CHANGED
@@ -28,16 +28,6 @@ module RailsInteractive
|
|
28
28
|
go_to_project_directory(project_name)
|
29
29
|
end
|
30
30
|
|
31
|
-
def self.handle_multi_options(multi_options)
|
32
|
-
multi_options.each do |value|
|
33
|
-
system("bin/rails app:template LOCATION=templates/setup_#{value}.rb")
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.handle_option(option)
|
38
|
-
system("bin/rails app:template LOCATION=templates/setup_#{option}.rb")
|
39
|
-
end
|
40
|
-
|
41
31
|
def self.sign_project
|
42
32
|
file = "README.md"
|
43
33
|
msg = "\n> This project was generated by [Rails Interactive CLI](https://github.com/oguzsh/rails-interactive)"
|
data/lib/cli/version.rb
CHANGED
data/lib/rails_interactive.rb
CHANGED
@@ -2,17 +2,19 @@
|
|
2
2
|
|
3
3
|
require "cli/prompt"
|
4
4
|
require "cli/message"
|
5
|
-
require "cli/
|
6
|
-
require "cli/
|
5
|
+
require "cli/command"
|
6
|
+
require "cli/category"
|
7
7
|
require "cli/utils"
|
8
|
+
require "cli/command_handler"
|
8
9
|
|
9
10
|
module RailsInteractive
|
10
11
|
# CLI class for the interactive CLI module
|
11
12
|
class CLI
|
12
13
|
def initialize
|
13
14
|
@inputs = {}
|
14
|
-
@commands =
|
15
|
-
@categories =
|
15
|
+
@commands = Command.new
|
16
|
+
@categories = Category.new
|
17
|
+
@handler = CommandHandler.new
|
16
18
|
end
|
17
19
|
|
18
20
|
def perform(key)
|
@@ -100,8 +102,10 @@ module RailsInteractive
|
|
100
102
|
@inputs.each do |key, value|
|
101
103
|
next if %i[name type database].include?(key) || value.is_a?(Array) && value.empty? || value.nil?
|
102
104
|
|
103
|
-
|
104
|
-
|
105
|
+
dependencies = @commands.dependencies(value)
|
106
|
+
|
107
|
+
@handler.handle_multi_options(value, dependencies) if value.is_a?(Array)
|
108
|
+
@handler.handle_option(value, dependencies) if value.is_a?(String)
|
105
109
|
end
|
106
110
|
|
107
111
|
# Remove templates folder from project folder
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-interactive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oguzhan Ince
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -163,8 +163,9 @@ files:
|
|
163
163
|
- bin/console
|
164
164
|
- bin/rails-interactive
|
165
165
|
- bin/setup
|
166
|
-
- lib/cli/
|
167
|
-
- lib/cli/
|
166
|
+
- lib/cli/category.rb
|
167
|
+
- lib/cli/command.rb
|
168
|
+
- lib/cli/command_handler.rb
|
168
169
|
- lib/cli/config/categories.yml
|
169
170
|
- lib/cli/config/commands.yml
|
170
171
|
- lib/cli/message.rb
|