Class: DeployChanges::Validator
- Inherits:
-
Object
- Object
- DeployChanges::Validator
- Defined in:
- lib/deploy_changes/validator.rb
Instance Attribute Summary collapse
-
#error_raiser ⇒ Object
Returns the value of attribute error_raiser.
-
#notifier ⇒ Object
Returns the value of attribute notifier.
Instance Method Summary collapse
-
#initialize(notifier_object) ⇒ Validator
constructor
A new instance of Validator.
- #last_command_successful? ⇒ Boolean
- #validate_deploy_job_build_number(job_build_number) ⇒ Object
- #validate_deploy_job_name(job_name) ⇒ Object
- #validate_new_tag(new_tag_name) ⇒ Object
- #validate_repo_cloned(repo_directory_name) ⇒ Object
- #validate_repo_url(repo_url) ⇒ Object
- #validate_slack_api_token(token) ⇒ Object
- #validate_slack_channel_name(channel_name) ⇒ Object
- #validate_tag_prefix(prefix) ⇒ Object
Constructor Details
#initialize(notifier_object) ⇒ Validator
Returns a new instance of Validator.
9 10 11 12 |
# File 'lib/deploy_changes/validator.rb', line 9 def initialize(notifier_object) self.notifier = notifier_object self.error_raiser = ErrorRaiser.new end |
Instance Attribute Details
#error_raiser ⇒ Object
Returns the value of attribute error_raiser.
7 8 9 |
# File 'lib/deploy_changes/validator.rb', line 7 def error_raiser @error_raiser end |
#notifier ⇒ Object
Returns the value of attribute notifier.
7 8 9 |
# File 'lib/deploy_changes/validator.rb', line 7 def notifier @notifier end |
Instance Method Details
#last_command_successful? ⇒ Boolean
56 57 58 |
# File 'lib/deploy_changes/validator.rb', line 56 def last_command_successful? $CHILD_STATUS.success? end |
#validate_deploy_job_build_number(job_build_number) ⇒ Object
24 25 26 27 28 |
# File 'lib/deploy_changes/validator.rb', line 24 def validate_deploy_job_build_number(job_build_number) return if non_empty_string?(job_build_number) && job_build_number.to_i > 0 error_raiser.raise_deploy_job_build_number_missing_error end |
#validate_deploy_job_name(job_name) ⇒ Object
30 31 32 |
# File 'lib/deploy_changes/validator.rb', line 30 def validate_deploy_job_name(job_name) error_raiser.raise_deploy_job_name_missing_error unless non_empty_string?(job_name) end |
#validate_new_tag(new_tag_name) ⇒ Object
38 39 40 41 42 |
# File 'lib/deploy_changes/validator.rb', line 38 def validate_new_tag(new_tag_name) return if non_empty_string?(new_tag_name) && git_tag_exists?(new_tag_name) error_raiser.raise_invalid_tag_name_error(new_tag_name) end |
#validate_repo_cloned(repo_directory_name) ⇒ Object
50 51 52 53 54 |
# File 'lib/deploy_changes/validator.rb', line 50 def validate_repo_cloned(repo_directory_name) error_raiser.raise_git_repo_clone_failed_error( notifier.git_repo_url ) unless last_command_successful? && Dir.exist?(repo_directory_name) end |
#validate_repo_url(repo_url) ⇒ Object
14 15 16 17 18 |
# File 'lib/deploy_changes/validator.rb', line 14 def validate_repo_url(repo_url) error_raiser.raise_invalid_git_repo_url_error( repo_url ) unless repo_url =~ git_repo_url_regex end |
#validate_slack_api_token(token) ⇒ Object
44 45 46 47 48 |
# File 'lib/deploy_changes/validator.rb', line 44 def validate_slack_api_token(token) return if non_empty_string?(token) error_raiser.raise_slack_api_token_missing_error end |
#validate_slack_channel_name(channel_name) ⇒ Object
34 35 36 |
# File 'lib/deploy_changes/validator.rb', line 34 def validate_slack_channel_name(channel_name) error_raiser.raise_slack_channel_missing_error unless non_empty_string?(channel_name) end |
#validate_tag_prefix(prefix) ⇒ Object
20 21 22 |
# File 'lib/deploy_changes/validator.rb', line 20 def validate_tag_prefix(prefix) error_raiser.raise_tag_prefix_missing_error unless non_empty_string?(prefix) end |