Class: LabClient::Files

Inherits:
Common
  • Object
show all
Defined in:
lib/labclient/files/show.rb,
lib/labclient/files/create.rb,
lib/labclient/files/delete.rb,
lib/labclient/files/update.rb

Overview

Specifics

Constant Summary

Constants included from AccessLevel

AccessLevel::HUMAN_ACCESS_LEVELS, AccessLevel::MACHINE_ACCESS_LEVELS

Instance Attribute Summary

Attributes inherited from Common

#client

Instance Method Summary collapse

Methods inherited from Common

#api_methods, #api_methods_help, #format_id, #format_query_id, #format_query_ids, #format_time?, #group_name, #help, #initialize, #inspect, #klass, #protected_query_access_level, #query_access_level, #query_format_time

Methods included from Docs

#demo, #desc, #doc, docs, #example, #group_name, #help, json, #markdown, #navigation, #option, #result, #subtitle, #title

Methods included from AccessLevel

#human_access_level, #human_protected_access_level, #machine_access_level, #machine_protected_access_level

Constructor Details

This class inherits a constructor from LabClient::Common

Instance Method Details

#create(project_id, file_path, query) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/labclient/files/create.rb', line 46

def create(project_id, file_path, query)
  project_id = format_id(project_id)

  # Path Name Encoding
  file_path = ERB::Util.url_encode(file_path)

  client.request(:post, "projects/#{project_id}/repository/files/#{file_path}", nil, query)
end

#delete(project_id, file_path, query) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/labclient/files/delete.rb', line 37

def delete(project_id, file_path, query)
  project_id = format_id(project_id)

  # Path Name Encoding
  file_path = ERB::Util.url_encode(file_path)

  client.request(:delete, "projects/#{project_id}/repository/files/#{file_path}", nil, query)
end

#show(project_id, file_path, ref = :main, kind = nil) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/labclient/files/show.rb', line 34

def show(project_id, file_path, ref = :main, kind = nil)
  # LabStruct vs LabFile
  return_kind = kind == :raw ? LabFile : nil

  kind = case kind
         when :raw
           '/raw'
         when :blame
           '/blame'
         end

  project_id = format_id(project_id)

  # Path Name Encoding
  file_path = ERB::Util.url_encode(file_path)

  client.request(:get, "projects/#{project_id}/repository/files/#{file_path}#{kind}", return_kind, ref: ref)
end

#update(project_id, file_path, query) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/labclient/files/update.rb', line 43

def update(project_id, file_path, query)
  project_id = format_id(project_id)

  # Path Name Encoding
  file_path = ERB::Util.url_encode(file_path)

  client.request(:put, "projects/#{project_id}/repository/files/#{file_path}", nil, query)
end