redfinger 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +43 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/lib/redfinger.rb +17 -0
- data/lib/redfinger/client.rb +50 -0
- data/lib/redfinger/finger.rb +24 -0
- data/lib/redfinger/link.rb +18 -0
- data/lib/redfinger/link_helpers.rb +31 -0
- data/redfinger.gemspec +73 -0
- data/spec/redfinger/client_spec.rb +76 -0
- data/spec/redfinger_spec.rb +10 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +53 -0
- metadata +122 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Intridea, Inc. and Michael Bleigh
|
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.rdoc
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
= Redfinger
|
2
|
+
|
3
|
+
Redfinger is a simple Ruby library built to consume the Webfinger protocol. It's simple!
|
4
|
+
|
5
|
+
== Usage
|
6
|
+
|
7
|
+
Just call it with an e-mail address of a domain that provides the Webfinger protocol:
|
8
|
+
|
9
|
+
require 'redfinger'
|
10
|
+
|
11
|
+
Redfinger.finger('youraccount@gmail.com')
|
12
|
+
|
13
|
+
From there, you have access to the links provided in the response as well as some shortcuts for common uses:
|
14
|
+
|
15
|
+
finger = Redfinger.finger('youraccount@gmail.com)
|
16
|
+
finger.open_id.first.to_s # => "http://www.google.com/profiles/youraccount"
|
17
|
+
|
18
|
+
Links are simple hash based objects that store the 'rel' URI (such as that for hCard, OpenID, etc.), the 'href' (the actual destination URI), and the content type if specified. Note you can also just use <tt>#to_s</tt> on a link to get the destination URI.
|
19
|
+
|
20
|
+
So how can you use Webfinger to your advantage? Let's take the example of hCard. If you install the `mofo` library you can do this:
|
21
|
+
|
22
|
+
require 'mofo'
|
23
|
+
require 'redfinger'
|
24
|
+
|
25
|
+
hcard_uri = Redfinger.finger('example@gmail.com').hcard.first
|
26
|
+
hcard = hCard.find(hcard_uri)
|
27
|
+
hcard.fn # => "Example Guy"
|
28
|
+
hcard.title # => "Title guy gave himself on Google profile"
|
29
|
+
|
30
|
+
Note that the Webfinger protocol is still in its alpha/infancy and there will likely be many changes as time progresses. This library will do its best to stay up-to-date and current with these changes over time.
|
31
|
+
|
32
|
+
== Note on Patches/Pull Requests
|
33
|
+
|
34
|
+
* Fork the project.
|
35
|
+
* Make your feature addition or bug fix.
|
36
|
+
* Add tests for it. This is important so I don't break it in a
|
37
|
+
future version unintentionally.
|
38
|
+
* Commit, do not mess with rakefile, version, or history. (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)
|
39
|
+
* Send me a pull request. Bonus points for topic branches.
|
40
|
+
|
41
|
+
== Copyright
|
42
|
+
|
43
|
+
Copyright (c) 2010 Intridea, Inc. and Michael Bleigh. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "redfinger"
|
8
|
+
gem.summary = %Q{A Ruby WebFinger client.}
|
9
|
+
gem.description = %Q{A Ruby Webfinger client}
|
10
|
+
gem.email = "michael@intridea.com"
|
11
|
+
gem.homepage = "http://github.com/mbleigh/redfinger"
|
12
|
+
gem.authors = ["Michael Bleigh"]
|
13
|
+
gem.add_dependency "rest-client"
|
14
|
+
gem.add_dependency "nokogiri"
|
15
|
+
gem.add_dependency "hashie"
|
16
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
17
|
+
gem.add_development_dependency "webmock"
|
18
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
19
|
+
end
|
20
|
+
Jeweler::GemcutterTasks.new
|
21
|
+
rescue LoadError
|
22
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'spec/rake/spectask'
|
26
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
27
|
+
spec.libs << 'lib' << 'spec'
|
28
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
29
|
+
end
|
30
|
+
|
31
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
32
|
+
spec.libs << 'lib' << 'spec'
|
33
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
34
|
+
spec.rcov = true
|
35
|
+
end
|
36
|
+
|
37
|
+
task :spec => :check_dependencies
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rake/rdoctask'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "redfinger #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.2
|
data/lib/redfinger.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'redfinger/link_helpers'
|
2
|
+
require 'redfinger/link'
|
3
|
+
require 'redfinger/finger'
|
4
|
+
require 'redfinger/client'
|
5
|
+
|
6
|
+
module Redfinger
|
7
|
+
class ResourceNotFound < StandardError; end
|
8
|
+
# A SecurityException occurs when something in the
|
9
|
+
# webfinger process does not appear safe, such as
|
10
|
+
# mismatched domains or an unverified XRD signature.
|
11
|
+
class SecurityException < StandardError; end
|
12
|
+
|
13
|
+
# Finger the provided e-mail address.
|
14
|
+
def self.finger(email)
|
15
|
+
Redfinger::Client.new(email).finger
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'restclient'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
module Redfinger
|
6
|
+
class Client
|
7
|
+
attr_accessor :account, :domain, :uri_template
|
8
|
+
|
9
|
+
def initialize(email, uri_template = nil)
|
10
|
+
self.account = urify(email)
|
11
|
+
self.domain = account.split('@').last
|
12
|
+
end
|
13
|
+
|
14
|
+
def finger
|
15
|
+
self.uri_template ||= retrieve_template_from_xrd
|
16
|
+
Finger.new RestClient.get(swizzle)
|
17
|
+
end
|
18
|
+
|
19
|
+
def xrd_url(ssl = true)
|
20
|
+
"http#{'s' if ssl}://#{domain}/.well-known/host-meta"
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def swizzle
|
26
|
+
uri_template.gsub '{uri}', URI.escape(self.account)
|
27
|
+
end
|
28
|
+
|
29
|
+
def retrieve_template_from_xrd(ssl = true)
|
30
|
+
doc = Nokogiri::XML::Document.parse(RestClient.get(xrd_url(ssl)))
|
31
|
+
|
32
|
+
unless doc.at_xpath('.//hm:Host').content == self.domain
|
33
|
+
raise Redfinger::SecurityException, "The XRD document's host did not match the account's host."
|
34
|
+
end
|
35
|
+
|
36
|
+
doc.at('Link[rel=lrdd]').attribute('template').value
|
37
|
+
rescue Errno::ECONNREFUSED, RestClient::ResourceNotFound
|
38
|
+
if ssl
|
39
|
+
retrieve_template_from_xrd(false)
|
40
|
+
else
|
41
|
+
raise Redfinger::ResourceNotFound, "Unable to find the host XRD file."
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def urify(email)
|
46
|
+
email = "acct:#{email}" unless email.include?("acct:")
|
47
|
+
email
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module Redfinger
|
4
|
+
# The result of a Webfinger. For more information about
|
5
|
+
# special helpers that are availale to pull specific types
|
6
|
+
# of URLs, see Redfinger::LinkHelpers
|
7
|
+
class Finger
|
8
|
+
def initialize(xml) # :nodoc:
|
9
|
+
@doc = Nokogiri::XML::Document.parse(xml)
|
10
|
+
@subject = @doc.at_css('Subject').content
|
11
|
+
end
|
12
|
+
|
13
|
+
# All of the links provided by the Webfinger response.
|
14
|
+
def links
|
15
|
+
@links ||= @doc.css('Link').map{|l| Link.new(l)}
|
16
|
+
end
|
17
|
+
|
18
|
+
def inspect # :nodoc:
|
19
|
+
"<#Redfinger::Finger subject=\"#{@subject}\">"
|
20
|
+
end
|
21
|
+
|
22
|
+
include Redfinger::LinkHelpers
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'hashie'
|
3
|
+
|
4
|
+
module Redfinger
|
5
|
+
class Link < Hashie::Mash
|
6
|
+
def initialize(xml_link)
|
7
|
+
self[:rel] = xml_link['rel']
|
8
|
+
self[:href] = xml_link['href']
|
9
|
+
self[:type] = xml_link['type']
|
10
|
+
end
|
11
|
+
|
12
|
+
# Outputs the URL of the link, useful for using
|
13
|
+
# a Link directly in other libraries.
|
14
|
+
def to_s
|
15
|
+
self.href
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module Redfinger
|
4
|
+
module LinkHelpers
|
5
|
+
# An array of links with hCard information about this e-mail address.
|
6
|
+
def hcard
|
7
|
+
relmap('http://microformats.org/profile/hcard')
|
8
|
+
end
|
9
|
+
|
10
|
+
# An array of links of OpenID providers for this e-mail address.
|
11
|
+
def open_id
|
12
|
+
relmap('http://specs.openid.net/auth/', true)
|
13
|
+
end
|
14
|
+
|
15
|
+
# An array of links to profile pages belonging to this e-mail address.
|
16
|
+
def profile_page
|
17
|
+
relmap('http://webfinger.net/rel/profile-page')
|
18
|
+
end
|
19
|
+
|
20
|
+
# An array of links to XFN compatible URLs for this e-mail address.
|
21
|
+
def xfn
|
22
|
+
relmap('http://gmpg.org/xfn/', true)
|
23
|
+
end
|
24
|
+
|
25
|
+
protected
|
26
|
+
|
27
|
+
def relmap(uri, substring=false)
|
28
|
+
@doc.css("Link[rel#{'^' if substring}=\"#{uri}\"]").map{|e| Link.new(e)}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/redfinger.gemspec
ADDED
@@ -0,0 +1,73 @@
|
|
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{redfinger}
|
8
|
+
s.version = "0.0.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Michael Bleigh"]
|
12
|
+
s.date = %q{2010-02-12}
|
13
|
+
s.description = %q{A Ruby Webfinger client}
|
14
|
+
s.email = %q{michael@intridea.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"lib/redfinger.rb",
|
27
|
+
"lib/redfinger/client.rb",
|
28
|
+
"lib/redfinger/finger.rb",
|
29
|
+
"lib/redfinger/link.rb",
|
30
|
+
"lib/redfinger/link_helpers.rb",
|
31
|
+
"redfinger.gemspec",
|
32
|
+
"spec/redfinger/client_spec.rb",
|
33
|
+
"spec/redfinger_spec.rb",
|
34
|
+
"spec/spec.opts",
|
35
|
+
"spec/spec_helper.rb"
|
36
|
+
]
|
37
|
+
s.homepage = %q{http://github.com/mbleigh/redfinger}
|
38
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
39
|
+
s.require_paths = ["lib"]
|
40
|
+
s.rubygems_version = %q{1.3.5}
|
41
|
+
s.summary = %q{A Ruby WebFinger client.}
|
42
|
+
s.test_files = [
|
43
|
+
"spec/redfinger/client_spec.rb",
|
44
|
+
"spec/redfinger_spec.rb",
|
45
|
+
"spec/spec_helper.rb"
|
46
|
+
]
|
47
|
+
|
48
|
+
if s.respond_to? :specification_version then
|
49
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
50
|
+
s.specification_version = 3
|
51
|
+
|
52
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
53
|
+
s.add_runtime_dependency(%q<rest-client>, [">= 0"])
|
54
|
+
s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
|
55
|
+
s.add_runtime_dependency(%q<hashie>, [">= 0"])
|
56
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
57
|
+
s.add_development_dependency(%q<webmock>, [">= 0"])
|
58
|
+
else
|
59
|
+
s.add_dependency(%q<rest-client>, [">= 0"])
|
60
|
+
s.add_dependency(%q<nokogiri>, [">= 0"])
|
61
|
+
s.add_dependency(%q<hashie>, [">= 0"])
|
62
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
63
|
+
s.add_dependency(%q<webmock>, [">= 0"])
|
64
|
+
end
|
65
|
+
else
|
66
|
+
s.add_dependency(%q<rest-client>, [">= 0"])
|
67
|
+
s.add_dependency(%q<nokogiri>, [">= 0"])
|
68
|
+
s.add_dependency(%q<hashie>, [">= 0"])
|
69
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
70
|
+
s.add_dependency(%q<webmock>, [">= 0"])
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
class HaltSuccessError < StandardError; end
|
4
|
+
|
5
|
+
describe Redfinger::Client do
|
6
|
+
describe '#new' do
|
7
|
+
it 'should add acct: if it is not in URI form' do
|
8
|
+
Redfinger::Client.new('abc@example.com').account.should == 'acct:abc@example.com'
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should not add acct: if it is already in URI form' do
|
12
|
+
Redfinger::Client.new('acct:abc@example.com').account.should == 'acct:abc@example.com'
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should set the domain to whatevers after the @ sign' do
|
16
|
+
Redfinger::Client.new('abc@example.com').domain.should == 'example.com'
|
17
|
+
Redfinger::Client.new('abc@frog.co.uk').domain.should == 'frog.co.uk'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#retrieve_template_from_xrd' do
|
22
|
+
it 'should make an SSL request to get the host XRD document' do
|
23
|
+
stub_request(:get, 'https://example.com/.well-known/host-meta').to_raise(HaltSuccessError)
|
24
|
+
lambda{Redfinger::Client.new('acct:abc@example.com').send(:retrieve_template_from_xrd)}.should raise_error(HaltSuccessError)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should make an HTTP request if HTTPS cannot connect' do
|
28
|
+
stub_request(:get, 'https://example.com/.well-known/host-meta').to_raise(Errno::ECONNREFUSED)
|
29
|
+
stub_request(:get, 'http://example.com/.well-known/host-meta').to_raise(HaltSuccessError)
|
30
|
+
lambda{Redfinger::Client.new('acct:abc@example.com').send(:retrieve_template_from_xrd)}.should raise_error(HaltSuccessError)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should raise Redfinger::ResourceNotFound if HTTP fails as well' do
|
34
|
+
stub_request(:get, 'https://example.com/.well-known/host-meta').to_raise(Errno::ECONNREFUSED)
|
35
|
+
stub_request(:get, 'http://example.com/.well-known/host-meta').to_raise(Errno::ECONNREFUSED)
|
36
|
+
lambda{Redfinger::Client.new('acct:abc@example.com').send(:retrieve_template_from_xrd)}.should raise_error(Redfinger::ResourceNotFound)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should raise Redfinger::ResourceNotFound on 404 as well as HTTP fail' do
|
40
|
+
stub_request(:get, /.well-known\/host-meta/).to_return(:status => 404, :body => '404 Not Found')
|
41
|
+
lambda{Redfinger::Client.new('acct:abc@example.com').send(:retrieve_template_from_xrd)}.should raise_error(Redfinger::ResourceNotFound)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should return the template' do
|
45
|
+
stub_request(:get, 'https://example.com/.well-known/host-meta').to_return(:status => 200, :body => host_xrd)
|
46
|
+
Redfinger::Client.new('acct:abc@example.com').send(:retrieve_template_from_xrd).should == 'http://example.com/webfinger/?q={uri}'
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should raise a SecurityException if there is a host mismatch' do
|
50
|
+
stub_request(:get, 'https://franklin.com/.well-known/host-meta').to_return(:status => 200, :body => host_xrd)
|
51
|
+
lambda{Redfinger::Client.new('acct:abc@franklin.com').send(:retrieve_template_from_xrd)}.should raise_error(Redfinger::SecurityException)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#finger' do
|
56
|
+
it 'should fetch the URI template if is not set' do
|
57
|
+
stub_success
|
58
|
+
@client = Redfinger::Client.new('abc@example.com')
|
59
|
+
@client.should_receive(:retrieve_template_from_xrd).and_raise(HaltSuccessError)
|
60
|
+
lambda{@client.finger}.should raise_error(HaltSuccessError)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should NOT fetch the URI template if it is already set' do
|
64
|
+
stub_success
|
65
|
+
@client = Redfinger::Client.new('abc@example.com')
|
66
|
+
@client.should_not_receive(:retrieve_template_from_xrd)
|
67
|
+
@client.uri_template = 'http://example.com/webfinger/?q={uri}'
|
68
|
+
@client.finger
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should return a Finger' do
|
72
|
+
stub_success
|
73
|
+
Redfinger::Client.new('abc@example.com').finger.should be_kind_of(Redfinger::Finger)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe Redfinger do
|
4
|
+
describe '#finger' do
|
5
|
+
it 'should initialize a new client' do
|
6
|
+
Redfinger::Client.should_receive(:new).with('abc@example.com').and_return(mock("Redfinger::Client", :finger => nil))
|
7
|
+
Redfinger.finger('abc@example.com')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'redfinger'
|
6
|
+
require 'spec'
|
7
|
+
require 'spec/autorun'
|
8
|
+
require 'webmock/rspec'
|
9
|
+
|
10
|
+
include WebMock
|
11
|
+
|
12
|
+
def host_xrd
|
13
|
+
<<-XML
|
14
|
+
<?xml version='1.0' encoding='UTF-8'?>
|
15
|
+
<!-- NOTE: this host-meta end-point is a pre-alpha work in progress. Don't rely on it. -->
|
16
|
+
<!-- Please follow the list at http://groups.google.com/group/webfinger -->
|
17
|
+
<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'
|
18
|
+
xmlns:hm='http://host-meta.net/xrd/1.0'>
|
19
|
+
<hm:Host xmlns='http://host-meta.net/xrd/1.0'>example.com</hm:Host>
|
20
|
+
<Link rel='lrdd'
|
21
|
+
template='http://example.com/webfinger/?q={uri}'>
|
22
|
+
<Title>Resource Descriptor</Title>
|
23
|
+
</Link>
|
24
|
+
</XRD>
|
25
|
+
XML
|
26
|
+
end
|
27
|
+
|
28
|
+
def finger_xrd
|
29
|
+
<<-XML
|
30
|
+
<?xml version='1.0'?>
|
31
|
+
<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>
|
32
|
+
<Subject>acct:abc@example.com</Subject>
|
33
|
+
<Alias>http://www.google.com/profiles/abc</Alias>
|
34
|
+
<Link rel='http://portablecontacts.net/spec/1.0' href='http://www-opensocial.googleusercontent.com/api/people/'/>
|
35
|
+
<Link rel='http://webfinger.net/rel/profile-page' href='http://www.google.com/profiles/abc' type='text/html'/>
|
36
|
+
<Link rel='http://microformats.org/profile/hcard' href='http://www.google.com/profiles/abc' type='text/html'/>
|
37
|
+
<Link rel='http://gmpg.org/xfn/11' href='http://www.google.com/profiles/abc' type='text/html'/>
|
38
|
+
<Link rel='http://specs.openid.net/auth/2.0/provider' href='http://www.google.com/profiles/abc'/>
|
39
|
+
<Link rel='describedby' href='http://www.google.com/profiles/abc' type='text/html'/>
|
40
|
+
<Link rel='describedby' href='http://s2.googleusercontent.com/webfinger/?q=acct%3Aabc%example.com&fmt=foaf' type='application/rdf+xml'/>
|
41
|
+
<Link rel='http://schemas.google.com/g/2010#updates-from' href='http://buzz.googleapis.com/feeds/100660544095714416357/public/posted' type='application/atom+xml'/>
|
42
|
+
</XRD>
|
43
|
+
XML
|
44
|
+
end
|
45
|
+
|
46
|
+
def stub_success
|
47
|
+
stub_request(:get, 'https://example.com/.well-known/host-meta').to_return(:status => 200, :body => host_xrd)
|
48
|
+
stub_request(:get, /webfinger\/\?q=.*/).to_return(:status => 200, :body => finger_xrd)
|
49
|
+
end
|
50
|
+
|
51
|
+
Spec::Runner.configure do |config|
|
52
|
+
|
53
|
+
end
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: redfinger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michael Bleigh
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-02-12 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rest-client
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: nokogiri
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: hashie
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: rspec
|
47
|
+
type: :development
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.2.9
|
54
|
+
version:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
type: :development
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
65
|
+
description: A Ruby Webfinger client
|
66
|
+
email: michael@intridea.com
|
67
|
+
executables: []
|
68
|
+
|
69
|
+
extensions: []
|
70
|
+
|
71
|
+
extra_rdoc_files:
|
72
|
+
- LICENSE
|
73
|
+
- README.rdoc
|
74
|
+
files:
|
75
|
+
- .document
|
76
|
+
- .gitignore
|
77
|
+
- LICENSE
|
78
|
+
- README.rdoc
|
79
|
+
- Rakefile
|
80
|
+
- VERSION
|
81
|
+
- lib/redfinger.rb
|
82
|
+
- lib/redfinger/client.rb
|
83
|
+
- lib/redfinger/finger.rb
|
84
|
+
- lib/redfinger/link.rb
|
85
|
+
- lib/redfinger/link_helpers.rb
|
86
|
+
- redfinger.gemspec
|
87
|
+
- spec/redfinger/client_spec.rb
|
88
|
+
- spec/redfinger_spec.rb
|
89
|
+
- spec/spec.opts
|
90
|
+
- spec/spec_helper.rb
|
91
|
+
has_rdoc: true
|
92
|
+
homepage: http://github.com/mbleigh/redfinger
|
93
|
+
licenses: []
|
94
|
+
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options:
|
97
|
+
- --charset=UTF-8
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: "0"
|
105
|
+
version:
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: "0"
|
111
|
+
version:
|
112
|
+
requirements: []
|
113
|
+
|
114
|
+
rubyforge_project:
|
115
|
+
rubygems_version: 1.3.5
|
116
|
+
signing_key:
|
117
|
+
specification_version: 3
|
118
|
+
summary: A Ruby WebFinger client.
|
119
|
+
test_files:
|
120
|
+
- spec/redfinger/client_spec.rb
|
121
|
+
- spec/redfinger_spec.rb
|
122
|
+
- spec/spec_helper.rb
|