diff options
author | Tomasz Maczukin <tomasz@maczukin.pl> | 2016-04-21 13:58:30 +0300 |
---|---|---|
committer | Tomasz Maczukin <tomasz@maczukin.pl> | 2016-04-22 23:08:36 +0300 |
commit | 0ccf6295254dbf72cf081c8c99a95c59a54ba655 (patch) | |
tree | 6619e414886064407290935cc25328027a90eecb /lib | |
parent | e1b3ce546865d405fd942611cdc8ec810b16fa74 (diff) |
Simplify the GitlabCiYamlProcessor#initial_parsing method
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ci/gitlab_ci_yaml_processor.rb | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb index 4319d99d520..59ac861ee79 100644 --- a/lib/ci/gitlab_ci_yaml_processor.rb +++ b/lib/ci/gitlab_ci_yaml_processor.rb @@ -61,28 +61,23 @@ module Ci @stages = @config[:stages] || @config[:types] @variables = @config[:variables] || {} @cache = @config[:cache] - @config.except!(*ALLOWED_YAML_KEYS) + @jobs = {} + @config.except!(*ALLOWED_YAML_KEYS) @config.each do |name, param| - raise ValidationError, "Unknown parameter: #{name}" unless is_a_job?(name, param) - end - - unless @config.values.any?{|job| job.is_a?(Hash)} - raise ValidationError, "Please define at least one job" + add_job(name, param) end - @jobs = {} - @config.each do |key, job| - next if key.to_s.start_with?('.') - stage = job[:stage] || job[:type] || DEFAULT_STAGE - @jobs[key] = { stage: stage }.merge(job) - end + raise ValidationError, "Please define at least one job" if @jobs.none? end - def is_a_job?(name, value) - return true if value.is_a?(Hash) && value.has_key?(:script) - return true if name.to_s.start_with?('.') - false + def add_job(name, job) + return if name.to_s.start_with?('.') + + raise ValidationError, "Unknown parameter: #{name}" unless job.is_a?(Hash) && job.has_key?(:script) + + stage = job[:stage] || job[:type] || DEFAULT_STAGE + @jobs[name] = { stage: stage }.merge(job) end def build_job(name, job) |