Skip to content

Commit

Permalink
add special method that lists available actions for client
Browse files Browse the repository at this point in the history
  • Loading branch information
NARKOZ committed May 12, 2014
1 parent fe50c24 commit 4963f16
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/gitlab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,12 @@ def self.method_missing(method, *args, &block)
def self.respond_to?(method)
return client.respond_to?(method) || super
end

# Returns an unsorted array of available client methods.
#
# @return [Array<Symbol>]
def self.actions
hidden = /endpoint|private_token|user_agent|sudo|get|post|put|\Adelete\z|validate|set_request_defaults/
(Gitlab::Client.instance_methods - Object.methods).reject {|e| e[hidden]}
end
end
9 changes: 9 additions & 0 deletions spec/gitlab_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
end
end

describe ".actions" do
it "should return an array of client methods" do
actions = Gitlab.actions
expect(actions).to be_an Array
expect(actions.first).to be_a Symbol
expect(actions.sort.first).to match(/add_/)
end
end

describe ".endpoint=" do
it "should set endpoint" do
Gitlab.endpoint = 'https://api.example.com'
Expand Down

0 comments on commit 4963f16

Please sign in to comment.