diff options
author | Leandro Camargo <leandroico@gmail.com> | 2016-12-13 02:53:12 -0200 |
---|---|---|
committer | Leandro Camargo <leandroico@gmail.com> | 2017-01-25 01:07:45 -0200 |
commit | 8fe708f4a2850d71c11234b234e039b2a9422299 (patch) | |
tree | 95337889798b4166b35e5b8e8929a14c4f13f98b /lib | |
parent | 518fd2eb93711e1e9c3d597a6bdf13366d9abdb5 (diff) | |
download | gitlab-ce-8fe708f4a2850d71c11234b234e039b2a9422299.tar.gz |
Make more code improvements around the '/' stripping logic
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/ci/config/entry/coverage.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/ci/config/entry/validators.rb | 12 |
2 files changed, 8 insertions, 8 deletions
diff --git a/lib/gitlab/ci/config/entry/coverage.rb b/lib/gitlab/ci/config/entry/coverage.rb index 25546f363fb..12a063059cb 100644 --- a/lib/gitlab/ci/config/entry/coverage.rb +++ b/lib/gitlab/ci/config/entry/coverage.rb @@ -11,6 +11,10 @@ module Gitlab validations do validates :config, regexp: true end + + def value + @config[1...-1] + end end end end diff --git a/lib/gitlab/ci/config/entry/validators.rb b/lib/gitlab/ci/config/entry/validators.rb index 5f50b80af6c..30c52dd65e8 100644 --- a/lib/gitlab/ci/config/entry/validators.rb +++ b/lib/gitlab/ci/config/entry/validators.rb @@ -66,7 +66,7 @@ module Gitlab private def look_like_regexp?(value) - value =~ %r{\A/.*/\z} + value.start_with?('/') && value.end_with?('/') end def validate_regexp(value) @@ -78,7 +78,7 @@ module Gitlab end end - class ArrayOfStringsOrRegexps < RegexpValidator + class ArrayOfStringsOrRegexpsValidator < RegexpValidator def validate_each(record, attribute, value) unless validate_array_of_strings_or_regexps(value) record.errors.add(attribute, 'should be an array of strings or regexps') @@ -94,12 +94,8 @@ module Gitlab def validate_string_or_regexp(value) return true if value.is_a?(Symbol) return false unless value.is_a?(String) - - if look_like_regexp?(value) - validate_regexp(value) - else - true - end + return validate_regexp(value) if look_like_regexp?(value) + true end end |