diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-26 15:09:11 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-26 15:09:11 +0000 |
commit | 1a18b430890a59ad846deed3a8e88f54e9db4c35 (patch) | |
tree | 3dfda0922a4e2217b8de11db106148affe636145 | |
parent | bbda97dde4df05f2aaccdf325a8344f36358ccde (diff) | |
download | gitlab-ce-1a18b430890a59ad846deed3a8e88f54e9db4c35.tar.gz |
Add latest changes from gitlab-org/gitlab@master
-rw-r--r-- | changelogs/unreleased/refactoring-entities-file.yml | 5 | ||||
-rw-r--r-- | lib/api/entities.rb | 45 | ||||
-rw-r--r-- | lib/api/entities/blame_range.rb | 10 | ||||
-rw-r--r-- | lib/api/entities/blame_range_commit.rb | 13 | ||||
-rw-r--r-- | lib/api/entities/wiki_attachment.rb | 27 | ||||
-rw-r--r-- | lib/api/entities/wiki_page.rb | 9 | ||||
-rw-r--r-- | lib/api/entities/wiki_page_basic.rb | 11 |
7 files changed, 75 insertions, 45 deletions
diff --git a/changelogs/unreleased/refactoring-entities-file.yml b/changelogs/unreleased/refactoring-entities-file.yml new file mode 100644 index 00000000000..060b4abaacd --- /dev/null +++ b/changelogs/unreleased/refactoring-entities-file.yml @@ -0,0 +1,5 @@ +--- +title: Seprate 5 classes in separate files from entities +merge_request: 23299 +author: Rajendra Kadam +type: added diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 6aebeb1a597..872432f0cd7 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -11,51 +11,6 @@ module API expose :access_level end - class BlameRangeCommit < Grape::Entity - expose :id - expose :parent_ids - expose :message - expose :authored_date, :author_name, :author_email - expose :committed_date, :committer_name, :committer_email - end - - class BlameRange < Grape::Entity - expose :commit, using: BlameRangeCommit - expose :lines - end - - class WikiPageBasic < Grape::Entity - expose :format - expose :slug - expose :title - end - - class WikiPage < WikiPageBasic - expose :content - end - - class WikiAttachment < Grape::Entity - include Gitlab::FileMarkdownLinkBuilder - - expose :file_name - expose :file_path - expose :branch - expose :link do - expose :file_path, as: :url - expose :markdown do |_entity| - self.markdown_link - end - end - - def filename - object.file_name - end - - def secure_url - object.file_path - end - end - class UserSafe < Grape::Entity expose :id, :name, :username end diff --git a/lib/api/entities/blame_range.rb b/lib/api/entities/blame_range.rb new file mode 100644 index 00000000000..20d09c15278 --- /dev/null +++ b/lib/api/entities/blame_range.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module API + module Entities + class BlameRange < Grape::Entity + expose :commit, using: BlameRangeCommit + expose :lines + end + end +end diff --git a/lib/api/entities/blame_range_commit.rb b/lib/api/entities/blame_range_commit.rb new file mode 100644 index 00000000000..3c1958925d7 --- /dev/null +++ b/lib/api/entities/blame_range_commit.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module API + module Entities + class BlameRangeCommit < Grape::Entity + expose :id + expose :parent_ids + expose :message + expose :authored_date, :author_name, :author_email + expose :committed_date, :committer_name, :committer_email + end + end +end diff --git a/lib/api/entities/wiki_attachment.rb b/lib/api/entities/wiki_attachment.rb new file mode 100644 index 00000000000..e622dea04dd --- /dev/null +++ b/lib/api/entities/wiki_attachment.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module API + module Entities + class WikiAttachment < Grape::Entity + include Gitlab::FileMarkdownLinkBuilder + + expose :file_name + expose :file_path + expose :branch + expose :link do + expose :file_path, as: :url + expose :markdown do |_entity| + self.markdown_link + end + end + + def filename + object.file_name + end + + def secure_url + object.file_path + end + end + end +end diff --git a/lib/api/entities/wiki_page.rb b/lib/api/entities/wiki_page.rb new file mode 100644 index 00000000000..a8ef0bd857c --- /dev/null +++ b/lib/api/entities/wiki_page.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module API + module Entities + class WikiPage < WikiPageBasic + expose :content + end + end +end diff --git a/lib/api/entities/wiki_page_basic.rb b/lib/api/entities/wiki_page_basic.rb new file mode 100644 index 00000000000..e10c0e6d553 --- /dev/null +++ b/lib/api/entities/wiki_page_basic.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module API + module Entities + class WikiPageBasic < Grape::Entity + expose :format + expose :slug + expose :title + end + end +end |