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.



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

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



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

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



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

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

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



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

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