# Class Namespace < ActiveRecord::Base

- app/models/namespace.rb

## Schema Information

Table name: namespaces

    id         :integer          not null, primary key
    name       :string(255)      not null
    path       :string(255)      not null
    owner_id   :integer          not null
    created_at :datetime         not null
    updated_at :datetime         not null
    type       :string(255)

Methods

D
  - dir_exists?
E
  - ensure_dir_exist
G
  - global_id
H
  - human_name
M
  - move_dir
N
  - namespace_full_path
R
  - rm_dir
S
  - search,
  - send_update_instructions
T
  - to_param
U
  - update_gitolite

Class Public methods
global_id() Link

Source: show

    # File app/models/namespace.rb, line 41
    def self.global_id
      'GLN'
    end

search(query) Link

Source: show

    # File app/models/namespace.rb, line 37
    def self.search query
      where("name LIKE :query OR path LIKE :query", query: "%#{query}%")
    end

Instance Public methods
dir_exists?() Link

Source: show

    # File app/models/namespace.rb, line 59
    def dir_exists?
      File.exists?(namespace_full_path)
    end

ensure_dir_exist() Link

Source: show

    # File app/models/namespace.rb, line 53
    def ensure_dir_exist
      unless dir_exists?
        system("mkdir -m 770 #{namespace_full_path}")
      end
    end

human_name() Link

Source: show

    # File app/models/namespace.rb, line 49
    def human_name
      owner_name
    end

move_dir() Link

Source: show

    # File app/models/namespace.rb, line 67
    def move_dir
      if path_changed?
        old_path = File.join(Gitlab.config.gitolite.repos_path, path_was)
        new_path = File.join(Gitlab.config.gitolite.repos_path, path)
        if File.exists?(new_path)
          raise "Already exists"
        end

        if system("mv #{old_path} #{new_path}")
          send_update_instructions
          @require_update_gitolite = true
        else
          raise "Namespace move error #{old_path} #{new_path}"
        end
      end
    end

namespace_full_path() Link

Source: show

    # File app/models/namespace.rb, line 63
    def namespace_full_path
      @namespace_full_path ||= File.join(Gitlab.config.gitolite.repos_path, path)
    end

rm_dir() Link

Source: show

    # File app/models/namespace.rb, line 89
    def rm_dir
      dir_path = File.join(Gitlab.config.gitolite.repos_path, path)
      system("rm -rf #{dir_path}")
    end

send_update_instructions() Link

Source: show

    # File app/models/namespace.rb, line 94
    def send_update_instructions
      projects.each(&:send_move_instructions)
    end

to_param() Link

Source: show

    # File app/models/namespace.rb, line 45
    def to_param
      path
    end

update_gitolite() Link

Source: show

    # File app/models/namespace.rb, line 84
    def update_gitolite
      @require_update_gitolite = false
      projects.each(&:update_repository)
    end