Thanks to visit codestin.com
Credit goes to github.com

Skip to content
17 changes: 12 additions & 5 deletions lib/gitlab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@ def self.client(options = {})
Gitlab::Client.new(options)
end

# Delegate to Gitlab::Client
def self.method_missing(method, *args, &block)
return super unless client.respond_to?(method)

client.send(method, *args, &block)
if Gem::Version.new(RUBY_VERSION).release >= Gem::Version.new('3.0.0')
def self.method_missing(method, *args, **keywargs, &block)
return super unless client.respond_to?(method)

client.send(method, *args, **keywargs, &block)
end
else
def self.method_missing(method, *args, &block)
return super unless client.respond_to?(method)

client.send(method, *args, &block)
end
end

# Delegate to Gitlab::Client
Expand Down
2 changes: 1 addition & 1 deletion lib/gitlab/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def self.run(cmd, args = [])
# Helper method that checks whether we want to get the output as json
# @return [nil]
def self.render_output(cmd, args, data)
if @json_output
if defined?(@json_output) && @json_output
output_json(cmd, args, data)
else
output_table(cmd, args, data)
Expand Down
10 changes: 5 additions & 5 deletions lib/gitlab/help.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ def namespace(cmd)
# Massage output from 'ri'.
def change_help_output!(cmd, output_str)
output_str = +output_str
output_str.gsub!(/#{cmd}\((.*?)\)/m, "#{cmd} \1")
output_str.gsub!(/,\s*/, ' ')
output_str.gsub!(/#{cmd}(\(.*?\))/m, "#{cmd}\\1")
output_str.gsub!(/,\s*/, ', ')

# Ensure @option descriptions are on a single line
output_str.gsub!(/\n\[/, " \[")
output_str.gsub!(/\s(@)/, "\n@")
output_str.gsub!(/(\])\n(:)/, '\1 \2')
output_str.gsub!(/(:.*)(\n)(.*\.)/, '\1 \3')
output_str.gsub!(/\{(.+)\}/, '"{\1}"')
output_str.gsub!(/(\])\n(:)/, '\\1 \\2')
output_str.gsub!(/(:.*)(\n)(.*\.)/, '\\1 \\3')
output_str.gsub!(/\{(.+)\}/, '"{\\1}"')
end
end
end
2 changes: 1 addition & 1 deletion spec/gitlab/client/build_variables_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

describe '.create_variable' do
before do
stub_post('/projects/3/variables', 'variable')
stub_post('/projects/3/variables', 'variable', { masked: true })
@variable = Gitlab.create_variable(3, 'NEW_VARIABLE', 'new value')
end

Expand Down
4 changes: 2 additions & 2 deletions spec/gitlab/client/users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@
describe 'create' do
before do
stub_post('/users/2/impersonation_tokens', 'impersonation_create')
@token = Gitlab.create_user_impersonation_token(2, 'mytoken', scopes)
@token = Gitlab.create_user_impersonation_token(2, 'mytoken', ['api'])
end

it 'gets the correct resource' do
Expand All @@ -614,7 +614,7 @@

it 'removes a token' do
expect(a_delete('/users/2/impersonation_tokens/2')).to have_been_made
expect(@token).to be_empty
expect(@token.to_hash).to be_empty
end
end
end