Class: Storage::Hashed

Inherits:
Object
  • Object
show all
Defined in:
app/models/storage/hashed.rb

Constant Summary collapse

REPOSITORY_PATH_PREFIX =
'@hashed'
GROUP_REPOSITORY_PATH_PREFIX =
'@groups'
SNIPPET_REPOSITORY_PATH_PREFIX =
'@snippets'
POOL_PATH_PREFIX =
'@pools'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(container, prefix: REPOSITORY_PATH_PREFIX) ⇒ Hashed

Returns a new instance of Hashed.


13
14
15
16
# File 'app/models/storage/hashed.rb', line 13

def initialize(container, prefix: REPOSITORY_PATH_PREFIX)
  @container = container
  @prefix = prefix
end

Instance Attribute Details

#containerObject

Returns the value of attribute container


5
6
7
# File 'app/models/storage/hashed.rb', line 5

def container
  @container
end

Instance Method Details

#base_dirString

Base directory

Returns:

  • (String)

    directory where repository is stored


21
22
23
# File 'app/models/storage/hashed.rb', line 21

def base_dir
  "#{@prefix}/#{disk_hash[0..1]}/#{disk_hash[2..3]}" if disk_hash
end

#disk_pathString

Disk path is used to build repository path on disk

without `.git`, `.wiki.git`, or any other extension

Returns:

  • (String)

    combination of base_dir and the repository own name


29
30
31
# File 'app/models/storage/hashed.rb', line 29

def disk_path
  "#{base_dir}/#{disk_hash}" if disk_hash
end

#rename_repo(old_full_path: nil, new_full_path: nil) ⇒ Object


33
34
35
# File 'app/models/storage/hashed.rb', line 33

def rename_repo(old_full_path: nil, new_full_path: nil)
  true
end