class Muwu::ControllerInteraction

Attributes

slug[RW]

Public Class Methods

new() click to toggle source
# File lib/muwu/controller/controller_interaction.rb, line 8
def initialize
  @slug = ''
end

Public Instance Methods

confirm_reset_compiled(project) click to toggle source
# File lib/muwu/controller/controller_interaction.rb, line 17
def confirm_reset_compiled(project)
  render_reset_compiled_heading
  render_reset_compiled_prompt
  @answer = $stdin.gets.chomp.strip.downcase
  if @answer == 'y'
    return true
  else
    return false
  end
end
confirm_reset_css(project) click to toggle source
# File lib/muwu/controller/controller_interaction.rb, line 29
def confirm_reset_css(project)
  render_reset_css_heading(project)
  render_reset_css_prompt
  @answer = $stdin.gets.chomp.strip.downcase
  if @answer == 'y'
    return true
  else
    return false
  end
end
request_metadata() click to toggle source
# File lib/muwu/controller/controller_interaction.rb, line 41
def request_metadata
  request_metadata_phase_1_render_heading
  request_metadata_phase_2_request_and_set_slug
  { slug: @slug }
end
request_metadata_phase_1_render_heading() click to toggle source
# File lib/muwu/controller/controller_interaction.rb, line 48
def request_metadata_phase_1_render_heading
  render_new_project_heading
  render_lf
end
request_metadata_phase_2_request_and_set_slug() click to toggle source
# File lib/muwu/controller/controller_interaction.rb, line 54
def request_metadata_phase_2_request_and_set_slug
  render_slug_heading
  while @slug == ''
    render_slug_can_not_be_blank
    render_slug_prompt
    @slug = $stdin.gets.chomp.strip
    if @slug.match(/\W/)
      @slug.gsub!(/\W/,'')
      render_slug_was_sanitized(result: @slug)
    end
  end
  render_lf
end

Private Instance Methods

determine_reset_css_files(project) click to toggle source
# File lib/muwu/controller/controller_interaction.rb, line 74
def determine_reset_css_files(project)
  [
    File.join(project.path_css_base),
    File.join(project.path_css_colors, 'dark.scss'),
    File.join(project.path_css_colors, 'index.scss'),
    File.join(project.path_css_colors, 'light.scss'),
    File.join(project.path_css, 'index.scss'),
  ]
end
render_lf() click to toggle source
# File lib/muwu/controller/controller_interaction.rb, line 85
def render_lf
  puts "\n"
end
render_new_project_heading() click to toggle source
# File lib/muwu/controller/controller_interaction.rb, line 90
def render_new_project_heading
  puts '# Muwu'
  puts '# New Project'
end
render_reset_compiled_heading() click to toggle source
# File lib/muwu/controller/controller_interaction.rb, line 96
def render_reset_compiled_heading
  puts '# Muwu'
  puts '# Reset `compiled/`'
  puts '- This will remove all contents of the `compiled/` folder.'
  puts '- This action cannot be undone.'
end
render_reset_compiled_prompt() click to toggle source
# File lib/muwu/controller/controller_interaction.rb, line 104
def render_reset_compiled_prompt
  print '> Continue resetting the `compiled/` folder? (y/N) '
end
render_reset_css_heading(project) click to toggle source
# File lib/muwu/controller/controller_interaction.rb, line 109
def render_reset_css_heading(project)
  puts '# Muwu'
  puts '# Reset CSS'
  puts '- This will reset the following files and folders to their original state:'
  determine_reset_css_files(project).each do |file|
    puts "  * #{file}"
  end
  puts "- If #{project.path_css_extensions} does not exist, it will be created."
  puts '  Otherwise, its existing contents will remain unchanged.'
  puts '- This action cannot be undone'
end
render_reset_css_prompt() click to toggle source
# File lib/muwu/controller/controller_interaction.rb, line 122
def render_reset_css_prompt
  print '> Continue with CSS reset? (y/N) '
end
render_slug_can_not_be_blank() click to toggle source
# File lib/muwu/controller/controller_interaction.rb, line 138
def render_slug_can_not_be_blank
  puts '- Directory Name can not be blank.'
end
render_slug_heading() click to toggle source
# File lib/muwu/controller/controller_interaction.rb, line 127
def render_slug_heading
  puts '# Project Directory Name'
  puts '- Word characters `[a-zA-Z0-9_]` only; non-word characters will be removed.'
end
render_slug_prompt() click to toggle source
# File lib/muwu/controller/controller_interaction.rb, line 133
def render_slug_prompt
  print '> Directory Name for project: '
end
render_slug_was_sanitized(result: nil) click to toggle source
# File lib/muwu/controller/controller_interaction.rb, line 143
def render_slug_was_sanitized(result: nil)
  puts '- Directory Name contained non-word characters that were removed.'
  if result
    puts "  - Modified Directory Name: `#{result}`"
  end
end
render_title_can_not_be_blank() click to toggle source
# File lib/muwu/controller/controller_interaction.rb, line 162
def render_title_can_not_be_blank
  puts '- Title can not be blank.'
end
render_title_heading() click to toggle source
# File lib/muwu/controller/controller_interaction.rb, line 151
def render_title_heading
  puts "\n"
  puts '# Project Title'
end
render_title_prompt() click to toggle source
# File lib/muwu/controller/controller_interaction.rb, line 157
def render_title_prompt
  print '> Title of project: '
end