Module: Yus
- Defined in:
- lib/yus/privilege.rb,
lib/yus/entity.rb,
lib/yus/server.rb,
lib/yus/helpers.rb,
lib/yus/session.rb,
lib/yus/version.rb,
lib/yus/persistence/og.rb,
lib/yus/persistence/odba.rb
Overview
Defined Under Namespace
Modules: Persistence
Classes: AuthenticationError, AutoSession, CircularAffiliationError, DuplicateNameError, Entity, EntitySession, NotPrivilegedError, Privilege, RootSession, Server, Session, TokenSession, UnknownEntityError, YusError
Constant Summary
collapse
- VERSION =
'1.0.5'
Class Method Summary
collapse
Class Method Details
.default_opts ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/yus/helpers.rb', line 9
def self.default_opts
opts = []
GetoptLong.new(
['--help', '-h', GetoptLong::NO_ARGUMENT],
['--config', '-c', GetoptLong::OPTIONAL_ARGUMENT],
['--root_name', '-r', GetoptLong::OPTIONAL_ARGUMENT],
['--server_url', '-u', GetoptLong::OPTIONAL_ARGUMENT],
['--yus_dir', '-d', GetoptLong::OPTIONAL_ARGUMENT]
).each { |key, pair|
opts.push("#{key}=#{pair}")
}
opts
end
|
.get_password(prompt = 'Password: ') ⇒ Object
71
72
73
|
# File 'lib/yus/helpers.rb', line 71
def self.get_password(prompt='Password: ')
ask(prompt) { |q| q.echo = false}
end
|
.session(opts = self.default_opts) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/yus/helpers.rb', line 23
def self.session(opts = self.default_opts)
if /--help=/.match(opts[0])
puts <<-EOF
#{File.basename(__FILE__)} ...
-h, --help:
show help
-c -config
config directory of yus.yml
-r --root_name
Root name to use for reading yus
-s --config
path to YAML-config of Yus
EOF
exit
end
default_dir = File.join(ENV['HOME'], '.yus')
default_config_files = [
File.join(default_dir, 'yus.yml'),
'/etc/yus/yus.yml',
]
defaults = {
'config' => default_config_files,
'root_name' => 'admin',
'server_url' => 'drbssl://localhost:9997',
'yus_dir' => default_config_files,
}
opts.each{|opt|opt.sub!(/^--/, '') } config = RCLConf::RCLConf.new(opts, defaults)
config.load(config.config)
server = DRb::DRbObject.new(nil, config.server_url)
server.ping
session = nil
begin
pass = Yus.get_password("Password for #{config.root_name}: ")
session = server.login(config.root_name, pass.to_s, 'commandline')
rescue Yus::YusError => e
puts e.message
retry
end
return session
end
|