From f44b374d791d769abff3fab98a77b807224ed971 Mon Sep 17 00:00:00 2001 From: carlad Date: Mon, 7 Sep 2015 17:09:05 +0200 Subject: [PATCH] v3 add branches endpoint --- lib/travis/api/v3/queries/branches.rb | 7 +++++++ lib/travis/api/v3/renderer/branches.rb | 6 ++++++ lib/travis/api/v3/routes.rb | 3 +++ lib/travis/api/v3/services.rb | 1 + lib/travis/api/v3/services/branches/find.rb | 9 +++++++++ 5 files changed, 26 insertions(+) create mode 100644 lib/travis/api/v3/queries/branches.rb create mode 100644 lib/travis/api/v3/renderer/branches.rb create mode 100644 lib/travis/api/v3/services/branches/find.rb diff --git a/lib/travis/api/v3/queries/branches.rb b/lib/travis/api/v3/queries/branches.rb new file mode 100644 index 00000000..0491e0b2 --- /dev/null +++ b/lib/travis/api/v3/queries/branches.rb @@ -0,0 +1,7 @@ +module Travis::API::V3 + class Queries::Branches < Query + def find(repository) + repository.branches + end + end +end diff --git a/lib/travis/api/v3/renderer/branches.rb b/lib/travis/api/v3/renderer/branches.rb new file mode 100644 index 00000000..4a927c23 --- /dev/null +++ b/lib/travis/api/v3/renderer/branches.rb @@ -0,0 +1,6 @@ +module Travis::API::V3 + class Renderer::Branches < Renderer::CollectionRenderer + type :branches + collection_key :branches + end +end diff --git a/lib/travis/api/v3/routes.rb b/lib/travis/api/v3/routes.rb index 926d6776..c2337f56 100644 --- a/lib/travis/api/v3/routes.rb +++ b/lib/travis/api/v3/routes.rb @@ -12,6 +12,9 @@ module Travis::API::V3 capture id: :digit route '/build/{build.id}' get :find + + # post :cancel, '/cancel' + # post :restart, '/restart' end resource :job do diff --git a/lib/travis/api/v3/services.rb b/lib/travis/api/v3/services.rb index a25984f1..5098e10f 100644 --- a/lib/travis/api/v3/services.rb +++ b/lib/travis/api/v3/services.rb @@ -4,6 +4,7 @@ module Travis::API::V3 Accounts = Module.new { extend Services } Branch = Module.new { extend Services } + Branch = Module.new { extend Services } Build = Module.new { extend Services } Builds = Module.new { extend Services } Job = Module.new { extend Services } diff --git a/lib/travis/api/v3/services/branches/find.rb b/lib/travis/api/v3/services/branches/find.rb new file mode 100644 index 00000000..76e22c31 --- /dev/null +++ b/lib/travis/api/v3/services/branches/find.rb @@ -0,0 +1,9 @@ +module Travis::API::V3 + class Services::Branches::Find < Service + paginate + def run! + query.find(find(:repository)) + end + end + +end