From 23030439c2cf3b3ad48099eb9a4371b8bf55066f Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 6 Jun 2016 08:20:55 +0200 Subject: Rename class that loads CI configuration to Loader --- lib/ci/gitlab_ci_yaml_processor.rb | 2 +- lib/gitlab/ci/config.rb | 10 +++++----- lib/gitlab/ci/config/loader.rb | 25 +++++++++++++++++++++++++ lib/gitlab/ci/config/parser.rb | 25 ------------------------- 4 files changed, 31 insertions(+), 31 deletions(-) create mode 100644 lib/gitlab/ci/config/loader.rb delete mode 100644 lib/gitlab/ci/config/parser.rb (limited to 'lib') diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb index 9a60c5ab842..46a923161c8 100644 --- a/lib/ci/gitlab_ci_yaml_processor.rb +++ b/lib/ci/gitlab_ci_yaml_processor.rb @@ -18,7 +18,7 @@ module Ci initial_parsing validate! - rescue Gitlab::Ci::Config::ParserError => e + rescue Gitlab::Ci::Config::LoaderError => e raise ValidationError, e.message end diff --git a/lib/gitlab/ci/config.rb b/lib/gitlab/ci/config.rb index 0baefa70f61..5fc4894311f 100644 --- a/lib/gitlab/ci/config.rb +++ b/lib/gitlab/ci/config.rb @@ -1,16 +1,16 @@ module Gitlab module Ci class Config - class ParserError < StandardError; end + class LoaderError < StandardError; end def initialize(config) - parser = Parser.new(config) + loader = Loader.new(config) - unless parser.valid? - raise ParserError, 'Invalid configuration format!' + unless loader.valid? + raise LoaderError, 'Invalid configuration format!' end - @config = parser.parse + @config = loader.load end def to_hash diff --git a/lib/gitlab/ci/config/loader.rb b/lib/gitlab/ci/config/loader.rb new file mode 100644 index 00000000000..ed9cc16702c --- /dev/null +++ b/lib/gitlab/ci/config/loader.rb @@ -0,0 +1,25 @@ +module Gitlab + module Ci + class Config + class Loader + class FormatError < StandardError; end + + def initialize(config) + @config = YAML.safe_load(config, [Symbol], [], true) + end + + def valid? + @config.is_a?(Hash) + end + + def load + unless valid? + raise FormatError, 'Invalid configuration format' + end + + @config.deep_symbolize_keys + end + end + end + end +end diff --git a/lib/gitlab/ci/config/parser.rb b/lib/gitlab/ci/config/parser.rb deleted file mode 100644 index 6e1b7ec8267..00000000000 --- a/lib/gitlab/ci/config/parser.rb +++ /dev/null @@ -1,25 +0,0 @@ -module Gitlab - module Ci - class Config - class Parser - class FormatError < StandardError; end - - def initialize(config) - @config = YAML.safe_load(config, [Symbol], [], true) - end - - def valid? - @config.is_a?(Hash) - end - - def parse - unless valid? - raise FormatError, 'Invalid configuration format' - end - - @config.deep_symbolize_keys - end - end - end - end -end -- cgit v1.2.1