Module: Vedeu::CLI::Helpers

Includes:
Vedeu::Common
Included in:
Application, View
Defined in:
lib/vedeu/cli/helpers.rb

Overview

Provides functionality used by the generators to build the client application.

:nocov:

Instance Method Summary collapse

Instance Method Details

#app_bin_pathString

Returns:

  • (String)


21
22
23
# File 'lib/vedeu/cli/helpers.rb', line 21

def app_bin_path
  name + '/bin/'
end

#app_borders_pathString

Returns:

  • (String)


46
47
48
# File 'lib/vedeu/cli/helpers.rb', line 46

def app_borders_path
  name + '/app/views/interfaces/borders/'
end

#app_config_pathString

Returns:

  • (String)


26
27
28
# File 'lib/vedeu/cli/helpers.rb', line 26

def app_config_path
  name + '/config/'
end

#app_controllers_pathString

Returns:

  • (String)


31
32
33
# File 'lib/vedeu/cli/helpers.rb', line 31

def app_controllers_path
  name + '/app/controllers/'
end

#app_geometries_pathString

Returns:

  • (String)


51
52
53
# File 'lib/vedeu/cli/helpers.rb', line 51

def app_geometries_path
  name + '/app/views/interfaces/geometries/'
end

#app_helpers_pathString

Returns:

  • (String)


36
37
38
# File 'lib/vedeu/cli/helpers.rb', line 36

def app_helpers_path
  name + '/app/helpers/'
end

#app_keymaps_pathString

Returns:

  • (String)


56
57
58
# File 'lib/vedeu/cli/helpers.rb', line 56

def app_keymaps_path
  name + '/app/models/keymaps/'
end

#app_models_pathString

Returns:

  • (String)


41
42
43
# File 'lib/vedeu/cli/helpers.rb', line 41

def app_models_path
  name + '/app/models/'
end

#app_nameString

Returns:

  • (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_pathString

Returns:

  • (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.

Parameters:

  • source (String)
  • destination (String)


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

Parameters:

  • destination_path (String)

Returns:

  • (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

Parameters:

  • destination_path (String)

Returns:

  • (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.

Parameters:

  • destination (String)


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.

Parameters:

  • source_path (String)
  • destination_path (String)


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

#nameString Also known as: app_root_path

Returns:

  • (String)


141
142
143
# File 'lib/vedeu/cli/helpers.rb', line 141

def name
  @_name ||= @name.downcase
end

#name_as_classString

Returns:

  • (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

Returns:

  • (String)


152
153
154
155
156
# File 'lib/vedeu/cli/helpers.rb', line 152

def output(message = '')
  Vedeu.log_stdout(type: :info, message: message)

  message
end

#parse(source_path) ⇒ String

Parameters:

  • source (String)

Returns:

  • (String)


160
161
162
# File 'lib/vedeu/cli/helpers.rb', line 160

def parse(source_path)
  Vedeu::Templating::Template.parse(self, source_path)
end

#sourceString

Returns:

  • (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.

Parameters:

  • destination_path (String)


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