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 CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('c3s', '0.2.6') do |p|
5
+ Echoe.new('c3s', '0.2.7') do |p|
6
6
  p.description = "C3s library gem."
7
7
  p.url = "http://github.com/rikas/c3s"
8
8
  p.author = "Ricardo Otero"
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.6"
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-11}
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
@@ -19,7 +19,7 @@ require 'databaseadapter'
19
19
  require 'c3s_logger'
20
20
 
21
21
  module C3s
22
- VERSION = "0.2.6"
22
+ VERSION = "0.2.7"
23
23
 
24
24
  def self.included(base)
25
25
  base.extend ClassMethods
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']}/#{iq.from.bare.to_s}")
104
- pub.publish(iq.from.bare.to_s, data)
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.6
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-11 00:00:00 +00:00
12
+ date: 2009-12-16 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies: []
15
15