rollcall-prosody 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/MIT-LICENSE +20 -0
- data/README +13 -0
- data/Rakefile +23 -0
- data/init.rb +1 -0
- data/install.rb +1 -0
- data/lib/account_callbacks.rb +22 -0
- data/lib/prosody_cli.rb +50 -0
- data/lib/rollcall-prosody.rb +22 -0
- data/rollcall-prosody.gemspec +13 -0
- data/uninstall.rb +1 -0
- metadata +72 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 University of Toronto
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
desc 'Default: run unit tests.'
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
desc 'Test the rollcall prosody plugin.'
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << 'lib'
|
11
|
+
t.libs << 'test'
|
12
|
+
t.pattern = 'test/**/*_test.rb'
|
13
|
+
t.verbose = true
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Generate documentation for the rollcall prosody plugin.'
|
17
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
18
|
+
rdoc.rdoc_dir = 'rdoc'
|
19
|
+
rdoc.title = 'Rollcall-Prosody'
|
20
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
21
|
+
rdoc.rdoc_files.include('README')
|
22
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
+
end
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Include hook code here
|
data/install.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Install hook code here
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'account'
|
3
|
+
|
4
|
+
Account.class_eval do
|
5
|
+
unless Rails.env == 'test'
|
6
|
+
require 'prosody_cli'
|
7
|
+
include RollcallProsody::ProsodyCli
|
8
|
+
Rails.logger.debug "Loaded Prosody CLI connector for domain #{RollcallProsody::DOMAIN}."
|
9
|
+
|
10
|
+
before_create :create_account_in_prosody, :if => proc{ !login.blank? && !password.blank? }
|
11
|
+
before_update :update_account_in_prosody, :if => proc{ !login.blank? && !password.blank? && password_changed? }
|
12
|
+
before_destroy :delete_account_in_prosody
|
13
|
+
|
14
|
+
validate do
|
15
|
+
# if !@prosody_error && !prosody_account_exists?
|
16
|
+
# @prosody_error = "#{login}@#{Rollcallprosody::DOMAIN} cannot be updated because it does not exist on the ejabbberd server!"
|
17
|
+
# end
|
18
|
+
|
19
|
+
self.errors[:base] << @prosody_error if @prosody_error
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/prosody_cli.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
module RollcallProsody::ProsodyCli
|
2
|
+
def create_account_in_prosody
|
3
|
+
unless @prosody_account_created
|
4
|
+
command = %{register "#{self.login}" "#{RollcallProsody::DOMAIN}" "#{self.encrypted_password}"}
|
5
|
+
prosody_cli_request(command)
|
6
|
+
@prosody_account_created = true unless @prosody_error
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def update_account_in_prosody
|
11
|
+
unless @prosody_account_created
|
12
|
+
delete_account_in_prosody
|
13
|
+
unless @prosody_error
|
14
|
+
create_account_in_prosody
|
15
|
+
@prosody_account_updated = true unless @prosody_error
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def delete_account_in_prosody
|
21
|
+
command = %{deluser "#{self.login}@#{RollcallProsody::DOMAIN}"}
|
22
|
+
prosody_cli_request(command)
|
23
|
+
end
|
24
|
+
|
25
|
+
def list_accounts_in_prosody
|
26
|
+
raise NotImplementedError
|
27
|
+
# command = %{registered-users "#{RollcallProsody::DOMAIN}"}
|
28
|
+
# prosody_cli_request(command)
|
29
|
+
end
|
30
|
+
|
31
|
+
def prosody_account_exists?
|
32
|
+
list_accounts_in_prosody.split("\n").include?(login)
|
33
|
+
end
|
34
|
+
|
35
|
+
def prosody_cli_request(command)
|
36
|
+
ctl = RollcallProsody::CTL
|
37
|
+
|
38
|
+
out = `#{ctl} #{command} 2>&1`
|
39
|
+
res = $?.to_i
|
40
|
+
|
41
|
+
|
42
|
+
Rails.logger.debug "RollcallProsody::ProsodyCli.prosody_cli_request: #{out}"
|
43
|
+
|
44
|
+
if res > 0
|
45
|
+
@prosody_error = "Prosody command \n\n\t`#{command}`\n\nwas unssuccessful because:\n\n\t#{out}"
|
46
|
+
end
|
47
|
+
|
48
|
+
return out
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module RollcallProsody
|
2
|
+
class Railtie < Rails::Railtie
|
3
|
+
config.prosody = ActiveSupport::OrderedOptions.new
|
4
|
+
|
5
|
+
initializer 'prosody.initialize' do |app|
|
6
|
+
if config.prosody.ctl_path
|
7
|
+
RollcallProsody::CTL = config.prosody.ctl_path
|
8
|
+
else
|
9
|
+
RollcallProsody::CTL = 'prosodyctl'
|
10
|
+
end
|
11
|
+
|
12
|
+
if config.prosody.domain
|
13
|
+
RollcallProsody::DOMAIN = config.prosody.domain
|
14
|
+
else
|
15
|
+
RollcallProsody::DOMAIN = 'localhost'
|
16
|
+
end
|
17
|
+
|
18
|
+
require 'account_callbacks'
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = %q{rollcall-prosody}
|
3
|
+
s.version = "0.0.1"
|
4
|
+
s.authors = ["Matt Zukowski"]
|
5
|
+
s.date = %q{2012-01-20}
|
6
|
+
s.summary = %q{Rollcall plugin for integration with the Prosody XMPP server}
|
7
|
+
s.email = %q{matt dot zukowski at utoronto dot ca}
|
8
|
+
s.files = `git ls-files`.split("\n")
|
9
|
+
s.homepage = %q{http://github.com/educoder/rollcall-prosody}
|
10
|
+
s.rdoc_options = ["--main", "README"]
|
11
|
+
s.require_paths = ["lib"]
|
12
|
+
s.rubyforge_project = %q{rollcall-prosody}
|
13
|
+
end
|
data/uninstall.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Uninstall hook code here
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rollcall-prosody
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Matt Zukowski
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2012-01-20 00:00:00 -05:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description:
|
22
|
+
email: matt dot zukowski at utoronto dot ca
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files: []
|
28
|
+
|
29
|
+
files:
|
30
|
+
- MIT-LICENSE
|
31
|
+
- README
|
32
|
+
- Rakefile
|
33
|
+
- init.rb
|
34
|
+
- install.rb
|
35
|
+
- lib/account_callbacks.rb
|
36
|
+
- lib/prosody_cli.rb
|
37
|
+
- lib/rollcall-prosody.rb
|
38
|
+
- rollcall-prosody.gemspec
|
39
|
+
- uninstall.rb
|
40
|
+
has_rdoc: true
|
41
|
+
homepage: http://github.com/educoder/rollcall-prosody
|
42
|
+
licenses: []
|
43
|
+
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options:
|
46
|
+
- --main
|
47
|
+
- README
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
version: "0"
|
64
|
+
requirements: []
|
65
|
+
|
66
|
+
rubyforge_project: rollcall-prosody
|
67
|
+
rubygems_version: 1.3.6
|
68
|
+
signing_key:
|
69
|
+
specification_version: 3
|
70
|
+
summary: Rollcall plugin for integration with the Prosody XMPP server
|
71
|
+
test_files: []
|
72
|
+
|