gravatar 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/CHANGELOG +2 -0
  2. data/README +5 -0
  3. data/lib/gravatar.rb +30 -0
  4. metadata +49 -0
@@ -0,0 +1,2 @@
1
+ [1.0] 09.09.06
2
+ + Initial release
data/README ADDED
@@ -0,0 +1,5 @@
1
+ gravatar is a class to represent GRAVATAR[1] avatars.
2
+ by Seth Thomas Rasmussen
3
+ http://sethrasmussen.com
4
+
5
+ [1]: http://gravatar.com
@@ -0,0 +1,30 @@
1
+ require 'digest/md5'
2
+
3
+ class Gravatar
4
+ DefaultOptions = {:size => 80} # px
5
+
6
+ attr_accessor :id, :size, :rating, :border, :default, :url
7
+
8
+ def initialize(email = '', options = {})
9
+ options = DefaultOptions.merge(options)
10
+
11
+ @id = Digest::MD5.hexdigest(email)
12
+
13
+ @url = 'http://gravatar.com/avatar.php?gravatar_id=' + @id
14
+ options.each {|k,v| @url += "&#{k}=#{v}" unless v.nil?}
15
+
16
+ %w(size rating border default).each do |a|
17
+ instance_variable_set "@#{a}", options[a.to_sym]
18
+ end
19
+ end
20
+
21
+ def to_s; url; end
22
+ end
23
+
24
+ class Class
25
+ def gravatar(attr_name, o = {})
26
+ define_method :gravatar do
27
+ Gravatar.new(__send__(attr_name), Gravatar::DefaultOptions.update(o))
28
+ end
29
+ end
30
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.0
3
+ specification_version: 1
4
+ name: gravatar
5
+ version: !ruby/object:Gem::Version
6
+ version: "1.0"
7
+ date: 2006-09-17 00:00:00 -07:00
8
+ summary: gravatar is a class to represent GRAVATAR[http://gravatar.com] avatars. also features some hooks and misc other related goodies. by Seth Thomas Rasmussen
9
+ require_paths:
10
+ - lib
11
+ email: sethrasmussen@gmail.com
12
+ homepage: http://sethrasmussen.com
13
+ rubyforge_project:
14
+ description:
15
+ autorequire: gravatar
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Seth Thomas Rasmussen
31
+ files:
32
+ - lib/gravatar.rb
33
+ - README
34
+ - CHANGELOG
35
+ test_files: []
36
+
37
+ rdoc_options: []
38
+
39
+ extra_rdoc_files:
40
+ - README
41
+ - CHANGELOG
42
+ executables: []
43
+
44
+ extensions: []
45
+
46
+ requirements: []
47
+
48
+ dependencies: []
49
+