omf_common 6.0.3 → 6.0.4.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/bin/omf_monitor_topic +1 -2
- data/lib/omf_common.rb +20 -0
- data/lib/omf_common/auth/certificate_store.rb +1 -1
- data/lib/omf_common/comm/xmpp/communicator.rb +13 -13
- data/lib/omf_common/comm/xmpp/topic.rb +15 -6
- data/lib/omf_common/version.rb +1 -1
- metadata +8 -57
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YTRlZWFhMDI4MWE0NDQ2ZDIxM2U3ZWVlZWM0NmIzN2QzMTNjZGUwNA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OTBhNDQ5NWZiOGRmNWRhZWYwOTJjMGQwYWNmNDBlZjJjMjhkZTRlYg==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MDk2NDE0N2JjMmE0YzMwYTk3NzFiNTJiM2I2MWVhNjNlZTEwYmY2MjUwOGI4
|
10
|
+
ZDQ5NmFiZTU3NmE2NzNjZThiNDIyYTVmOWYxYjJiM2I2NzFjMTEzOGQzM2Mz
|
11
|
+
ZDg2YWM0Y2YyY2MxZDM1ZDUyYjU5YTZlMDk4NjE3NjExZWE0MjU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NTkwNWZiZmZlZWI2N2NjMWYzODhhMzE5YzBiYzdkZjk5ZDM2ZmNmZDM2NmUy
|
14
|
+
ZDQ0M2MzNDczYmZjZjM4NGQ1ZGNlNDY1M2U5NDkzN2Q2MWRhMWRmNjRiNGE2
|
15
|
+
ZmIzZGQyMTdiZWY2MTVkNjlmNTM3NGQyYjkwOGU1M2IxMTNhYWQ=
|
data/bin/omf_monitor_topic
CHANGED
data/lib/omf_common.rb
CHANGED
@@ -188,6 +188,10 @@ module OmfCommon
|
|
188
188
|
Eventloop.instance
|
189
189
|
end
|
190
190
|
|
191
|
+
class << self
|
192
|
+
alias_method :el, :eventloop
|
193
|
+
end
|
194
|
+
|
191
195
|
# Load a YAML file and return it as hash.
|
192
196
|
#
|
193
197
|
# options:
|
@@ -305,4 +309,20 @@ module OmfCommon
|
|
305
309
|
h
|
306
310
|
end
|
307
311
|
|
312
|
+
# Load a config file compatible with Logging gem
|
313
|
+
#
|
314
|
+
# @param [String] file_path of the logging config file
|
315
|
+
def self.load_logging_config(file_path)
|
316
|
+
unless file_path.nil?
|
317
|
+
l_cfg_mime_type = `file --mime-type -b #{file_path}`.strip rescue nil
|
318
|
+
case l_cfg_mime_type
|
319
|
+
when /ruby/
|
320
|
+
load file_path
|
321
|
+
when /plain/
|
322
|
+
Logging::Config::YamlConfigurator.load(file_path)
|
323
|
+
else
|
324
|
+
warn "Invalid config file format for logging, please use Ruby or Yaml."
|
325
|
+
end
|
326
|
+
end
|
327
|
+
end
|
308
328
|
end
|
@@ -121,8 +121,8 @@ class Comm
|
|
121
121
|
# Delete a pubsub topic
|
122
122
|
#
|
123
123
|
# @param [String] topic Pubsub topic name
|
124
|
-
def delete_topic(topic, &block)
|
125
|
-
pubsub.delete(topic,
|
124
|
+
def delete_topic(topic, pubsub_host = default_host, &block)
|
125
|
+
pubsub.delete(topic, pubsub_host, &callback_logging(__method__, topic, &block))
|
126
126
|
end
|
127
127
|
|
128
128
|
# Subscribe to a pubsub topic
|
@@ -136,33 +136,33 @@ class Comm
|
|
136
136
|
MPSubscription.inject(Time.now.to_f, jid, 'join', topic) if OmfCommon::Measure.enabled?
|
137
137
|
end
|
138
138
|
|
139
|
-
def _subscribe(topic, &block)
|
140
|
-
pubsub.subscribe(topic, nil,
|
139
|
+
def _subscribe(topic, pubsub_host = default_host, &block)
|
140
|
+
pubsub.subscribe(topic, nil, pubsub_host, &callback_logging(__method__, topic, &block))
|
141
141
|
end
|
142
142
|
|
143
|
-
def _create(topic, &block)
|
144
|
-
pubsub.create(topic,
|
143
|
+
def _create(topic, pubsub_host = default_host, &block)
|
144
|
+
pubsub.create(topic, pubsub_host, PUBSUB_CONFIGURE, &callback_logging(__method__, topic, &block))
|
145
145
|
end
|
146
146
|
|
147
147
|
# Un-subscribe all existing subscriptions from all pubsub topics.
|
148
|
-
def unsubscribe
|
149
|
-
pubsub.subscriptions(
|
148
|
+
def unsubscribe(pubsub_host = default_host)
|
149
|
+
pubsub.subscriptions(pubsub_host) do |m|
|
150
150
|
m[:subscribed] && m[:subscribed].each do |s|
|
151
|
-
pubsub.unsubscribe(s[:node], nil, s[:subid],
|
151
|
+
pubsub.unsubscribe(s[:node], nil, s[:subid], pubsub_host, &callback_logging(__method__, s[:node], s[:subid]))
|
152
152
|
MPSubscription.inject(Time.now.to_f, jid, 'leave', s[:node]) if OmfCommon::Measure.enabled?
|
153
153
|
end
|
154
154
|
end
|
155
155
|
end
|
156
156
|
|
157
|
-
def affiliations(&block)
|
158
|
-
pubsub.affiliations(
|
157
|
+
def affiliations(pubsub_host = default_host, &block)
|
158
|
+
pubsub.affiliations(pubsub_host, &callback_logging(__method__, &block))
|
159
159
|
end
|
160
160
|
|
161
161
|
# Publish to a pubsub topic
|
162
162
|
#
|
163
163
|
# @param [String] topic Pubsub topic name
|
164
164
|
# @param [OmfCommon::Message] message Any XML fragment to be sent as payload
|
165
|
-
def publish(topic, message, &block)
|
165
|
+
def publish(topic, message, pubsub_host = default_host, &block)
|
166
166
|
raise StandardError, "Invalid message" unless message.valid?
|
167
167
|
|
168
168
|
message = message.marshall[1] unless message.kind_of? String
|
@@ -176,7 +176,7 @@ class Comm
|
|
176
176
|
block.call(stanza) if block
|
177
177
|
end
|
178
178
|
|
179
|
-
pubsub.publish(topic, message,
|
179
|
+
pubsub.publish(topic, message, pubsub_host, &callback_logging(__method__, topic, &new_block))
|
180
180
|
MPPublished.inject(Time.now.to_f, jid, topic, message.to_s.gsub("\n",'')) if OmfCommon::Measure.enabled?
|
181
181
|
end
|
182
182
|
|
@@ -14,7 +14,8 @@ class XMPP
|
|
14
14
|
# end
|
15
15
|
|
16
16
|
def address
|
17
|
-
"xmpp://#{id.to_s}@#{OmfCommon.comm.jid.domain}"
|
17
|
+
#"xmpp://#{id.to_s}@#{OmfCommon.comm.jid.domain}"
|
18
|
+
"xmpp://#{id.to_s}@#{@pubsub_domain}"
|
18
19
|
end
|
19
20
|
|
20
21
|
def on_subscribed(&block)
|
@@ -27,8 +28,16 @@ class XMPP
|
|
27
28
|
|
28
29
|
private
|
29
30
|
|
31
|
+
def pubsub_domain_addr
|
32
|
+
"pubsub.#{@pubsub_domain}"
|
33
|
+
end
|
34
|
+
|
30
35
|
def initialize(id, opts = {}, &block)
|
31
|
-
id =
|
36
|
+
id, @pubsub_domain = id.to_s.split("@")
|
37
|
+
if id =~ /^xmpp:\/\/(.+)$/
|
38
|
+
id = $1
|
39
|
+
end
|
40
|
+
@pubsub_domain ||= OmfCommon.comm.jid.domain
|
32
41
|
|
33
42
|
super
|
34
43
|
|
@@ -50,17 +59,17 @@ class XMPP
|
|
50
59
|
|
51
60
|
# Create xmpp pubsub topic, then subscribe to it
|
52
61
|
#
|
53
|
-
OmfCommon.comm._create(id.to_s) do |stanza|
|
62
|
+
OmfCommon.comm._create(id.to_s, pubsub_domain_addr) do |stanza|
|
54
63
|
if stanza.error?
|
55
64
|
e_stanza = Blather::StanzaError.import(stanza)
|
56
65
|
if e_stanza.name == :conflict
|
57
66
|
# Topic exists, just subscribe to it.
|
58
|
-
OmfCommon.comm._subscribe(id.to_s, &topic_block)
|
67
|
+
OmfCommon.comm._subscribe(id.to_s, pubsub_domain_addr, &topic_block)
|
59
68
|
else
|
60
69
|
block.call(stanza) if block
|
61
70
|
end
|
62
71
|
else
|
63
|
-
OmfCommon.comm._subscribe(id.to_s, &topic_block)
|
72
|
+
OmfCommon.comm._subscribe(id.to_s, pubsub_domain_addr, &topic_block)
|
64
73
|
end
|
65
74
|
end
|
66
75
|
|
@@ -75,7 +84,7 @@ class XMPP
|
|
75
84
|
|
76
85
|
def _send_message(msg, block)
|
77
86
|
super
|
78
|
-
OmfCommon.comm.publish(self.id, msg)
|
87
|
+
OmfCommon.comm.publish(self.id, msg, pubsub_domain_addr)
|
79
88
|
end
|
80
89
|
|
81
90
|
def valid_guard?(guard_proc)
|
data/lib/omf_common/version.rb
CHANGED
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omf_common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.
|
5
|
-
prerelease:
|
4
|
+
version: 6.0.4.pre.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- NICTA
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-08-29 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: minitest
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: em-minitest-spec
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: simplecov
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ! '>='
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ! '>='
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -62,7 +55,6 @@ dependencies:
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: pry
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ! '>='
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,7 +62,6 @@ dependencies:
|
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ! '>='
|
76
67
|
- !ruby/object:Gem::Version
|
@@ -78,7 +69,6 @@ dependencies:
|
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: mocha
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
73
|
- - ! '>='
|
84
74
|
- !ruby/object:Gem::Version
|
@@ -86,7 +76,6 @@ dependencies:
|
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
80
|
- - ! '>='
|
92
81
|
- !ruby/object:Gem::Version
|
@@ -94,7 +83,6 @@ dependencies:
|
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: eventmachine
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
87
|
- - '='
|
100
88
|
- !ruby/object:Gem::Version
|
@@ -102,7 +90,6 @@ dependencies:
|
|
102
90
|
type: :runtime
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
94
|
- - '='
|
108
95
|
- !ruby/object:Gem::Version
|
@@ -110,7 +97,6 @@ dependencies:
|
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: blather
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
101
|
- - '='
|
116
102
|
- !ruby/object:Gem::Version
|
@@ -118,7 +104,6 @@ dependencies:
|
|
118
104
|
type: :runtime
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
108
|
- - '='
|
124
109
|
- !ruby/object:Gem::Version
|
@@ -126,7 +111,6 @@ dependencies:
|
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
112
|
name: logging
|
128
113
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
114
|
requirements:
|
131
115
|
- - ~>
|
132
116
|
- !ruby/object:Gem::Version
|
@@ -134,7 +118,6 @@ dependencies:
|
|
134
118
|
type: :runtime
|
135
119
|
prerelease: false
|
136
120
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
121
|
requirements:
|
139
122
|
- - ~>
|
140
123
|
- !ruby/object:Gem::Version
|
@@ -142,7 +125,6 @@ dependencies:
|
|
142
125
|
- !ruby/object:Gem::Dependency
|
143
126
|
name: hashie
|
144
127
|
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
128
|
requirements:
|
147
129
|
- - ~>
|
148
130
|
- !ruby/object:Gem::Version
|
@@ -150,7 +132,6 @@ dependencies:
|
|
150
132
|
type: :runtime
|
151
133
|
prerelease: false
|
152
134
|
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
135
|
requirements:
|
155
136
|
- - ~>
|
156
137
|
- !ruby/object:Gem::Version
|
@@ -158,7 +139,6 @@ dependencies:
|
|
158
139
|
- !ruby/object:Gem::Dependency
|
159
140
|
name: oml4r
|
160
141
|
requirement: !ruby/object:Gem::Requirement
|
161
|
-
none: false
|
162
142
|
requirements:
|
163
143
|
- - ~>
|
164
144
|
- !ruby/object:Gem::Version
|
@@ -166,7 +146,6 @@ dependencies:
|
|
166
146
|
type: :runtime
|
167
147
|
prerelease: false
|
168
148
|
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
none: false
|
170
149
|
requirements:
|
171
150
|
- - ~>
|
172
151
|
- !ruby/object:Gem::Version
|
@@ -174,7 +153,6 @@ dependencies:
|
|
174
153
|
- !ruby/object:Gem::Dependency
|
175
154
|
name: json
|
176
155
|
requirement: !ruby/object:Gem::Requirement
|
177
|
-
none: false
|
178
156
|
requirements:
|
179
157
|
- - ~>
|
180
158
|
- !ruby/object:Gem::Version
|
@@ -182,7 +160,6 @@ dependencies:
|
|
182
160
|
type: :runtime
|
183
161
|
prerelease: false
|
184
162
|
version_requirements: !ruby/object:Gem::Requirement
|
185
|
-
none: false
|
186
163
|
requirements:
|
187
164
|
- - ~>
|
188
165
|
- !ruby/object:Gem::Version
|
@@ -274,51 +251,25 @@ files:
|
|
274
251
|
homepage: http://omf.mytestbed.net
|
275
252
|
licenses:
|
276
253
|
- MIT
|
254
|
+
metadata: {}
|
277
255
|
post_install_message:
|
278
256
|
rdoc_options: []
|
279
257
|
require_paths:
|
280
258
|
- lib
|
281
259
|
required_ruby_version: !ruby/object:Gem::Requirement
|
282
|
-
none: false
|
283
260
|
requirements:
|
284
261
|
- - ! '>='
|
285
262
|
- !ruby/object:Gem::Version
|
286
263
|
version: 1.9.3
|
287
264
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
288
|
-
none: false
|
289
265
|
requirements:
|
290
|
-
- - ! '
|
266
|
+
- - ! '>'
|
291
267
|
- !ruby/object:Gem::Version
|
292
|
-
version:
|
293
|
-
segments:
|
294
|
-
- 0
|
295
|
-
hash: 2941832345659960024
|
268
|
+
version: 1.3.1
|
296
269
|
requirements: []
|
297
270
|
rubyforge_project: omf_common
|
298
|
-
rubygems_version:
|
271
|
+
rubygems_version: 2.0.7
|
299
272
|
signing_key:
|
300
|
-
specification_version:
|
273
|
+
specification_version: 4
|
301
274
|
summary: Common library of OMF
|
302
|
-
test_files:
|
303
|
-
- test/fixture/1st_level.pem
|
304
|
-
- test/fixture/2nd_level.pem
|
305
|
-
- test/fixture/3rd_level.pem
|
306
|
-
- test/fixture/omf_test.cert.pem
|
307
|
-
- test/fixture/omf_test.pem
|
308
|
-
- test/fixture/omf_test.pub
|
309
|
-
- test/fixture/omf_test.pub.pem
|
310
|
-
- test/fixture/pubsub.rb
|
311
|
-
- test/fixture/rc.pem
|
312
|
-
- test/fixture/root.pem
|
313
|
-
- test/omf_common/auth/certificate_spec.rb
|
314
|
-
- test/omf_common/auth/certificate_store_spec.rb
|
315
|
-
- test/omf_common/auth/ssh_pub_key_convert_spec.rb
|
316
|
-
- test/omf_common/comm/topic_spec.rb
|
317
|
-
- test/omf_common/comm/xmpp/communicator_spec.rb
|
318
|
-
- test/omf_common/comm/xmpp/topic_spec.rb
|
319
|
-
- test/omf_common/comm_spec.rb
|
320
|
-
- test/omf_common/command_spec.rb
|
321
|
-
- test/omf_common/core_ext/string_spec.rb
|
322
|
-
- test/omf_common/message/xml/message_spec.rb
|
323
|
-
- test/omf_common/message_spec.rb
|
324
|
-
- test/test_helper.rb
|
275
|
+
test_files: []
|