c3s 0.2.6 → 0.2.7
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/Rakefile +1 -1
- data/c3s.gemspec +2 -2
- data/lib/c3s.rb +1 -1
- data/lib/component.rb +4 -3
- data/lib/publisher.rb +17 -2
- metadata +2 -2
data/Rakefile
CHANGED
data/c3s.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{c3s}
|
5
|
-
s.version = "0.2.
|
5
|
+
s.version = "0.2.7"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Ricardo Otero"]
|
9
|
-
s.date = %q{2009-12-
|
9
|
+
s.date = %q{2009-12-16}
|
10
10
|
s.description = %q{C3s library gem.}
|
11
11
|
s.email = %q{oterosantos@gmail.com}
|
12
12
|
s.extra_rdoc_files = ["README.rdoc", "lib/c3s.rb", "lib/c3s_logger.rb", "lib/component.rb", "lib/component_connection.rb", "lib/configreader.rb", "lib/databaseadapter.rb", "lib/model.rb", "lib/nodetracker.rb", "lib/publisher.rb"]
|
data/lib/c3s.rb
CHANGED
data/lib/component.rb
CHANGED
@@ -98,13 +98,14 @@ module C3s
|
|
98
98
|
# data:: what to publish
|
99
99
|
# changed:: the data is different from last set operation?
|
100
100
|
def publish(iq, data, changed)
|
101
|
+
jid = (iq.is_a?(Jabber::Iq)) ? iq.from.bare.to_s : iq
|
101
102
|
if changed
|
102
103
|
pub = Publisher.new(self, "pubsub."+config['url'])
|
103
|
-
pub.create_nodes("/#{config['name']}/#{
|
104
|
-
pub.publish(
|
104
|
+
pub.create_nodes("/#{config['name']}/#{jid}")
|
105
|
+
pub.publish(jid, data)
|
105
106
|
end
|
106
107
|
|
107
|
-
send_ok iq
|
108
|
+
send_ok(iq) if iq.is_a?(Jabber::Iq)
|
108
109
|
end
|
109
110
|
|
110
111
|
##
|
data/lib/publisher.rb
CHANGED
@@ -38,7 +38,8 @@ module C3s
|
|
38
38
|
# name:: [String] collection node name
|
39
39
|
def create_collection_node(name)
|
40
40
|
config = Jabber::PubSub::NodeConfig.new
|
41
|
-
@pubsub.create_collection_node(name, config)
|
41
|
+
node = @pubsub.create_collection_node(name, config)
|
42
|
+
grant_owner_to_admin(node)
|
42
43
|
end
|
43
44
|
|
44
45
|
##
|
@@ -49,7 +50,13 @@ module C3s
|
|
49
50
|
def create_leaf_node(name, collection)
|
50
51
|
config = Jabber::PubSub::NodeConfig.new
|
51
52
|
config.options = config.options.merge({'pubsub#collection' => collection})
|
52
|
-
@pubsub.create_node(name, config)
|
53
|
+
node = @pubsub.create_node(name, config)
|
54
|
+
grant_owner_to_admin(node)
|
55
|
+
end
|
56
|
+
|
57
|
+
def grant_owner_to_admin(node)
|
58
|
+
return unless node
|
59
|
+
@pubsub.set_affiliations(node, "admin@#{@client.config['url']}", 'owner')
|
53
60
|
end
|
54
61
|
|
55
62
|
##
|
@@ -63,6 +70,14 @@ module C3s
|
|
63
70
|
@pubsub.publish_item_to(node, item)
|
64
71
|
end
|
65
72
|
|
73
|
+
def fix_permissions
|
74
|
+
nodebrowser = Jabber::PubSub::NodeBrowser.new(@client)
|
75
|
+
nodes = nodebrowser.nodes_names(@service)
|
76
|
+
nodes.each do |node|
|
77
|
+
grant_owner_to_admin(node['node'])
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
66
81
|
##
|
67
82
|
# Checks for existance of a node with a given name. This
|
68
83
|
# node can be a leaf or a collection
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: c3s
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo Otero
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-16 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|