Module: Vedeu::CLI::Helpers
Overview
Provides functionality used by the generators to build the client application.
:nocov:
Instance Method Summary collapse
- #app_bin_path ⇒ String
- #app_config_path ⇒ String
- #app_controllers_path ⇒ String
- #app_helpers_path ⇒ String
- #app_keymaps_path ⇒ String
- #app_models_path ⇒ String
- #app_name ⇒ String
- #app_views_path ⇒ String
- #copy_file(source, destination) ⇒ void
- #log_processed_file(destination) ⇒ TrueClass
- #log_skipped_file(destination) ⇒ TrueClass
- #make_directory(destination) ⇒ void
- #make_file(source, destination) ⇒ void
- #name ⇒ String (also: #app_root_path)
- #name_as_class ⇒ String
- #output(message = '') ⇒ String
- #parse(source) ⇒ String
- #source ⇒ String
- #touch_file(destination) ⇒ void
Instance Method Details
#app_bin_path ⇒ String
19 20 21 |
# File 'lib/vedeu/cli/helpers.rb', line 19 def app_bin_path name + '/bin/' end |
#app_config_path ⇒ String
24 25 26 |
# File 'lib/vedeu/cli/helpers.rb', line 24 def app_config_path name + '/config/' end |
#app_controllers_path ⇒ String
29 30 31 |
# File 'lib/vedeu/cli/helpers.rb', line 29 def app_controllers_path name + '/app/controllers/' end |
#app_helpers_path ⇒ String
34 35 36 |
# File 'lib/vedeu/cli/helpers.rb', line 34 def app_helpers_path name + '/app/helpers/' end |
#app_keymaps_path ⇒ String
44 45 46 |
# File 'lib/vedeu/cli/helpers.rb', line 44 def app_keymaps_path name + '/app/models/keymaps/' end |
#app_models_path ⇒ String
39 40 41 |
# File 'lib/vedeu/cli/helpers.rb', line 39 def app_models_path name + '/app/models/' end |
#app_name ⇒ String
14 15 16 |
# File 'lib/vedeu/cli/helpers.rb', line 14 def app_name @app_name ||= File.read('./config/app_name') end |
#app_views_path ⇒ String
49 50 51 |
# File 'lib/vedeu/cli/helpers.rb', line 49 def app_views_path name + '/app/views/' end |
#copy_file(source, destination) ⇒ void
This method returns an undefined value.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/vedeu/cli/helpers.rb', line 66 def copy_file(source, destination) if File.exist?(destination) log_skipped_file(destination) false else log_processed_file(destination) FileUtils.cp(source, destination) true end end |
#log_processed_file(destination) ⇒ TrueClass
101 102 103 104 105 |
# File 'lib/vedeu/cli/helpers.rb', line 101 def log_processed_file(destination) Vedeu.log_stdout(type: :create, message: "#{destination}") true end |
#log_skipped_file(destination) ⇒ TrueClass
109 110 111 112 113 114 115 116 |
# File 'lib/vedeu/cli/helpers.rb', line 109 def log_skipped_file(destination) Vedeu.log_stdout(type: :create, message: "#{destination} " + Vedeu::EscapeSequences::Esc.red { 'already exists, skipped.' }) true end |
#make_directory(destination) ⇒ void
This method returns an undefined value.
55 56 57 58 59 60 61 |
# File 'lib/vedeu/cli/helpers.rb', line 55 def make_directory(destination) log_processed_file(destination) FileUtils.mkdir_p(destination) true end |
#make_file(source, destination) ⇒ void
This method returns an undefined value.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/vedeu/cli/helpers.rb', line 84 def make_file(source, destination) if File.exist?(destination) log_skipped_file(destination) false else log_processed_file(destination) File.write(destination, parse(source)) true end end |
#name ⇒ String Also known as: app_root_path
129 130 131 |
# File 'lib/vedeu/cli/helpers.rb', line 129 def name @_name ||= @name.downcase end |
#name_as_class ⇒ String
135 136 137 |
# File 'lib/vedeu/cli/helpers.rb', line 135 def name_as_class name.downcase.split(/_|-/).map(&:capitalize).join end |
#output(message = '') ⇒ String
140 141 142 143 144 |
# File 'lib/vedeu/cli/helpers.rb', line 140 def output( = '') Vedeu.log_stdout(type: :info, message: ) end |
#parse(source) ⇒ String
148 149 150 |
# File 'lib/vedeu/cli/helpers.rb', line 148 def parse(source) Vedeu::Templating::Template.parse(self, source) end |
#source ⇒ String
153 154 155 |
# File 'lib/vedeu/cli/helpers.rb', line 153 def source File.dirname(__FILE__) + '/templates/application/.' end |
#touch_file(destination) ⇒ void
This method returns an undefined value.
120 121 122 123 124 125 126 |
# File 'lib/vedeu/cli/helpers.rb', line 120 def touch_file(destination) log_processed_file(destination) FileUtils.touch(destination) true end |