Class: RailsInteractive::CLI::Utils
- Inherits:
-
Object
- Object
- RailsInteractive::CLI::Utils
- Defined in:
- lib/cli/utils.rb
Class Method Summary collapse
- .copy_templates_to_project(project_name) ⇒ Object
- .go_to_project_directory(project_name) ⇒ Object
- .humanize(value) ⇒ Object
- .remove_templates(_project_name) ⇒ Object
- .sign_project ⇒ Object
Class Method Details
.copy_templates_to_project(project_name) ⇒ Object
25 26 27 28 29 |
# File 'lib/cli/utils.rb', line 25 def self.copy_templates_to_project(project_name) FileUtils.cp_r "#{__dir__}/templates", "./#{project_name}" go_to_project_directory(project_name) end |
.go_to_project_directory(project_name) ⇒ Object
21 22 23 |
# File 'lib/cli/utils.rb', line 21 def self.go_to_project_directory(project_name) Dir.chdir "./#{project_name}" end |
.humanize(value) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/cli/utils.rb', line 8 def self.humanize(value) return nil if value.nil? value .gsub(/^[\s_]+|[\s_]+$/, "") .gsub(/[_\s]+/, " ") .gsub(/^[a-z]/, &:upcase) end |
.remove_templates(_project_name) ⇒ Object
17 18 19 |
# File 'lib/cli/utils.rb', line 17 def self.remove_templates(_project_name) FileUtils.rm_rf("templates") end |
.sign_project ⇒ Object
31 32 33 34 35 |
# File 'lib/cli/utils.rb', line 31 def self.sign_project file = "README.md" msg = "\n> This project was generated by [Rails Interactive CLI](https://github.com/oguzsh/rails-interactive)" File.write(file, msg, mode: "a+") end |