vishnu 1.2.2 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/libravatar.rb +4 -1
- data/lib/vishnu/version.rb +5 -0
- data/lib/vishnu.rb +103 -69
- metadata +23 -48
- data/.document +0 -5
- data/.travis.yml +0 -5
- data/Gemfile +0 -9
- data/LICENSE.txt +0 -22
- data/README.rdoc +0 -20
- data/Rakefile +0 -39
- data/VERSION +0 -1
- data/test/helper.rb +0 -11
- data/test/test_libravatar.rb +0 -50
- data/vishnu.gemspec +0 -61
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 39c384bc0a95bcbf579da3f0b6b67c0c2373f7ab22131e11c22411201eff6e97
|
4
|
+
data.tar.gz: 48582e1db8a8fce83385ad8df1dedd84857dbc6003d4d4ca8de056fbe5503209
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75b4cc8561a2cb4b11f8c1d33c20fba40cb987bb9424d2bb9146005a175306bb4f9d6cb212c6659137e388b67228f1dcee8945be05afb6096f8224a5fe459624
|
7
|
+
data.tar.gz: f3ac061ca1e38ab6013b87db04f2c7f09d18cc0ecd9210e998b7aaf46634fe4e52ec83b96797cc04f6bc732925fc9f6e7fc4715191423db6e3daa5956646a3a8
|
data/lib/libravatar.rb
CHANGED
data/lib/vishnu.rb
CHANGED
@@ -1,15 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
|
-
# The
|
3
|
-
# web service at
|
3
|
+
# The Vishnu class generates the avatar URL provided by the libravatar
|
4
|
+
# web service at https://www.libravatar.org
|
4
5
|
#
|
5
6
|
# Users may associate their avatar images with multiple OpenIDs and Emails.
|
6
|
-
#
|
7
|
-
# Author:: Kang-min Liu (http://gugod.org)
|
7
|
+
#
|
8
|
+
# Original Author:: Kang-min Liu (http://gugod.org/)
|
9
|
+
# Fork Author:: Anton Smirnov (https://sandfox.me/)
|
8
10
|
# Copyright:: Copyright (c) 2011 Kang-min Liu
|
9
11
|
# License:: MIT
|
10
|
-
# Contributors:: https://github.com/
|
12
|
+
# Contributors:: https://github.com/sandfoxme/vishnu/graphs/contributors
|
11
13
|
#
|
12
14
|
|
15
|
+
require 'vishnu/version'
|
16
|
+
|
13
17
|
require 'digest/md5'
|
14
18
|
require 'digest/sha2'
|
15
19
|
require 'uri'
|
@@ -20,7 +24,7 @@ class Vishnu
|
|
20
24
|
|
21
25
|
# The options should contain :email or :openid values. If both are
|
22
26
|
# given, email will be used. The value of openid and email will be
|
23
|
-
# normalized by the rule described in
|
27
|
+
# normalized by the rule described in https://wiki.libravatar.org/api/
|
24
28
|
#
|
25
29
|
# List of option keys:
|
26
30
|
#
|
@@ -28,101 +32,131 @@ class Vishnu
|
|
28
32
|
# - :openid
|
29
33
|
# - :size An integer ranged 1 - 512, default is 80.
|
30
34
|
# - :https Set to true to serve avatars over SSL
|
31
|
-
# - :default URL to redirect missing avatars to, or one of these specials:
|
35
|
+
# - :default URL to redirect missing avatars to, or one of these specials:
|
36
|
+
# "404", "mm", "identicon", "monsterid", "wavatar", "retro"
|
32
37
|
#
|
33
|
-
def initialize(
|
34
|
-
@email =
|
35
|
-
@openid =
|
36
|
-
@size =
|
37
|
-
@default =
|
38
|
-
@https =
|
38
|
+
def initialize(email: nil, openid: nil, size: nil, default: nil, https: nil)
|
39
|
+
@email = email
|
40
|
+
@openid = openid
|
41
|
+
@size = size
|
42
|
+
@default = default
|
43
|
+
@https = https
|
39
44
|
end
|
40
45
|
|
41
|
-
|
42
|
-
|
43
|
-
|
46
|
+
# All the values which are different between HTTP and HTTPS methods.
|
47
|
+
PROFILES = {
|
48
|
+
http: {
|
49
|
+
scheme: 'http://',
|
50
|
+
host: 'cdn.libravatar.org',
|
51
|
+
srv: '_avatars._tcp.',
|
52
|
+
port: 80,
|
53
|
+
}.freeze,
|
54
|
+
https: {
|
55
|
+
scheme: 'https://',
|
56
|
+
host: 'seccdn.libravatar.org',
|
57
|
+
srv: '_avatars-sec._tcp.',
|
58
|
+
port: 443,
|
59
|
+
}.freeze
|
60
|
+
}.freeze
|
61
|
+
|
62
|
+
# Generate the libravatar URL
|
63
|
+
def url
|
64
|
+
id =
|
65
|
+
if @email
|
66
|
+
Digest::MD5.hexdigest(normalize_email(@email))
|
67
|
+
else
|
68
|
+
Digest::SHA2.hexdigest(normalize_openid(@openid))
|
69
|
+
end
|
70
|
+
|
71
|
+
size = "s=#{@size}" if @size
|
72
|
+
default = "d=#{@default}" if @default
|
73
|
+
|
74
|
+
# noinspection RubyScope
|
75
|
+
# ok for them to be nil
|
76
|
+
query = [size, default].reject(&:!).join('&')
|
77
|
+
query = "?#{query}" unless query == ''
|
78
|
+
|
79
|
+
base_url = get_base_url + '/avatar/'
|
80
|
+
|
81
|
+
base_url + id + query
|
44
82
|
end
|
45
83
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
84
|
+
alias_method :to_s, :url
|
85
|
+
|
86
|
+
private
|
87
|
+
|
88
|
+
def profile
|
89
|
+
PROFILES[@https ? :https : :http]
|
90
|
+
end
|
91
|
+
|
92
|
+
def get_target_domain
|
93
|
+
if @email
|
94
|
+
@email.split('@')[1]
|
95
|
+
else
|
96
|
+
URI.parse(@openid).host
|
97
|
+
end
|
98
|
+
end
|
57
99
|
|
58
100
|
# Grab the DNS SRV records associated with the target domain,
|
59
101
|
# and choose one according to RFC2782.
|
60
102
|
def srv_lookup
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
Resolv::DNS::Resource::IN::SRV
|
65
|
-
|
103
|
+
Resolv::DNS.open do |dns|
|
104
|
+
resources = dns.getresources(
|
105
|
+
profile[:srv] + get_target_domain,
|
106
|
+
Resolv::DNS::Resource::IN::SRV
|
107
|
+
).to_a
|
66
108
|
|
109
|
+
return [nil, nil] unless resources.any?
|
67
110
|
|
68
|
-
min_priority =
|
69
|
-
|
111
|
+
min_priority = resources.map(&:priority).min
|
112
|
+
resources.delete_if { |r| r.priority != min_priority }
|
70
113
|
|
71
|
-
weight_sum =
|
114
|
+
weight_sum = resources.inject(0) { |sum, r| sum + r.weight }.to_f
|
72
115
|
|
73
|
-
|
116
|
+
resource = resources.max_by do |r|
|
117
|
+
if r.weight == 0
|
118
|
+
0
|
119
|
+
else
|
120
|
+
rand**(weight_sum / r.weight)
|
121
|
+
end
|
122
|
+
end
|
74
123
|
|
75
|
-
return
|
124
|
+
return sanitize_srv_lookup(resource.target.to_s, resource.port)
|
76
125
|
end
|
77
126
|
end
|
78
127
|
|
79
128
|
def get_base_url
|
80
|
-
profile = @@profiles[ @https ? 1 : 0 ]
|
81
129
|
target, port = srv_lookup
|
82
130
|
|
83
|
-
if
|
131
|
+
if target && port
|
84
132
|
port_fragment = port != profile[:port] ? ':' + port.to_s : ''
|
85
|
-
|
86
|
-
else
|
87
|
-
return profile[:scheme] + profile[:host]
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
# Generate the libravatar URL
|
92
|
-
def to_s
|
93
|
-
if @email
|
94
|
-
@email.downcase!
|
95
|
-
id = Digest::MD5.hexdigest(@email)
|
133
|
+
profile[:scheme] + target.to_s + port_fragment
|
96
134
|
else
|
97
|
-
|
135
|
+
profile[:scheme] + profile[:host]
|
98
136
|
end
|
99
|
-
s = @size ? "s=#{@size}" : nil
|
100
|
-
d = @default ? "d=#{@default}" : nil
|
101
|
-
|
102
|
-
query = [s,d].reject{|x|!x}.join("&")
|
103
|
-
query = "?#{query}" unless query == ""
|
104
|
-
baseurl = get_base_url() + '/avatar/'
|
105
|
-
return baseurl + id + query
|
106
137
|
end
|
107
138
|
|
108
|
-
private
|
109
|
-
|
110
139
|
def sanitize_srv_lookup(hostname, port)
|
111
|
-
unless hostname.match(/^[0-9a-zA-Z\-.]+$/) && 1 <= port && port <=
|
140
|
+
unless hostname.match(/^[0-9a-zA-Z\-.]+$/) && 1 <= port && port <= 65_535
|
112
141
|
return [nil, nil]
|
113
142
|
end
|
114
143
|
|
115
|
-
|
144
|
+
[hostname, port]
|
145
|
+
end
|
146
|
+
|
147
|
+
def normalize_email(email)
|
148
|
+
email.downcase
|
116
149
|
end
|
117
150
|
|
118
151
|
# Normalize an openid URL following the description on libravatar.org
|
119
|
-
def normalize_openid(
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
if
|
124
|
-
|
152
|
+
def normalize_openid(url)
|
153
|
+
parsed_url = URI.parse(url)
|
154
|
+
parsed_url.host = parsed_url.host.downcase
|
155
|
+
parsed_url.scheme = parsed_url.scheme.downcase
|
156
|
+
if parsed_url.path == '' && parsed_url.fragment.nil?
|
157
|
+
parsed_url.path = '/'
|
125
158
|
end
|
126
|
-
|
159
|
+
|
160
|
+
parsed_url.to_s
|
127
161
|
end
|
128
162
|
end
|
metadata
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vishnu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Smirnov
|
8
8
|
- Kang-min Liu
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-12-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: bundler
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
@@ -26,35 +26,21 @@ dependencies:
|
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: rspec
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - "
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: 1.2.3
|
35
|
-
type: :development
|
36
|
-
prerelease: false
|
37
|
-
version_requirements: !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - ">"
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: 1.2.3
|
42
|
-
- !ruby/object:Gem::Dependency
|
43
|
-
name: minitest
|
44
|
-
requirement: !ruby/object:Gem::Requirement
|
45
|
-
requirements:
|
46
|
-
- - '='
|
32
|
+
- - ">="
|
47
33
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
34
|
+
version: '0'
|
49
35
|
type: :development
|
50
36
|
prerelease: false
|
51
37
|
version_requirements: !ruby/object:Gem::Requirement
|
52
38
|
requirements:
|
53
|
-
- -
|
39
|
+
- - ">="
|
54
40
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
41
|
+
version: '0'
|
56
42
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
43
|
+
name: rake
|
58
44
|
requirement: !ruby/object:Gem::Requirement
|
59
45
|
requirements:
|
60
46
|
- - ">="
|
@@ -67,33 +53,23 @@ dependencies:
|
|
67
53
|
- - ">="
|
68
54
|
- !ruby/object:Gem::Version
|
69
55
|
version: '0'
|
70
|
-
description:
|
71
|
-
|
72
|
-
|
73
|
-
|
56
|
+
description: |
|
57
|
+
Libravatar provides avatar image hosting (like gravatar.com).
|
58
|
+
Their users may associate avatar images with email or openid.
|
59
|
+
This rubygem can be used to generate Libravatar image URL
|
60
|
+
email: sandfox+gem@sandfox.me
|
74
61
|
executables: []
|
75
62
|
extensions: []
|
76
|
-
extra_rdoc_files:
|
77
|
-
- LICENSE.txt
|
78
|
-
- README.rdoc
|
63
|
+
extra_rdoc_files: []
|
79
64
|
files:
|
80
|
-
- ".document"
|
81
|
-
- ".travis.yml"
|
82
|
-
- Gemfile
|
83
|
-
- LICENSE.txt
|
84
|
-
- README.rdoc
|
85
|
-
- Rakefile
|
86
|
-
- VERSION
|
87
65
|
- lib/libravatar.rb
|
88
66
|
- lib/vishnu.rb
|
89
|
-
-
|
90
|
-
|
91
|
-
- vishnu.gemspec
|
92
|
-
homepage: http://github.com/sandfoxme/vishnu
|
67
|
+
- lib/vishnu/version.rb
|
68
|
+
homepage: https://sandfox.dev/ruby/vishnu.html
|
93
69
|
licenses:
|
94
70
|
- MIT
|
95
71
|
metadata: {}
|
96
|
-
post_install_message:
|
72
|
+
post_install_message:
|
97
73
|
rdoc_options: []
|
98
74
|
require_paths:
|
99
75
|
- lib
|
@@ -101,16 +77,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
101
77
|
requirements:
|
102
78
|
- - ">="
|
103
79
|
- !ruby/object:Gem::Version
|
104
|
-
version:
|
80
|
+
version: 2.0.0
|
105
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
82
|
requirements:
|
107
83
|
- - ">="
|
108
84
|
- !ruby/object:Gem::Version
|
109
85
|
version: '0'
|
110
86
|
requirements: []
|
111
|
-
|
112
|
-
|
113
|
-
signing_key:
|
87
|
+
rubygems_version: 3.4.10
|
88
|
+
signing_key:
|
114
89
|
specification_version: 4
|
115
|
-
summary: Avatar URL Generation
|
90
|
+
summary: Avatar URL Generation with libravatar.org
|
116
91
|
test_files: []
|
data/.document
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
The MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2011 Kang-min Liu
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|
22
|
-
|
data/README.rdoc
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
= libravatar
|
2
|
-
|
3
|
-
http://libravatar.org is an avatar service to let their users associate avatar images
|
4
|
-
with their emails or openids. This rubygem generates their avatar URL.
|
5
|
-
|
6
|
-
== Contributing to libravatar
|
7
|
-
|
8
|
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
9
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
10
|
-
* Fork the project
|
11
|
-
* Start a feature/bugfix branch
|
12
|
-
* Commit and push until you are happy with your contribution
|
13
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
14
|
-
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
15
|
-
|
16
|
-
== Copyright
|
17
|
-
|
18
|
-
Copyright (c) 2011 Kang-min Liu. See LICENSE.txt for
|
19
|
-
further details.
|
20
|
-
|
data/Rakefile
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
|
4
|
-
require 'jeweler'
|
5
|
-
Jeweler::Tasks.new do |gem|
|
6
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
7
|
-
gem.name = "vishnu"
|
8
|
-
gem.homepage = "http://github.com/sandfoxme/vishnu"
|
9
|
-
gem.license = "MIT"
|
10
|
-
gem.summary = %Q{Avatar URL Generation wih libravatar.org}
|
11
|
-
gem.description = %Q{libravatar.org provides avatar image hosting (like gravatar.com). Their users may associate avatar images with email or openid. This rubygem can be used to generate libravatar avatar image URL}
|
12
|
-
gem.email = "sandfox@sandfox.me"
|
13
|
-
gem.authors = ['Anton Smirnov', "Kang-min Liu"]
|
14
|
-
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
15
|
-
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
16
|
-
# gem.add_runtime_dependency 'digest/sha2', '> 0.1'
|
17
|
-
# gem.add_runtime_dependency 'uri', '> 0.1'
|
18
|
-
# gem.add_development_dependency 'shoulda', '> 1.2.3'
|
19
|
-
end
|
20
|
-
Jeweler::RubygemsDotOrgTasks.new
|
21
|
-
|
22
|
-
require 'rake/testtask'
|
23
|
-
Rake::TestTask.new(:test) do |test|
|
24
|
-
test.libs << 'lib' << 'test'
|
25
|
-
test.pattern = 'test/**/test_*.rb'
|
26
|
-
test.verbose = true
|
27
|
-
end
|
28
|
-
|
29
|
-
task :default => :test
|
30
|
-
|
31
|
-
require 'rdoc/task'
|
32
|
-
Rake::RDocTask.new do |rdoc|
|
33
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
34
|
-
|
35
|
-
rdoc.rdoc_dir = 'rdoc'
|
36
|
-
rdoc.title = "vishnu #{version}"
|
37
|
-
rdoc.rdoc_files.include('README*')
|
38
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
39
|
-
end
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.2.2
|
data/test/helper.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'minitest/autorun'
|
3
|
-
require 'test/unit'
|
4
|
-
require 'shoulda'
|
5
|
-
|
6
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
7
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
8
|
-
require 'libravatar'
|
9
|
-
|
10
|
-
class Test::Unit::TestCase
|
11
|
-
end
|
data/test/test_libravatar.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
class TestLibravatar < Test::Unit::TestCase
|
4
|
-
should "Generate url from email" do
|
5
|
-
# echo -n "user@example.com"|md5sum
|
6
|
-
# => b58996c504c5638798eb6b511e6f49af
|
7
|
-
avatar = Libravatar.new(:email => "user@example.com")
|
8
|
-
|
9
|
-
re = /http:\/\/.+\/avatar\/b58996c504c5638798eb6b511e6f49af$/
|
10
|
-
assert avatar.to_s.match(re)
|
11
|
-
assert Libravatar.new(:email => "USER@ExAmPlE.CoM").to_s.match(re)
|
12
|
-
|
13
|
-
assert_equal Libravatar.new(:email => "user@example.com", :https => true).to_s[0,8], "https://"
|
14
|
-
assert_equal Libravatar.new(:email => "user@example.com", :https => false).to_s[0,7], "http://"
|
15
|
-
|
16
|
-
assert Libravatar.new(:email => "USER@ExAmPlE.CoM", :default => "http://example.com/avatar.png").to_s.match(/http:\/\/.+\/avatar\/b58996c504c5638798eb6b511e6f49af\?d=http:\/\/example\.com\/avatar\.png/)
|
17
|
-
|
18
|
-
assert_equal Libravatar.new(:email => "USER@ExAmPlE.CoM", :size => 512, :default => "mm").to_s[-43,43], "b58996c504c5638798eb6b511e6f49af?s=512&d=mm"
|
19
|
-
end
|
20
|
-
|
21
|
-
should "Generate url from openid" do
|
22
|
-
# echo -n "http://example.com/id/Bob"|shasum -a 256
|
23
|
-
# => 80cd0679bb52beac4d5d388c163016dbc5d3f30c262a4f539564236ca9d49ccd
|
24
|
-
avatar = Libravatar.new(:openid => "http://example.com/id/Bob")
|
25
|
-
assert_equal avatar.to_s, "http://cdn.libravatar.org/avatar/80cd0679bb52beac4d5d388c163016dbc5d3f30c262a4f539564236ca9d49ccd"
|
26
|
-
|
27
|
-
avatar = Libravatar.new(:openid => "hTTp://EXAMPLE.COM/id/Bob")
|
28
|
-
assert_equal avatar.to_s, "http://cdn.libravatar.org/avatar/80cd0679bb52beac4d5d388c163016dbc5d3f30c262a4f539564236ca9d49ccd"
|
29
|
-
|
30
|
-
avatar = Libravatar.new(:openid => "hTTp://EXAMPLE.COM/id/Bob", :size => 512)
|
31
|
-
assert_equal avatar.to_s, "http://cdn.libravatar.org/avatar/80cd0679bb52beac4d5d388c163016dbc5d3f30c262a4f539564236ca9d49ccd?s=512"
|
32
|
-
end
|
33
|
-
|
34
|
-
should "Normalize OpenID" do
|
35
|
-
x = Libravatar.new
|
36
|
-
assert_equal x.send(:normalize_openid, "HTTP://EXAMPLE.COM/id/Bob"), "http://example.com/id/Bob"
|
37
|
-
assert_equal x.send(:normalize_openid, "HTTP://EXAMPLE.COM"), "http://example.com/"
|
38
|
-
end
|
39
|
-
|
40
|
-
should "Return the federated URI" do
|
41
|
-
avatar = Libravatar.new(:email => 'invalid@catalyst.net.nz')
|
42
|
-
assert avatar.to_s.match(/http:\/\/.+\/avatar\/f924d1e9f2c10ee9efa7acdd16484c2f$/)
|
43
|
-
end
|
44
|
-
|
45
|
-
should "Sanitize the SRV lookup result" do
|
46
|
-
avatar = Libravatar.new
|
47
|
-
assert_equal ["hosntame.abcde.fghi.com", 12345], avatar.send(:sanitize_srv_lookup, "hosntame.abcde.fghi.com", 12345)
|
48
|
-
assert_equal [nil, nil], avatar.send(:sanitize_srv_lookup, "FNORD IMPUNTK *#(*$#&", 65348283)
|
49
|
-
end
|
50
|
-
end
|
data/vishnu.gemspec
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: vishnu 1.2.2 ruby lib
|
6
|
-
|
7
|
-
Gem::Specification.new do |s|
|
8
|
-
s.name = "vishnu"
|
9
|
-
s.version = "1.2.2"
|
10
|
-
|
11
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
-
s.require_paths = ["lib"]
|
13
|
-
s.authors = ["Anton Smirnov", "Kang-min Liu"]
|
14
|
-
s.date = "2016-06-20"
|
15
|
-
s.description = "libravatar.org provides avatar image hosting (like gravatar.com). Their users may associate avatar images with email or openid. This rubygem can be used to generate libravatar avatar image URL"
|
16
|
-
s.email = "sandfox@sandfox.me"
|
17
|
-
s.extra_rdoc_files = [
|
18
|
-
"LICENSE.txt",
|
19
|
-
"README.rdoc"
|
20
|
-
]
|
21
|
-
s.files = [
|
22
|
-
".document",
|
23
|
-
".travis.yml",
|
24
|
-
"Gemfile",
|
25
|
-
"LICENSE.txt",
|
26
|
-
"README.rdoc",
|
27
|
-
"Rakefile",
|
28
|
-
"VERSION",
|
29
|
-
"lib/libravatar.rb",
|
30
|
-
"lib/vishnu.rb",
|
31
|
-
"test/helper.rb",
|
32
|
-
"test/test_libravatar.rb",
|
33
|
-
"vishnu.gemspec"
|
34
|
-
]
|
35
|
-
s.homepage = "http://github.com/sandfoxme/vishnu"
|
36
|
-
s.licenses = ["MIT"]
|
37
|
-
s.rubygems_version = "2.5.1"
|
38
|
-
s.summary = "Avatar URL Generation wih libravatar.org"
|
39
|
-
|
40
|
-
if s.respond_to? :specification_version then
|
41
|
-
s.specification_version = 4
|
42
|
-
|
43
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
44
|
-
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
45
|
-
s.add_development_dependency(%q<shoulda>, ["> 1.2.3"])
|
46
|
-
s.add_development_dependency(%q<minitest>, ["= 4.7.5"])
|
47
|
-
s.add_development_dependency(%q<test-unit>, [">= 0"])
|
48
|
-
else
|
49
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
50
|
-
s.add_dependency(%q<shoulda>, ["> 1.2.3"])
|
51
|
-
s.add_dependency(%q<minitest>, ["= 4.7.5"])
|
52
|
-
s.add_dependency(%q<test-unit>, [">= 0"])
|
53
|
-
end
|
54
|
-
else
|
55
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
56
|
-
s.add_dependency(%q<shoulda>, ["> 1.2.3"])
|
57
|
-
s.add_dependency(%q<minitest>, ["= 4.7.5"])
|
58
|
-
s.add_dependency(%q<test-unit>, [">= 0"])
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|