From 32b09b8847955052765895063297181835c45b8c Mon Sep 17 00:00:00 2001 From: Tomasz Maczukin Date: Tue, 7 Mar 2017 12:30:34 +0100 Subject: Add minor refactoring --- lib/api/runner.rb | 2 +- lib/gitlab/ci/build/image.rb | 3 +-- lib/gitlab/ci/build/step.rb | 22 ++++++---------------- 3 files changed, 8 insertions(+), 19 deletions(-) (limited to 'lib') diff --git a/lib/api/runner.rb b/lib/api/runner.rb index caa330c7234..c700d2ef4a1 100644 --- a/lib/api/runner.rb +++ b/lib/api/runner.rb @@ -115,7 +115,7 @@ module API end end - desc 'Appends a patch to the job.trace' do + desc 'Appends a patch to the job trace' do http_codes [[202, 'Trace was patched'], [400, 'Missing Content-Range header'], [403, 'Forbidden'], diff --git a/lib/gitlab/ci/build/image.rb b/lib/gitlab/ci/build/image.rb index c0663f1ae8a..c62aeb60fa9 100644 --- a/lib/gitlab/ci/build/image.rb +++ b/lib/gitlab/ci/build/image.rb @@ -21,8 +21,7 @@ module Gitlab end def initialize(image) - type = image.class - @name = image if type == String + @name = image end def valid? diff --git a/lib/gitlab/ci/build/step.rb b/lib/gitlab/ci/build/step.rb index f857ab6063a..1877429ac46 100644 --- a/lib/gitlab/ci/build/step.rb +++ b/lib/gitlab/ci/build/step.rb @@ -6,7 +6,9 @@ module Gitlab WHEN_ON_SUCCESS = 'on_success'.freeze WHEN_ALWAYS = 'always'.freeze - attr_reader :name, :script, :timeout, :when, :allow_failure + attr_reader :name + attr_writer :script + attr_accessor :timeout, :when, :allow_failure class << self def from_commands(job) @@ -25,7 +27,7 @@ module Gitlab step.script = after_script step.timeout = job.timeout step.when = WHEN_ALWAYS - step.allow_failure_on + step.allow_failure = true end end end @@ -35,20 +37,8 @@ module Gitlab @allow_failure = false end - def script=(script) - @script = script.split("\n") - end - - def timeout=(timeout) - @timeout = timeout - end - - def when=(when_condition) - @when = when_condition - end - - def allow_failure_on - @allow_failure = true + def script + @script.split("\n") end end end -- cgit v1.2.3