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_borders_path ⇒ String
- #app_config_path ⇒ String
- #app_controllers_path ⇒ String
- #app_geometries_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_path) ⇒ TrueClass
- #log_skipped_file(destination_path) ⇒ TrueClass
- #make_directory(destination) ⇒ void
- #make_file(source_path, destination_path) ⇒ void
- #name ⇒ String (also: #app_root_path)
- #name_as_class ⇒ String
- #output(message = '') ⇒ String
- #parse(source_path) ⇒ String
- #source ⇒ String
- #touch_file(destination_path) ⇒ void
Instance Method Details
#app_bin_path ⇒ String
21 22 23 |
# File 'lib/vedeu/cli/helpers.rb', line 21 def app_bin_path name + '/bin/' end |
#app_borders_path ⇒ String
46 47 48 |
# File 'lib/vedeu/cli/helpers.rb', line 46 def app_borders_path name + '/app/views/interfaces/borders/' end |
#app_config_path ⇒ String
26 27 28 |
# File 'lib/vedeu/cli/helpers.rb', line 26 def app_config_path name + '/config/' end |
#app_controllers_path ⇒ String
31 32 33 |
# File 'lib/vedeu/cli/helpers.rb', line 31 def app_controllers_path name + '/app/controllers/' end |
#app_geometries_path ⇒ String
51 52 53 |
# File 'lib/vedeu/cli/helpers.rb', line 51 def app_geometries_path name + '/app/views/interfaces/geometries/' end |
#app_helpers_path ⇒ String
36 37 38 |
# File 'lib/vedeu/cli/helpers.rb', line 36 def app_helpers_path name + '/app/helpers/' end |
#app_keymaps_path ⇒ String
56 57 58 |
# File 'lib/vedeu/cli/helpers.rb', line 56 def app_keymaps_path name + '/app/models/keymaps/' end |
#app_models_path ⇒ String
41 42 43 |
# File 'lib/vedeu/cli/helpers.rb', line 41 def app_models_path name + '/app/models/' end |
#app_name ⇒ String
16 17 18 |
# File 'lib/vedeu/cli/helpers.rb', line 16 def app_name @app_name ||= File.read('./config/app_name') end |
#app_views_path ⇒ String
61 62 63 |
# File 'lib/vedeu/cli/helpers.rb', line 61 def app_views_path name + '/app/views/' end |
#copy_file(source, destination) ⇒ void
This method returns an undefined value.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/vedeu/cli/helpers.rb', line 78 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_path) ⇒ TrueClass
113 114 115 116 117 |
# File 'lib/vedeu/cli/helpers.rb', line 113 def log_processed_file(destination_path) Vedeu.log_stdout(type: :create, message: destination_path) true end |
#log_skipped_file(destination_path) ⇒ TrueClass
121 122 123 124 125 126 127 128 |
# File 'lib/vedeu/cli/helpers.rb', line 121 def log_skipped_file(destination_path) Vedeu.log_stdout(type: :create, message: "#{destination_path} " + Vedeu::Esc.red { 'already exists, skipped.' }) true end |
#make_directory(destination) ⇒ void
This method returns an undefined value.
67 68 69 70 71 72 73 |
# File 'lib/vedeu/cli/helpers.rb', line 67 def make_directory(destination) log_processed_file(destination) FileUtils.mkdir_p(destination) true end |
#make_file(source_path, destination_path) ⇒ void
This method returns an undefined value.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/vedeu/cli/helpers.rb', line 96 def make_file(source_path, destination_path) if File.exist?(destination_path) log_skipped_file(destination_path) false else log_processed_file(destination_path) File.write(destination_path, parse(source_path)) true end end |
#name ⇒ String Also known as: app_root_path
141 142 143 |
# File 'lib/vedeu/cli/helpers.rb', line 141 def name @_name ||= @name.downcase end |
#name_as_class ⇒ String
147 148 149 |
# File 'lib/vedeu/cli/helpers.rb', line 147 def name_as_class name.downcase.split(/_|-/).map(&:capitalize).join end |
#output(message = '') ⇒ String
152 153 154 155 156 |
# File 'lib/vedeu/cli/helpers.rb', line 152 def output( = '') Vedeu.log_stdout(type: :info, message: ) end |
#parse(source_path) ⇒ String
160 161 162 |
# File 'lib/vedeu/cli/helpers.rb', line 160 def parse(source_path) Vedeu::Templating::Template.parse(self, source_path) end |
#source ⇒ String
165 166 167 |
# File 'lib/vedeu/cli/helpers.rb', line 165 def source File.dirname(__FILE__) + '/templates/application/.' end |
#touch_file(destination_path) ⇒ void
This method returns an undefined value.
132 133 134 135 136 137 138 |
# File 'lib/vedeu/cli/helpers.rb', line 132 def touch_file(destination_path) log_processed_file(destination_path) FileUtils.touch(destination_path) true end |