webfinger 0.0.1 → 0.0.2
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/README.rdoc +48 -0
- data/VERSION +1 -1
- data/lib/webfinger/request.rb +16 -3
- data/spec/webfinger_spec.rb +49 -40
- metadata +3 -3
- data/README.md +0 -29
data/README.rdoc
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
= FbGraph
|
2
|
+
|
3
|
+
An Ruby WebFinger client library.
|
4
|
+
|
5
|
+
Following the latest WebFinger spec discussed at IETF WebFinger WG.
|
6
|
+
http://tools.ietf.org/html/draft-ietf-appsawg-webfinger
|
7
|
+
|
8
|
+
If you found something different from the latest spec, open an issue please.
|
9
|
+
|
10
|
+
== Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
gem 'webfinger'
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install webfinger
|
23
|
+
|
24
|
+
== Usage
|
25
|
+
|
26
|
+
# Basic
|
27
|
+
WebFinger.discover! 'acct:nov@gmail.com'
|
28
|
+
|
29
|
+
# Only specific relations
|
30
|
+
WebFinger.discover! 'acct:nov@gmail.com', rel: 'http://openid.net/specs/connect/1.0/issuer'
|
31
|
+
WebFinger.discover! 'acct:nov@gmail.com', rel: ['http://openid.net/specs/connect/1.0/issuer', 'vcard']
|
32
|
+
|
33
|
+
# Specify host
|
34
|
+
WebFinger.discover! 'acct:nov@gmail.com', host: 'mail.google.com'
|
35
|
+
|
36
|
+
For more detailed usage, read <code>spec/webfinger_spec.rb</code>.
|
37
|
+
|
38
|
+
== Contributing
|
39
|
+
|
40
|
+
1. Fork it
|
41
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
42
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
43
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
44
|
+
5. Create new Pull Request
|
45
|
+
|
46
|
+
== Copyright
|
47
|
+
|
48
|
+
Copyright (c) 2010 nov matake. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/lib/webfinger/request.rb
CHANGED
@@ -30,13 +30,26 @@ module WebFinger
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def endpoint
|
33
|
-
uri = URI.parse(resource)
|
34
33
|
path = '/.well-known/webfinger'
|
35
|
-
host =
|
36
|
-
port = @options[:port] || ([80, 443].include?(uri.port) ? nil : uri.port)
|
34
|
+
host, port = host_and_port
|
37
35
|
WebFinger.url_builder.build [nil, host, port, path, query_string, nil]
|
38
36
|
end
|
39
37
|
|
38
|
+
def host_and_port
|
39
|
+
uri = URI.parse(resource) rescue nil
|
40
|
+
if uri.try(:host).present?
|
41
|
+
[uri.host, [80, 443].include?(uri.port) ? nil : uri.port]
|
42
|
+
else
|
43
|
+
scheme_or_host, host_or_port, port_or_nil = resource.split('@').last.split('/').first.split(':')
|
44
|
+
case host_or_port
|
45
|
+
when nil, /\d+/
|
46
|
+
[scheme_or_host, host_or_port.try(:to_i)]
|
47
|
+
else
|
48
|
+
[host_or_port, port_or_nil.try(:to_i)]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
40
53
|
def query_string
|
41
54
|
query_params.join('&')
|
42
55
|
end
|
data/spec/webfinger_spec.rb
CHANGED
@@ -4,46 +4,55 @@ describe WebFinger do
|
|
4
4
|
let(:resource) { 'acct:nov@example.com' }
|
5
5
|
|
6
6
|
describe '#discover!' do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
7
|
+
{
|
8
|
+
'example.com' => 'https://example.com',
|
9
|
+
'example.com/~nov/' => 'https://example.com',
|
10
|
+
'nov@example.com' => 'https://example.com',
|
11
|
+
'nov.matake@example.com' => 'https://example.com',
|
12
|
+
'acct:nov@example.com' => 'https://example.com',
|
13
|
+
'mailto:nov@example.com' => 'https://example.com',
|
14
|
+
'device:example.com' => 'https://example.com',
|
15
|
+
'unknown:nov@example.com' => 'https://example.com',
|
16
|
+
'http://example.com/nov' => 'https://example.com',
|
17
|
+
'https://example.com/nov' => 'https://example.com',
|
18
|
+
'example.com:8080' => 'https://example.com:8080',
|
19
|
+
'example.com:8080/~nov/' => 'https://example.com:8080',
|
20
|
+
'nov@example.com:8080' => 'https://example.com:8080',
|
21
|
+
'nov.matake@example.com:8080' => 'https://example.com:8080',
|
22
|
+
'acct:nov@example.com:8080' => 'https://example.com:8080',
|
23
|
+
'mailto:nov@example.com:8080' => 'https://example.com:8080',
|
24
|
+
'device:example.com:8080' => 'https://example.com:8080',
|
25
|
+
'unknown:nov@example.com:8080' => 'https://example.com:8080',
|
26
|
+
'http://example.com:8080' => 'https://example.com:8080',
|
27
|
+
'https://example.com:8080' => 'https://example.com:8080',
|
28
|
+
'discover.example.com' => 'https://discover.example.com',
|
29
|
+
'discover.example.com/~nov/' => 'https://discover.example.com',
|
30
|
+
'nov@discover.example.com' => 'https://discover.example.com',
|
31
|
+
'nov.matake@discover.example.com' => 'https://discover.example.com',
|
32
|
+
'acct:nov@discover.example.com' => 'https://discover.example.com',
|
33
|
+
'mailto:nov@discover.example.com' => 'https://discover.example.com',
|
34
|
+
'device:discover.example.com' => 'https://discover.example.com',
|
35
|
+
'unknown:nov@discover.example.com' => 'https://discover.example.com',
|
36
|
+
'http://discover.example.com/nov' => 'https://discover.example.com',
|
37
|
+
'https://discover.example.com/nov' => 'https://discover.example.com',
|
38
|
+
'discover.example.com:8080' => 'https://discover.example.com:8080',
|
39
|
+
'discover.example.com:8080/~nov/' => 'https://discover.example.com:8080',
|
40
|
+
'nov@discover.example.com:8080' => 'https://discover.example.com:8080',
|
41
|
+
'nov.matake@discover.example.com:8080' => 'https://discover.example.com:8080',
|
42
|
+
'acct:nov@discover.example.com:8080' => 'https://discover.example.com:8080',
|
43
|
+
'mailto:nov@discover.example.com:8080' => 'https://discover.example.com:8080',
|
44
|
+
'device:discover.example.com:8080' => 'https://discover.example.com:8080',
|
45
|
+
'unknown:nov@discover.example.com:8080' => 'https://discover.example.com:8080',
|
46
|
+
'http://discover.example.com:8080/nov' => 'https://discover.example.com:8080',
|
47
|
+
'https://discover.example.com:8080/nov' => 'https://discover.example.com:8080'
|
48
|
+
}.each do |resource, base_url|
|
49
|
+
endpoint = File.join base_url, '/.well-known/webfinger'
|
50
|
+
context "when resource=#{resource}" do
|
51
|
+
it "should access to #{endpoint}" do
|
52
|
+
mock_json endpoint, 'all', query: {resource: resource} do
|
53
|
+
response = WebFinger.discover! resource
|
54
|
+
response.should be_instance_of WebFinger::Response
|
55
|
+
end
|
47
56
|
end
|
48
57
|
end
|
49
58
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webfinger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httpclient
|
@@ -117,7 +117,7 @@ files:
|
|
117
117
|
- .gitignore
|
118
118
|
- Gemfile
|
119
119
|
- LICENSE.txt
|
120
|
-
- README.
|
120
|
+
- README.rdoc
|
121
121
|
- Rakefile
|
122
122
|
- VERSION
|
123
123
|
- lib/webfinger.rb
|
data/README.md
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# Webfinger
|
2
|
-
|
3
|
-
TODO: Write a gem description
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
gem 'webfinger'
|
10
|
-
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
|
-
$ gem install webfinger
|
18
|
-
|
19
|
-
## Usage
|
20
|
-
|
21
|
-
TODO: Write usage instructions here
|
22
|
-
|
23
|
-
## Contributing
|
24
|
-
|
25
|
-
1. Fork it
|
26
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
-
5. Create new Pull Request
|