osub 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/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in osub.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,56 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+
4
+ module OSub
5
+ class Subscription
6
+ def initialize(callback_url, topic_url)
7
+ @callback_url = callback_url
8
+ @topic_url = topic_url
9
+ end
10
+
11
+ # Subscribe to the topic through the given hub.
12
+ def subscribe(hub_url = @topic_url)
13
+ change_subscription(:subscribe, hub_url)
14
+ end
15
+
16
+ # Unsubscribe to the topic through the given hub.
17
+ def unsubscribe(hub_url = @topic_url)
18
+ change_subscription(:unsubscribe, hub_url)
19
+ end
20
+
21
+ def change_subscription(mode, hub_url)
22
+ res = Net::HTTP.post_form(URI.parse(hub_url),
23
+ { 'hub.mode' => mode.to_s,
24
+ 'hub.callback' => @callback_url,
25
+ 'hub.verify' => 'async',
26
+ 'hub.verify_token' => '',
27
+ 'hub.lease_seconds' => '',
28
+ 'hub.secret' => '',
29
+ 'hub.topic' => @topic_url})
30
+ end
31
+
32
+ def perform_challenge(challenge_code)
33
+ {:body => challenge_code, :status => 200}
34
+ end
35
+ end
36
+
37
+ module Subscriptions
38
+ def Subscriptions.new(callback_url, topic_url)
39
+ if not defined?(@@instances)
40
+ @@instances = {}
41
+ end
42
+
43
+ if @@instances[topic_url] == nil
44
+ sub = OSub::Subscription.new(callback_url, topic_url)
45
+ @@instances[topic_url] = sub
46
+ end
47
+
48
+ @@instances[topic_url]
49
+ end
50
+
51
+ def Subscriptions.[](topic_url)
52
+ return nil if not defined?(@@instances)
53
+ @@instances[topic_url]
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,3 @@
1
+ module OSub
2
+ VERSION = "0.0.1"
3
+ end
data/lib/osub.rb ADDED
@@ -0,0 +1,2 @@
1
+ module OSub
2
+ end
data/osub.gemspec ADDED
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "osub/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "osub"
7
+ s.version = OSub::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ['Hackers of the Severed Hand']
10
+ s.email = ['hotsh@xomb.org']
11
+ s.homepage = "http://github.com/hotsh/osub"
12
+ s.summary = %q{This is a simple implementation of a subscriber in the PubSubHubbub protocol.}
13
+ s.description = %q{This is a simple implementation of a subscriber in the PubSubHubbub protocol.}
14
+
15
+ s.rubyforge_project = "osub"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: osub
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
+ - Hackers of the Severed Hand
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-03-12 23:00:00 -05:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: This is a simple implementation of a subscriber in the PubSubHubbub protocol.
22
+ email:
23
+ - hotsh@xomb.org
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - .gitignore
32
+ - Gemfile
33
+ - Rakefile
34
+ - lib/osub.rb
35
+ - lib/osub/subscriber.rb
36
+ - lib/osub/version.rb
37
+ - osub.gemspec
38
+ has_rdoc: true
39
+ homepage: http://github.com/hotsh/osub
40
+ licenses: []
41
+
42
+ post_install_message:
43
+ rdoc_options: []
44
+
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ segments:
53
+ - 0
54
+ version: "0"
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ requirements: []
64
+
65
+ rubyforge_project: osub
66
+ rubygems_version: 1.3.7
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: This is a simple implementation of a subscriber in the PubSubHubbub protocol.
70
+ test_files: []
71
+