diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-12-16 23:04:01 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-12-16 23:04:01 +0800 |
commit | 1b4a244dbc8d1e5b79feb4f111ec6183afa1b413 (patch) | |
tree | 2fe0e9393f4e1d25529165c0771cec96c4a6de35 | |
parent | cc1eb7fec5a225342992377495e4969fdf8adf45 (diff) | |
download | gitlab-ce-1b4a244dbc8d1e5b79feb4f111ec6183afa1b413.tar.gz |
Rename to Gitlab::Serialize::Ci::Variables
Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8088#note_20133176
-rw-r--r-- | app/models/ci/build.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/serialize/ci/variables.rb | 32 | ||||
-rw-r--r-- | lib/gitlab/serialize/yaml_variables.rb | 31 | ||||
-rw-r--r-- | spec/lib/gitlab/serialize/ci/variables_spec.rb (renamed from spec/lib/gitlab/serialize/yaml_variables_spec.rb) | 2 |
4 files changed, 34 insertions, 33 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 99f3f4711aa..0e30755b870 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -10,7 +10,7 @@ module Ci has_many :deployments, as: :deployable serialize :options - serialize :yaml_variables, Gitlab::Serialize::YamlVariables + serialize :yaml_variables, Gitlab::Serialize::Ci::Variables validates :coverage, numericality: true, allow_blank: true validates_presence_of :ref diff --git a/lib/gitlab/serialize/ci/variables.rb b/lib/gitlab/serialize/ci/variables.rb new file mode 100644 index 00000000000..0ca060cd95e --- /dev/null +++ b/lib/gitlab/serialize/ci/variables.rb @@ -0,0 +1,32 @@ +module Gitlab + module Serialize + module Ci + # This serializer could make sure our YAML variables' keys and values + # are always strings. This is more for legacy build data because + # from now on we convert them into strings before saving to database. + module Variables + extend self + + def load(string) + return unless string + + object = YAML.safe_load(string, [Symbol]) + + object.map(&Variables.method(:convert_key_value_to_string)) + end + + def dump(object) + YAML.dump(object) + end + + private + + def convert_key_value_to_string(variable) + variable[:key] = variable[:key].to_s + variable[:value] = variable[:value].to_s + variable + end + end + end + end +end diff --git a/lib/gitlab/serialize/yaml_variables.rb b/lib/gitlab/serialize/yaml_variables.rb deleted file mode 100644 index db1e7641c74..00000000000 --- a/lib/gitlab/serialize/yaml_variables.rb +++ /dev/null @@ -1,31 +0,0 @@ - -module Gitlab - module Serialize - # This serializer could make sure our YAML variables' keys and values - # are always strings. This is more for legacy build data because - # from now on we convert them into strings before saving to database. - module YamlVariables - extend self - - def load(string) - return unless string - - object = YAML.safe_load(string, [Symbol]) - - object.map(&YamlVariables.method(:convert_key_value_to_string)) - end - - def dump(object) - YAML.dump(object) - end - - private - - def convert_key_value_to_string(variable) - variable[:key] = variable[:key].to_s - variable[:value] = variable[:value].to_s - variable - end - end - end -end diff --git a/spec/lib/gitlab/serialize/yaml_variables_spec.rb b/spec/lib/gitlab/serialize/ci/variables_spec.rb index 2691c3dc22f..797baef640c 100644 --- a/spec/lib/gitlab/serialize/yaml_variables_spec.rb +++ b/spec/lib/gitlab/serialize/ci/variables_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Serialize::YamlVariables do +describe Gitlab::Serialize::Ci::Variables do subject do described_class.load(described_class.dump(object)) end |