push-client 0.1.0
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/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.markdown +39 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/lib/push-client.rb +61 -0
- data/push-client.gemspec +48 -0
- metadata +81 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Peter Haza
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# push-client
|
2
|
+
|
3
|
+
## Using Subscriber
|
4
|
+
PushClient::Subscriber.new('http://someexamplehub.com').subscribe('somefeedurl', 'somecallbackurl')
|
5
|
+
or
|
6
|
+
PushClient::Subscriber.new('http://someexamplehub.com') do |s|
|
7
|
+
s.subscribe('somefeedurl1', 'somecallbackurl1')
|
8
|
+
s.subscribe('somefeedurl2', 'somecallbackurl2')
|
9
|
+
s.subscribe('somefeedurl3', 'somecallbackurl3')
|
10
|
+
end
|
11
|
+
|
12
|
+
## Using Publisher
|
13
|
+
PushClient::Publisher.new('http://someexamplehub.com').publish('somefeedurl', 'somefeedurl', 'somefeedurl')
|
14
|
+
or
|
15
|
+
PushClient::Publisher.new('http://someexamplehub.com') do |s|
|
16
|
+
s.publish('somefeedurl1')
|
17
|
+
s.publish('somefeedurl2')
|
18
|
+
s.publish('somefeedurl3')
|
19
|
+
end
|
20
|
+
|
21
|
+
## Dependencies
|
22
|
+
* HTTParty
|
23
|
+
|
24
|
+
## Tests
|
25
|
+
There are no tests as I don't know how to write them for a client like this :/
|
26
|
+
|
27
|
+
## Note on Patches/Pull Requests
|
28
|
+
|
29
|
+
* Fork the project.
|
30
|
+
* Make your feature addition or bug fix.
|
31
|
+
* Add tests for it. This is important so I don't break it in a
|
32
|
+
future version unintentionally.
|
33
|
+
* Commit, do not mess with rakefile, version, or history.
|
34
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
35
|
+
* Send me a pull request. Bonus points for topic branches.
|
36
|
+
|
37
|
+
## Copyright
|
38
|
+
|
39
|
+
Copyright (c) 2010 Peter Haza. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "push-client"
|
8
|
+
gem.summary = %Q{A subscriber and publisher client for talking with a pubsubhubbub}
|
9
|
+
gem.description = %Q{A subscriber and publisher client for talking with a pubsubhubbub.}
|
10
|
+
gem.email = "peter.haza@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/phaza/push-client"
|
12
|
+
gem.authors = ["Peter Haza"]
|
13
|
+
gem.add_dependency "httparty", ">= 0"
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
end
|
16
|
+
Jeweler::GemcutterTasks.new
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'rake/testtask'
|
22
|
+
Rake::TestTask.new(:test) do |test|
|
23
|
+
test.libs << 'lib' << 'test'
|
24
|
+
test.pattern = 'test/**/test_*.rb'
|
25
|
+
test.verbose = true
|
26
|
+
end
|
27
|
+
|
28
|
+
begin
|
29
|
+
require 'rcov/rcovtask'
|
30
|
+
Rcov::RcovTask.new do |test|
|
31
|
+
test.libs << 'test'
|
32
|
+
test.pattern = 'test/**/test_*.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
rescue LoadError
|
36
|
+
task :rcov do
|
37
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
task :test => :check_dependencies
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "push-client #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/lib/push-client.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Much borrowed from http://github.com/igrigorik/PubSubHubbub
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'httparty'
|
5
|
+
|
6
|
+
module PushClient
|
7
|
+
|
8
|
+
class Communicator
|
9
|
+
include ::HTTParty
|
10
|
+
|
11
|
+
HEADERS = {'User-Agent' => 'PuSH Ruby Client', 'Content-Type' => 'application/x-www-form-urlencoded'}
|
12
|
+
|
13
|
+
def initialize(hub)
|
14
|
+
@hub = hub
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Subscriber < Communicator
|
19
|
+
|
20
|
+
def initialize(hub)
|
21
|
+
super(hub)
|
22
|
+
yield self if block_given?
|
23
|
+
end
|
24
|
+
|
25
|
+
def subscribe(feed, callback, options = {})
|
26
|
+
command('subscribe', feed, callback, options)
|
27
|
+
end
|
28
|
+
|
29
|
+
def unsubscribe(feed, callback, options = {})
|
30
|
+
command('unsubscribe', feed, callback, options)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
def command(mode, feed, callback, options)
|
35
|
+
options['hub.verify'] ||= 'sync'
|
36
|
+
params = {'hub.mode' => mode, 'hub.topic' => feed, 'hub.callback' => callback}.merge(options)
|
37
|
+
|
38
|
+
self.class.post("#{@hub}", :body => params, :headers => HEADERS)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
class Publisher < Communicator
|
44
|
+
|
45
|
+
def initialize(hub)
|
46
|
+
super(hub)
|
47
|
+
yield self if block_given?
|
48
|
+
end
|
49
|
+
|
50
|
+
def publish(*feeds)
|
51
|
+
|
52
|
+
feeds.flatten.each do |f|
|
53
|
+
self.class.post("#{@hub}", :body => {'hub.mode' => 'publish', 'hub.url' => f}, :headers => HEADERS)
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
end
|
data/push-client.gemspec
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{push-client}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Peter Haza"]
|
12
|
+
s.date = %q{2010-04-29}
|
13
|
+
s.description = %q{A subscriber and publisher client for talking with a pubsubhubbub.}
|
14
|
+
s.email = %q{peter.haza@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.markdown"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.markdown",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"lib/push-client.rb",
|
27
|
+
"push-client.gemspec"
|
28
|
+
]
|
29
|
+
s.homepage = %q{http://github.com/phaza/push-client}
|
30
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
31
|
+
s.require_paths = ["lib"]
|
32
|
+
s.rubygems_version = %q{1.3.6}
|
33
|
+
s.summary = %q{A subscriber and publisher client for talking with a pubsubhubbub}
|
34
|
+
|
35
|
+
if s.respond_to? :specification_version then
|
36
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
37
|
+
s.specification_version = 3
|
38
|
+
|
39
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
40
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0"])
|
41
|
+
else
|
42
|
+
s.add_dependency(%q<httparty>, [">= 0"])
|
43
|
+
end
|
44
|
+
else
|
45
|
+
s.add_dependency(%q<httparty>, [">= 0"])
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: push-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Peter Haza
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-04-29 00:00:00 +02:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: httparty
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :runtime
|
31
|
+
version_requirements: *id001
|
32
|
+
description: A subscriber and publisher client for talking with a pubsubhubbub.
|
33
|
+
email: peter.haza@gmail.com
|
34
|
+
executables: []
|
35
|
+
|
36
|
+
extensions: []
|
37
|
+
|
38
|
+
extra_rdoc_files:
|
39
|
+
- LICENSE
|
40
|
+
- README.markdown
|
41
|
+
files:
|
42
|
+
- .document
|
43
|
+
- .gitignore
|
44
|
+
- LICENSE
|
45
|
+
- README.markdown
|
46
|
+
- Rakefile
|
47
|
+
- VERSION
|
48
|
+
- lib/push-client.rb
|
49
|
+
- push-client.gemspec
|
50
|
+
has_rdoc: true
|
51
|
+
homepage: http://github.com/phaza/push-client
|
52
|
+
licenses: []
|
53
|
+
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options:
|
56
|
+
- --charset=UTF-8
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
segments:
|
64
|
+
- 0
|
65
|
+
version: "0"
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
version: "0"
|
73
|
+
requirements: []
|
74
|
+
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 1.3.6
|
77
|
+
signing_key:
|
78
|
+
specification_version: 3
|
79
|
+
summary: A subscriber and publisher client for talking with a pubsubhubbub
|
80
|
+
test_files: []
|
81
|
+
|