Class: Dsu::Views::Project::Create

Inherits:
Object
  • Object
show all
Includes:
Support::Ask, Support::ColorThemable
Defined in:
lib/dsu/views/project/create.rb

Instance Method Summary collapse

Methods included from Support::ColorThemable

apply_theme, #prompt_with_options

Methods included from Support::Ask

#ask_while, #yes?

Constructor Details

#initialize(presenter:, options: {}) ⇒ Create

Returns a new instance of Create.



14
15
16
17
18
# File 'lib/dsu/views/project/create.rb', line 14

def initialize(presenter:, options: {})
  @presenter = presenter
  @options = options&.dup || {}
  @color_theme = Models::ColorTheme.find(theme_name: theme_name)
end

Instance Method Details

#renderObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dsu/views/project/create.rb', line 20

def render
  return display_project_errors if presenter.project_errors?
  return display_project_already_exists if presenter.project_already_exists?

  response = display_project_create_prompt
  if presenter.respond response: response
    display_project_created_message
  else
    display_project_cancelled_message
  end
rescue StandardError => e
  puts apply_theme(e.message, theme_color: color_theme.error)
  puts apply_theme(e.backtrace_locations.join("\n"), theme_color: color_theme.error) if Dsu.env.local?
end