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/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: AuthSetupMiddleware, BasicSaveable, Client, Command, Group, Message, Repo, User, WebApp
Constant Summary
collapse
- VERSION =
[0, 0, 4, 5]
- BASE_DIR =
Pathname.new(__FILE__).dirname.join("..").expand_path
- LIB_DIR =
BASE_DIR.join("lib", "gitauth")
- GITAUTH_DIR =
Pathname.new("~/.gitauth/").expand_path
- Users =
User
Class Method Summary
collapse
Class Method Details
.each_model(method = nil, &blk) ⇒ Object
87
88
89
90
|
# File 'lib/gitauth.rb', line 87
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
77
78
79
80
81
|
# File 'lib/gitauth.rb', line 77
def get_user_or_group(name)
name = name.to_s.strip
return if name.empty?
(name =~ /^@/ ? Group : User).get(name)
end
|
.has_git? ⇒ Boolean
83
84
85
|
# File 'lib/gitauth.rb', line 83
def has_git?
!`which git`.blank?
end
|
.msg(type, message) ⇒ Object
73
74
75
|
# File 'lib/gitauth.rb', line 73
def msg(type, message)
Message.new(type, message)
end
|
.prepare ⇒ Object
64
65
66
67
|
# File 'lib/gitauth.rb', line 64
def prepare
GitAuth::Settings.setup!
reload_models!
end
|
.reload_models! ⇒ Object
92
93
94
|
# File 'lib/gitauth.rb', line 92
def reload_models!
each_model(:load!)
end
|
.require_vendored(lib) ⇒ Object
This is the first declaration because we need it so that we can load a vendored version of perennial if present.
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/gitauth.rb', line 31
def self.require_vendored(lib)
vendored_path = BASE_DIR.join("vendor", lib, "lib", "#{lib}.rb")
if File.exist?(vendored_path)
$:.unshift File.dirname(vendored_path)
require lib
else
require 'rubygems' unless defined?(Gem)
require lib
end
end
|
.run(command) ⇒ Object
96
97
98
99
100
101
|
# File 'lib/gitauth.rb', line 96
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
46
47
48
49
50
51
|
# File 'lib/gitauth/saveable_class.rb', line 46
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
|
.version ⇒ Object
69
70
71
|
# File 'lib/gitauth.rb', line 69
def version
VERSION.join(".")
end
|