Sha256: b20b8d7d0b29ad2686b971ef0449ac52a8aad38f0e93ca5cdf523d9339fb6b6d

Contents?: true

Size: 560 Bytes

Versions: 27

Compression:

Stored size: 560 Bytes

Contents

module Gritano
  class Repository < ActiveRecord::Base
    validates :name, presence: true
    validates_uniqueness_of :name
    
    has_many :permissions
    has_many :users, through: :permissions
    
    before_create :create_bare_repo
    after_destroy :destroy_bare_repo
    
    def create_bare_repo
      Grit::Repo.init_bare(full_path)
    end
    
    def destroy_bare_repo
      FileUtils.rm_r(full_path, force: true)
    end
    
    def full_path
      if path
        File.join(path, name)
      else
        name
      end
    end
    
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
gritano-1.0.0 lib/gritano/models/repository.rb
gritano-0.11.2 lib/gritano/models/repository.rb
gritano-0.11.1 lib/gritano/models/repository.rb
gritano-0.11.0 lib/gritano/models/repository.rb
gritano-0.10.3 lib/gritano/models/repository.rb
gritano-0.10.2 lib/gritano/models/repository.rb
gritano-0.10.1 lib/gritano/models/repository.rb
gritano-0.10.0 lib/gritano/models/repository.rb
gritano-0.9.4 lib/gritano/models/repository.rb
gritano-0.9.3 lib/gritano/models/repository.rb
gritano-0.9.2 lib/gritano/models/repository.rb
gritano-0.9.1 lib/gritano/models/repository.rb
gritano-0.9.0 lib/gritano/models/repository.rb
gritano-0.8.1 lib/gritano/models/repository.rb
gritano-0.8.0 lib/gritano/models/repository.rb
gritano-0.7.2 lib/gritano/models/repository.rb
gritano-0.7.1 lib/gritano/models/repository.rb
gritano-0.7.0 lib/gritano/models/repository.rb
gritano-0.6.0 lib/gritano/models/repository.rb
gritano-0.5.4 lib/gritano/models/repository.rb