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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7bbe64281e0e3224cf7ca9a041eb42c42c7e69028406b7e10d3e60a9efbae743
4
- data.tar.gz: b69196bc79adb05559963c6f1cfee8fc2dda46fe795bf4c5449c35673080fa19
3
+ metadata.gz: 482ad6f26a28d35ab5a4d58ea8f0f56bfe977bd1096bfc25a26bed05cf318b1f
4
+ data.tar.gz: fad72c7fec9fe01a3e28ba23e370f1c200155ad2207dc32e8c57b969c0b4e882
5
5
  SHA512:
6
- metadata.gz: f72def1e7699e42baa285164308ef728d5c118bf7611972441242486c442d154d3ee00a8c3cf05a29c3eeb6aa453bb61a05f60c406880aa4942c8c64858593d5
7
- data.tar.gz: d53e7c764ca1ecbee3378a4304070ced64c18825b7f2ef7b53700612c442fced35128b05f8c4be6cbe12090a08784a5d9b747a0f0be4cf83f29412b30b604b8e
6
+ metadata.gz: 4a91c4823bd9b5322c5e72b3fb402edba3d8d90f951aeb5c9b4e7762ea14a50bb91669995b2171a6a478d70b2e4234f5b55870d7c3eaa1ef159535cdd08c3a3f
7
+ data.tar.gz: 17c8c28bfa9286d09bb0e72a56372f40438a68ff594836fbca9e1146a7709f443ae37ccfeddce8e4cd842ac83025018b1171f98a8a6799b4d5918aed384bc2b1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails-interactive (2.0.0)
4
+ rails-interactive (2.1.0)
5
5
  tty-prompt
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ![render1647134864886](https://user-images.githubusercontent.com/15168877/158041125-2ba863cf-ab17-4c8e-a603-7ccb0494938b.gif)
1
+ [![asciicast](https://asciinema.org/a/mFutWNTzym5aZPqK7AgBSMjLE.svg)](https://asciinema.org/a/mFutWNTzym5aZPqK7AgBSMjLE)
2
2
 
3
3
  # Rails::Interactive
4
4
  [![Gem Version](https://badge.fury.io/rb/rails-interactive.svg)](https://badge.fury.io/rb/rails-interactive)
@@ -5,7 +5,7 @@ require "yaml"
5
5
  module RailsInteractive
6
6
  class CLI
7
7
  # Categories class for the interactive CLI module
8
- class Categories
8
+ class Category
9
9
  def initialize
10
10
  @categories = YAML.load_file("#{__dir__}/config/categories.yml").uniq
11
11
  end
@@ -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 Commands
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RailsInteractive
4
4
  class CLI
5
- VERSION = "2.0.0"
5
+ VERSION = "2.1.0"
6
6
  end
7
7
  end
@@ -2,17 +2,19 @@
2
2
 
3
3
  require "cli/prompt"
4
4
  require "cli/message"
5
- require "cli/commands"
6
- require "cli/categories"
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 = Commands.new
15
- @categories = Categories.new
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
- Utils.handle_multi_options(value) if value.is_a?(Array)
104
- Utils.handle_option(value) if value.is_a?(String)
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.0.0
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-29 00:00:00.000000000 Z
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/categories.rb
167
- - lib/cli/commands.rb
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