Class: Gitlab::PushOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/push_options.rb

Constant Summary collapse

VALID_OPTIONS =
HashWithIndifferentAccess.new({
  merge_request: {
    keys: [
      :assign,
      :create,
      :description,
      :draft,
      :label,
      :merge_when_pipeline_succeeds,
      :milestone,
      :remove_source_branch,
      :target,
      :title,
      :unassign,
      :unlabel
    ]
  },
  ci: {
    keys: [:skip, :variable]
  },
  integrations: {
    keys: [:skip_ci]
  }
}).freeze
MULTI_VALUE_OPTIONS =
[
  %w[ci variable],
  %w[merge_request label],
  %w[merge_request unlabel],
  %w[merge_request assign],
  %w[merge_request unassign]
].freeze
NAMESPACE_ALIASES =
HashWithIndifferentAccess.new({
  mr: :merge_request
}).freeze
OPTION_MATCHER =
/(?<namespace>[^\.]+)\.(?<key>[^=]+)=?(?<value>.*)/
CI_SKIP =
'ci.skip'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = []) ⇒ PushOptions

Returns a new instance of PushOptions.



48
49
50
# File 'lib/gitlab/push_options.rb', line 48

def initialize(options = [])
  @options = parse_options(options)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



46
47
48
# File 'lib/gitlab/push_options.rb', line 46

def options
  @options
end

Instance Method Details

#as_json(*_args) ⇒ Object

Allow #to_json serialization



57
58
59
# File 'lib/gitlab/push_options.rb', line 57

def as_json(*_args)
  options
end

#getObject



52
53
54
# File 'lib/gitlab/push_options.rb', line 52

def get(...)
  options.dig(...)
end