summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-05-14 15:33:31 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-05-14 15:33:31 +0300
commit634cbd71380f595f6f44ce93399b92fbee37f98f (patch)
treec421f7fd1b2cfbf396f8765e948b19fa47d1fd6e
parente6224942cee8f02d96e51098552a738f1d89860f (diff)
downloadgitlab-ce-634cbd71380f595f6f44ce93399b92fbee37f98f.tar.gz
Refactor API classes. So api classes like Gitlab::Issues become API::Issues
-rw-r--r--app/controllers/application_controller.rb2
-rw-r--r--config/routes.rb6
-rw-r--r--lib/api/api.rb (renamed from lib/api.rb)2
-rw-r--r--lib/api/entities.rb2
-rw-r--r--lib/api/groups.rb2
-rw-r--r--lib/api/helpers.rb2
-rw-r--r--lib/api/internal.rb4
-rw-r--r--lib/api/issues.rb2
-rw-r--r--lib/api/merge_requests.rb2
-rw-r--r--lib/api/milestones.rb2
-rw-r--r--lib/api/notes.rb2
-rw-r--r--lib/api/projects.rb2
-rw-r--r--lib/api/session.rb2
-rw-r--r--lib/api/system_hooks.rb2
-rw-r--r--lib/api/users.rb2
-rw-r--r--spec/requests/api/groups_spec.rb2
-rw-r--r--spec/requests/api/internal_spec.rb4
-rw-r--r--spec/requests/api/issues_spec.rb2
-rw-r--r--spec/requests/api/merge_requests_spec.rb2
-rw-r--r--spec/requests/api/milestones_spec.rb2
-rw-r--r--spec/requests/api/notes_spec.rb2
-rw-r--r--spec/requests/api/projects_spec.rb2
-rw-r--r--spec/requests/api/session_spec.rb2
-rw-r--r--spec/requests/api/system_hooks_spec.rb2
-rw-r--r--spec/requests/api/users_spec.rb2
-rw-r--r--spec/routing/routing_spec.rb2
-rw-r--r--spec/support/api_helpers.rb2
27 files changed, 31 insertions, 31 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index a6a887fa939..dfc1fdcee8a 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -152,7 +152,7 @@ class ApplicationController < ActionController::Base
def add_gon_variables
gon.default_issues_tracker = Project.issues_tracker.default_value
- gon.api_version = Gitlab::API.version
+ gon.api_version = API::API.version
gon.api_token = current_user.private_token if current_user
gon.gravatar_url = request.ssl? ? Gitlab.config.gravatar.ssl_url : Gitlab.config.gravatar.plain_url
gon.relative_url_root = Gitlab.config.gitlab.relative_url_root
diff --git a/config/routes.rb b/config/routes.rb
index 0e60aeb9984..0b0bd293da2 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,4 +1,5 @@
require 'sidekiq/web'
+require 'api/api'
Gitlab::Application.routes.draw do
#
@@ -7,9 +8,8 @@ Gitlab::Application.routes.draw do
get 'search' => "search#show"
# API
- require 'api'
- Gitlab::API.logger Rails.logger
- mount Gitlab::API => '/api'
+ API::API.logger Rails.logger
+ mount API::API => '/api'
constraint = lambda { |request| request.env["warden"].authenticate? and request.env['warden'].user.admin? }
constraints constraint do
diff --git a/lib/api.rb b/lib/api/api.rb
index 082769da6d3..28e6add73ed 100644
--- a/lib/api.rb
+++ b/lib/api/api.rb
@@ -1,6 +1,6 @@
Dir["#{Rails.root}/lib/api/*.rb"].each {|file| require file}
-module Gitlab
+module API
class API < Grape::API
version 'v3', using: :path
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 3fe4abc3e2a..c3c351e1733 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -1,4 +1,4 @@
-module Gitlab
+module API
module Entities
class User < Grape::Entity
expose :id, :username, :email, :name, :bio, :skype, :linkedin, :twitter,
diff --git a/lib/api/groups.rb b/lib/api/groups.rb
index efdbeb176c6..701f6777b77 100644
--- a/lib/api/groups.rb
+++ b/lib/api/groups.rb
@@ -1,4 +1,4 @@
-module Gitlab
+module API
# groups API
class Groups < Grape::API
before { authenticate! }
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index f12fb5fdbd0..94cf4f2e69f 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -1,4 +1,4 @@
-module Gitlab
+module API
module APIHelpers
def current_user
@current_user ||= User.find_by_authentication_token(params[:private_token] || env["HTTP_PRIVATE_TOKEN"])
diff --git a/lib/api/internal.rb b/lib/api/internal.rb
index 3e1173bd0a3..a602dc05418 100644
--- a/lib/api/internal.rb
+++ b/lib/api/internal.rb
@@ -1,4 +1,4 @@
-module Gitlab
+module API
# Internal access API
class Internal < Grape::API
namespace 'internal' do
@@ -58,7 +58,7 @@ module Gitlab
get "/check" do
{
- api_version: Gitlab::API.version,
+ api_version: API.version,
gitlab_version: Gitlab::VERSION,
gitlab_rev: Gitlab::REVISION,
}
diff --git a/lib/api/issues.rb b/lib/api/issues.rb
index 500a8551f35..53e2e8cfa35 100644
--- a/lib/api/issues.rb
+++ b/lib/api/issues.rb
@@ -1,4 +1,4 @@
-module Gitlab
+module API
# Issues API
class Issues < Grape::API
before { authenticate! }
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb
index d5595d5f16b..23e2f82889f 100644
--- a/lib/api/merge_requests.rb
+++ b/lib/api/merge_requests.rb
@@ -1,4 +1,4 @@
-module Gitlab
+module API
# MergeRequest API
class MergeRequests < Grape::API
before { authenticate! }
diff --git a/lib/api/milestones.rb b/lib/api/milestones.rb
index 1adeefece1f..a25bbad1302 100644
--- a/lib/api/milestones.rb
+++ b/lib/api/milestones.rb
@@ -1,4 +1,4 @@
-module Gitlab
+module API
# Milestones API
class Milestones < Grape::API
before { authenticate! }
diff --git a/lib/api/notes.rb b/lib/api/notes.rb
index 450faae535a..cb2bc764476 100644
--- a/lib/api/notes.rb
+++ b/lib/api/notes.rb
@@ -1,4 +1,4 @@
-module Gitlab
+module API
# Notes API
class Notes < Grape::API
before { authenticate! }
diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index 18e912ff48e..d9743b4539a 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -1,4 +1,4 @@
-module Gitlab
+module API
# Projects API
class Projects < Grape::API
before { authenticate! }
diff --git a/lib/api/session.rb b/lib/api/session.rb
index b4050160ae4..509acded51e 100644
--- a/lib/api/session.rb
+++ b/lib/api/session.rb
@@ -1,4 +1,4 @@
-module Gitlab
+module API
# Users API
class Session < Grape::API
# Login to get token
diff --git a/lib/api/system_hooks.rb b/lib/api/system_hooks.rb
index 9e3574e3b99..3e239c5afe7 100644
--- a/lib/api/system_hooks.rb
+++ b/lib/api/system_hooks.rb
@@ -1,4 +1,4 @@
-module Gitlab
+module API
# Hooks API
class SystemHooks < Grape::API
before {
diff --git a/lib/api/users.rb b/lib/api/users.rb
index cda543495a0..84256b51124 100644
--- a/lib/api/users.rb
+++ b/lib/api/users.rb
@@ -1,4 +1,4 @@
-module Gitlab
+module API
# Users API
class Users < Grape::API
before { authenticate! }
diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb
index cf284b607a5..d2e25fb9e23 100644
--- a/spec/requests/api/groups_spec.rb
+++ b/spec/requests/api/groups_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::API do
+describe API::API do
include ApiHelpers
let(:user1) { create(:user) }
diff --git a/spec/requests/api/internal_spec.rb b/spec/requests/api/internal_spec.rb
index ba11a41da29..5a43953d15c 100644
--- a/spec/requests/api/internal_spec.rb
+++ b/spec/requests/api/internal_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::API do
+describe API::API do
include ApiHelpers
let(:user) { create(:user) }
@@ -12,7 +12,7 @@ describe Gitlab::API do
get api("/internal/check")
response.status.should == 200
- json_response['api_version'].should == Gitlab::API.version
+ json_response['api_version'].should == API::API.version
end
end
diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb
index ecf0bdb7084..d5f75367e4a 100644
--- a/spec/requests/api/issues_spec.rb
+++ b/spec/requests/api/issues_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::API do
+describe API::API do
include ApiHelpers
let(:user) { create(:user) }
diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb
index 25bbd9860bd..5bf228a7448 100644
--- a/spec/requests/api/merge_requests_spec.rb
+++ b/spec/requests/api/merge_requests_spec.rb
@@ -1,6 +1,6 @@
require "spec_helper"
-describe Gitlab::API do
+describe API::API do
include ApiHelpers
let(:user) { create(:user ) }
diff --git a/spec/requests/api/milestones_spec.rb b/spec/requests/api/milestones_spec.rb
index c9a10417fff..af12c088c8f 100644
--- a/spec/requests/api/milestones_spec.rb
+++ b/spec/requests/api/milestones_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::API do
+describe API::API do
include ApiHelpers
before(:each) { enable_observers }
diff --git a/spec/requests/api/notes_spec.rb b/spec/requests/api/notes_spec.rb
index 901640834f2..78d55a7b4ed 100644
--- a/spec/requests/api/notes_spec.rb
+++ b/spec/requests/api/notes_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::API do
+describe API::API do
include ApiHelpers
let(:user) { create(:user) }
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index 7aeee354ba1..4346bfe8f2e 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::API do
+describe API::API do
include ApiHelpers
before(:each) { enable_observers }
diff --git a/spec/requests/api/session_spec.rb b/spec/requests/api/session_spec.rb
index 4a37312bffd..88c17f26a69 100644
--- a/spec/requests/api/session_spec.rb
+++ b/spec/requests/api/session_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::API do
+describe API::API do
include ApiHelpers
let(:user) { create(:user) }
diff --git a/spec/requests/api/system_hooks_spec.rb b/spec/requests/api/system_hooks_spec.rb
index 647e31ce034..b1df3cb7886 100644
--- a/spec/requests/api/system_hooks_spec.rb
+++ b/spec/requests/api/system_hooks_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::API do
+describe API::API do
include ApiHelpers
let(:user) { create(:user) }
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb
index b4688dd29f7..33df9f7ece5 100644
--- a/spec/requests/api/users_spec.rb
+++ b/spec/requests/api/users_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::API do
+describe API::API do
include ApiHelpers
let(:user) { create(:user) }
diff --git a/spec/routing/routing_spec.rb b/spec/routing/routing_spec.rb
index 5ad8165ecce..049cfeaab01 100644
--- a/spec/routing/routing_spec.rb
+++ b/spec/routing/routing_spec.rb
@@ -7,7 +7,7 @@ describe SearchController, "routing" do
end
end
-# gitlab_api /api Gitlab::API
+# gitlab_api /api API::API
# resque /info/resque Resque::Server
# /:path Grack
describe "Mounted Apps", "routing" do
diff --git a/spec/support/api_helpers.rb b/spec/support/api_helpers.rb
index c4514bf38be..ec9a326a1ea 100644
--- a/spec/support/api_helpers.rb
+++ b/spec/support/api_helpers.rb
@@ -18,7 +18,7 @@ module ApiHelpers
#
# Returns the relative path to the requested API resource
def api(path, user = nil)
- "/api/#{Gitlab::API.version}#{path}" +
+ "/api/#{API::API.version}#{path}" +
# Normalize query string
(path.index('?') ? '' : '?') +