diff options
author | Toon Claes <toon@gitlab.com> | 2019-02-28 19:57:34 +0100 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2019-02-28 19:57:34 +0100 |
commit | 62d7990b9bb30cf33ed87017c5c633d1cccc75c2 (patch) | |
tree | c3e1b69c58a412ba1c6f50a0337a23d9f9d6e1a4 /lib/api/snippets.rb | |
parent | f6453eca992a9c142268e78ac782cef98110d183 (diff) | |
download | gitlab-ce-tc-standard-gem.tar.gz |
Ran standardrb --fix on the whole codebasetc-standard-gem
Inspired by https://twitter.com/searls/status/1101137953743613952 I
decided to try https://github.com/testdouble/standard on our codebase.
It's opinionated, but at least it's a _standard_.
Diffstat (limited to 'lib/api/snippets.rb')
-rw-r--r-- | lib/api/snippets.rb | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/lib/api/snippets.rb b/lib/api/snippets.rb index 326d55afd0e..62e1e9aef2d 100644 --- a/lib/api/snippets.rb +++ b/lib/api/snippets.rb @@ -18,8 +18,8 @@ module API end end - desc 'Get a snippets list for authenticated user' do - detail 'This feature was introduced in GitLab 8.15.' + desc "Get a snippets list for authenticated user" do + detail "This feature was introduced in GitLab 8.15." success Entities::PersonalSnippet end params do @@ -29,42 +29,42 @@ module API present paginate(snippets_for_current_user), with: Entities::PersonalSnippet end - desc 'List all public snippets current_user has access to' do - detail 'This feature was introduced in GitLab 8.15.' + desc "List all public snippets current_user has access to" do + detail "This feature was introduced in GitLab 8.15." success Entities::PersonalSnippet end params do use :pagination end - get 'public' do + get "public" do present paginate(public_snippets), with: Entities::PersonalSnippet end - desc 'Get a single snippet' do - detail 'This feature was introduced in GitLab 8.15.' + desc "Get a single snippet" do + detail "This feature was introduced in GitLab 8.15." success Entities::PersonalSnippet end params do - requires :id, type: Integer, desc: 'The ID of a snippet' + requires :id, type: Integer, desc: "The ID of a snippet" end - get ':id' do + get ":id" do snippet = snippets_for_current_user.find(params[:id]) present snippet, with: Entities::PersonalSnippet end - desc 'Create new snippet' do - detail 'This feature was introduced in GitLab 8.15.' + desc "Create new snippet" do + detail "This feature was introduced in GitLab 8.15." success Entities::PersonalSnippet end params do - requires :title, type: String, desc: 'The title of a snippet' - requires :file_name, type: String, desc: 'The name of a snippet file' - requires :content, type: String, desc: 'The content of a snippet' - optional :description, type: String, desc: 'The description of a snippet' + requires :title, type: String, desc: "The title of a snippet" + requires :file_name, type: String, desc: "The name of a snippet file" + requires :content, type: String, desc: "The content of a snippet" + optional :description, type: String, desc: "The description of a snippet" optional :visibility, type: String, values: Gitlab::VisibilityLevel.string_values, - default: 'internal', - desc: 'The visibility of the snippet' + default: "internal", + desc: "The visibility of the snippet" end post do attrs = declared_params(include_missing: false).merge(request: request, api: true) @@ -79,25 +79,25 @@ module API end end - desc 'Update an existing snippet' do - detail 'This feature was introduced in GitLab 8.15.' + desc "Update an existing snippet" do + detail "This feature was introduced in GitLab 8.15." success Entities::PersonalSnippet end params do - requires :id, type: Integer, desc: 'The ID of a snippet' - optional :title, type: String, desc: 'The title of a snippet' - optional :file_name, type: String, desc: 'The name of a snippet file' - optional :content, type: String, desc: 'The content of a snippet' - optional :description, type: String, desc: 'The description of a snippet' + requires :id, type: Integer, desc: "The ID of a snippet" + optional :title, type: String, desc: "The title of a snippet" + optional :file_name, type: String, desc: "The name of a snippet file" + optional :content, type: String, desc: "The content of a snippet" + optional :description, type: String, desc: "The description of a snippet" optional :visibility, type: String, values: Gitlab::VisibilityLevel.string_values, - desc: 'The visibility of the snippet' + desc: "The visibility of the snippet" at_least_one_of :title, :file_name, :content, :visibility end # rubocop: disable CodeReuse/ActiveRecord - put ':id' do + put ":id" do snippet = snippets_for_current_user.find_by(id: params.delete(:id)) - break not_found!('Snippet') unless snippet + break not_found!("Snippet") unless snippet authorize! :update_personal_snippet, snippet @@ -115,17 +115,17 @@ module API end # rubocop: enable CodeReuse/ActiveRecord - desc 'Remove snippet' do - detail 'This feature was introduced in GitLab 8.15.' + desc "Remove snippet" do + detail "This feature was introduced in GitLab 8.15." success Entities::PersonalSnippet end params do - requires :id, type: Integer, desc: 'The ID of a snippet' + requires :id, type: Integer, desc: "The ID of a snippet" end # rubocop: disable CodeReuse/ActiveRecord - delete ':id' do + delete ":id" do snippet = snippets_for_current_user.find_by(id: params.delete(:id)) - break not_found!('Snippet') unless snippet + break not_found!("Snippet") unless snippet authorize! :destroy_personal_snippet, snippet @@ -133,29 +133,29 @@ module API end # rubocop: enable CodeReuse/ActiveRecord - desc 'Get a raw snippet' do - detail 'This feature was introduced in GitLab 8.15.' + desc "Get a raw snippet" do + detail "This feature was introduced in GitLab 8.15." end params do - requires :id, type: Integer, desc: 'The ID of a snippet' + requires :id, type: Integer, desc: "The ID of a snippet" end # rubocop: disable CodeReuse/ActiveRecord get ":id/raw" do snippet = snippets_for_current_user.find_by(id: params.delete(:id)) - break not_found!('Snippet') unless snippet + break not_found!("Snippet") unless snippet - env['api.format'] = :txt - content_type 'text/plain' - header['Content-Disposition'] = 'attachment' + env["api.format"] = :txt + content_type "text/plain" + header["Content-Disposition"] = "attachment" present snippet.content end # rubocop: enable CodeReuse/ActiveRecord - desc 'Get the user agent details for a snippet' do + desc "Get the user agent details for a snippet" do success Entities::UserAgentDetail end params do - requires :id, type: Integer, desc: 'The ID of a snippet' + requires :id, type: Integer, desc: "The ID of a snippet" end # rubocop: disable CodeReuse/ActiveRecord get ":id/user_agent_detail" do @@ -163,7 +163,7 @@ module API snippet = Snippet.find_by!(id: params[:id]) - break not_found!('UserAgentDetail') unless snippet.user_agent_detail + break not_found!("UserAgentDetail") unless snippet.user_agent_detail present snippet.user_agent_detail, with: Entities::UserAgentDetail end |