osub 0.0.7 → 0.0.9
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/lib/osub/subscription.rb +36 -17
- data/lib/osub/version.rb +1 -1
- data/lib/osub.rb +2 -1
- metadata +47 -59
data/lib/osub/subscription.rb
CHANGED
@@ -9,11 +9,8 @@ module OSub
|
|
9
9
|
attr_reader :callback_url
|
10
10
|
attr_reader :topic_url
|
11
11
|
|
12
|
-
def initialize(callback_url, topic_url, secret = nil
|
12
|
+
def initialize(callback_url, topic_url, secret = nil)
|
13
13
|
@tokens = []
|
14
|
-
if token != nil
|
15
|
-
@tokens << token
|
16
|
-
end
|
17
14
|
|
18
15
|
secret = "" if secret == nil
|
19
16
|
@secret = secret.to_s
|
@@ -28,30 +25,52 @@ module OSub
|
|
28
25
|
end
|
29
26
|
|
30
27
|
# Subscribe to the topic through the given hub.
|
31
|
-
def subscribe(hub_url,
|
28
|
+
def subscribe(hub_url, token = nil)
|
32
29
|
if token != nil
|
33
30
|
@tokens << token.to_s
|
34
31
|
end
|
35
|
-
change_subscription(:subscribe, hub_url,
|
32
|
+
change_subscription(:subscribe, hub_url, token)
|
36
33
|
end
|
37
34
|
|
38
35
|
# Unsubscribe to the topic through the given hub.
|
39
|
-
def unsubscribe(hub_url,
|
36
|
+
def unsubscribe(hub_url, token = nil)
|
40
37
|
if token != nil
|
41
38
|
@tokens << token.to_s
|
42
39
|
end
|
43
|
-
change_subscription(:unsubscribe, hub_url,
|
40
|
+
change_subscription(:unsubscribe, hub_url, token)
|
44
41
|
end
|
45
42
|
|
46
|
-
def change_subscription(mode, hub_url,
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
43
|
+
def change_subscription(mode, hub_url, token, redirect_limit = 10)
|
44
|
+
hub_uri = URI.parse(hub_url)
|
45
|
+
|
46
|
+
req = Net::HTTP::Post.new(hub_uri.request_uri)
|
47
|
+
req.set_form_data({
|
48
|
+
'hub.mode' => mode.to_s,
|
49
|
+
'hub.callback' => @callback_url,
|
50
|
+
'hub.verify' => async ? 'async' : 'sync',
|
51
|
+
'hub.verify_token' => token,
|
52
|
+
'hub.lease_seconds' => '',
|
53
|
+
'hub.secret' => @secret,
|
54
|
+
'hub.topic' => @topic_url
|
55
|
+
})
|
56
|
+
|
57
|
+
http = Net::HTTP.new(hub_uri.hostname, hub_uri.port)
|
58
|
+
if hub_uri.scheme == 'https'
|
59
|
+
http.use_ssl = true
|
60
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
61
|
+
end
|
62
|
+
|
63
|
+
response = http.request(req)
|
64
|
+
|
65
|
+
if response.is_a?(Net::HTTPRedirection) && redirect_limit > 0
|
66
|
+
location = response['location']
|
67
|
+
self.change_subscription(mode, hub_url, token, redirect_limit - 1)
|
68
|
+
else
|
69
|
+
response
|
70
|
+
end
|
71
|
+
|
72
|
+
rescue OpenSSL::SSL::SSLError
|
73
|
+
return nil
|
55
74
|
end
|
56
75
|
|
57
76
|
def verify_subscription(token)
|
data/lib/osub/version.rb
CHANGED
data/lib/osub.rb
CHANGED
metadata
CHANGED
@@ -1,58 +1,55 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: osub
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 7
|
9
|
-
version: 0.0.7
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.9
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Hackers of the Severed Hand
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2014-10-06 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: ruby-hmac
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
- 0
|
30
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
31
22
|
type: :runtime
|
32
|
-
version_requirements: *id001
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: ostatus
|
35
23
|
prerelease: false
|
36
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
25
|
none: false
|
38
|
-
requirements:
|
39
|
-
- -
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
|
42
|
-
|
43
|
-
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: ostatus
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
44
38
|
type: :runtime
|
45
|
-
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
46
|
description: This is a simple implementation of a subscriber in the PubSubHubbub protocol.
|
47
|
-
email:
|
47
|
+
email:
|
48
48
|
- hotsh@xomb.org
|
49
49
|
executables: []
|
50
|
-
|
51
50
|
extensions: []
|
52
|
-
|
53
51
|
extra_rdoc_files: []
|
54
|
-
|
55
|
-
files:
|
52
|
+
files:
|
56
53
|
- .gitignore
|
57
54
|
- Gemfile
|
58
55
|
- LICENSE
|
@@ -62,37 +59,28 @@ files:
|
|
62
59
|
- lib/osub/subscription.rb
|
63
60
|
- lib/osub/version.rb
|
64
61
|
- osub.gemspec
|
65
|
-
has_rdoc: true
|
66
62
|
homepage: http://github.com/hotsh/osub
|
67
63
|
licenses: []
|
68
|
-
|
69
64
|
post_install_message:
|
70
65
|
rdoc_options: []
|
71
|
-
|
72
|
-
require_paths:
|
66
|
+
require_paths:
|
73
67
|
- lib
|
74
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
69
|
none: false
|
76
|
-
requirements:
|
77
|
-
- -
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
|
80
|
-
|
81
|
-
version: "0"
|
82
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
75
|
none: false
|
84
|
-
requirements:
|
85
|
-
- -
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
|
88
|
-
- 0
|
89
|
-
version: "0"
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
90
80
|
requirements: []
|
91
|
-
|
92
81
|
rubyforge_project: osub
|
93
|
-
rubygems_version: 1.
|
82
|
+
rubygems_version: 1.8.24
|
94
83
|
signing_key:
|
95
84
|
specification_version: 3
|
96
85
|
summary: This is a simple implementation of a subscriber in the PubSubHubbub protocol.
|
97
86
|
test_files: []
|
98
|
-
|