Module: GitAuth

Includes:
Loggable, Perennial
Defined in:
lib/gitauth/client.rb,
lib/gitauth.rb,
lib/gitauth/repo.rb,
lib/gitauth/user.rb,
lib/gitauth/group.rb,
lib/gitauth/command.rb,
lib/gitauth/message.rb,
lib/gitauth/web_app.rb,
lib/gitauth/saveable_class.rb,
lib/gitauth/apache_authentication.rb,
lib/gitauth/auth_setup_middleware.rb

Overview

Copyright (C) 2009 Brown Beagle Software
Copyright (C) 2009 Darcy Laycock <[email protected]>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

++

Defined Under Namespace

Classes: ApacheAuthentication, AuthSetupMiddleware, BasicSaveable, Client, Command, Group, Message, Repo, User, WebApp

Constant Summary collapse

VERSION =
[0, 1, 0]
BASE_DIR =
Pathname(__FILE__).dirname.join("..").expand_path
GITAUTH_DIR =
Pathname("~/.gitauth/").expand_path
Users =

For Backwards Compat.

User

Class Method Summary collapse

Class Method Details

.each_model(method = nil, &blk) ⇒ Object



86
87
88
89
# File 'lib/gitauth.rb', line 86

def each_model(method = nil, &blk)
  [Repo, User, Group].each { |m| m.send(method) } if method.present?
  [Repo, User, Group].each(&blk) unless blk.nil?
end

.get_user_or_group(name) ⇒ Object



76
77
78
79
80
# File 'lib/gitauth.rb', line 76

def get_user_or_group(name)
  name = name.to_s.strip
  return if name.empty?
  (name =~ /^@/ ? Group : User).get(name)
end

.has_git?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/gitauth.rb', line 82

def has_git?
  !`which git`.blank?
end

.msg(type, message) ⇒ Object



72
73
74
# File 'lib/gitauth.rb', line 72

def msg(type, message)
  Message.new(type, message)
end

.prepareObject



63
64
65
66
# File 'lib/gitauth.rb', line 63

def prepare
  GitAuth::Settings.setup!
  reload_models!
end

.reload_models!Object



91
92
93
# File 'lib/gitauth.rb', line 91

def reload_models!
  each_model(:load!)
end

.run(command) ⇒ Object



95
96
97
98
99
100
# File 'lib/gitauth.rb', line 95

def run(command)
  GitAuth::Logger.info "Running command: #{command}"
  result = system "#{command} 2> /dev/null 1> /dev/null"
  GitAuth::Logger.info "Command was #{"not " if !result}successful"
  return result
end

.SaveableClass(kind) ⇒ Object



47
48
49
50
51
52
# File 'lib/gitauth/saveable_class.rb', line 47

def self.SaveableClass(kind)
  klass            = Class.new(BasicSaveable)
  klass.store_path = GitAuth::GITAUTH_DIR.join("#{kind}.yml").to_s
  klass.all        = nil
  return klass
end

.versionObject



68
69
70
# File 'lib/gitauth.rb', line 68

def version
  VERSION.join(".")
end