-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
605 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../models/project' | ||
require_relative '../base_presenter_ex' | ||
|
||
module Dsu | ||
module Presenters | ||
module Project | ||
class UseByNumberPresenter < BasePresenterEx | ||
attr_reader :project_number | ||
|
||
delegate :project_name, to: :project, allow_nil: true | ||
delegate :description, to: :project, prefix: true, allow_nil: true | ||
|
||
def initialize(project_number:, options: {}) | ||
super(options: options) | ||
|
||
raise ArgumentError, 'project_number is blank' if project_number.blank? | ||
|
||
self.project_number = project_number | ||
end | ||
|
||
def respond(response:) | ||
return false unless response | ||
|
||
project.use! if project&.present? | ||
end | ||
|
||
def project_does_not_exist? | ||
!project&.exist? | ||
end | ||
|
||
def project_errors | ||
return false unless project&.persisted? | ||
|
||
project.errors.full_messages | ||
end | ||
|
||
private | ||
|
||
attr_writer :project_number | ||
|
||
def project | ||
@project ||= Models::Project.find_by_number(project_number: project_number) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../env' | ||
require_relative '../../models/color_theme' | ||
require_relative '../../support/ask' | ||
require_relative '../../support/color_themable' | ||
require_relative 'use' | ||
|
||
module Dsu | ||
module Views | ||
module Project | ||
class UseByNumber < Use | ||
private | ||
|
||
def display_project_does_not_exists | ||
message = I18n.t('subcommands.project.messages.number_does_not_exist', | ||
project_number: presenter.project_number) | ||
puts apply_theme(message, theme_color: color_theme.error) | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.