avatar 0.0.3 → 0.0.4

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.
@@ -1,3 +1,16 @@
1
+ == 0.0.4 2008-03-28
2
+ * 2 major fixes:
3
+ * GravatarSource downcases email to comply with Gravatar standards
4
+ * GravatarSource raises exception if passed a path instead of a URL for default
5
+
6
+ * 1 major enhancement:
7
+ * added RailsAssetSource
8
+
9
+ * 3 minor enhancements:
10
+ * added default_options to StringSubstitutionSource
11
+ * broke StringSubstitution out into a separate module
12
+ * added :any to GravatarSource::allowed_ratings
13
+
1
14
  == 0.0.3 2008-03-27
2
15
  * 2 minor fixes:
3
16
  * GravatarSource now takes parameter :gravatar_field instead of :field for compatibility with other sources
@@ -7,14 +7,17 @@ Rakefile
7
7
  config/hoe.rb
8
8
  config/requirements.rb
9
9
  lib/avatar.rb
10
+ lib/avatar/object_support.rb
10
11
  lib/avatar/source.rb
11
12
  lib/avatar/source/abstract_source.rb
12
13
  lib/avatar/source/file_column_source.rb
13
14
  lib/avatar/source/gravatar_source.rb
14
15
  lib/avatar/source/nil_source.rb
16
+ lib/avatar/source/rails_asset_source.rb
15
17
  lib/avatar/source/source_chain.rb
16
18
  lib/avatar/source/static_url_source.rb
17
19
  lib/avatar/source/string_substitution_source.rb
20
+ lib/avatar/string_substitution.rb
18
21
  lib/avatar/version.rb
19
22
  lib/avatar/view.rb
20
23
  lib/avatar/view/abstract_view_support.rb
@@ -63,8 +66,10 @@ test/test_file_column_source.rb
63
66
  test/test_gravatar_source.rb
64
67
  test/test_helper.rb
65
68
  test/test_nil_source.rb
69
+ test/test_rails_asset_source.rb
66
70
  test/test_source_chain.rb
67
71
  test/test_static_url_source.rb
72
+ test/test_string_substitution.rb
68
73
  test/test_string_substitution_source.rb
69
74
  website/index.html
70
75
  website/index.txt
@@ -1,8 +1,6 @@
1
1
  $:.unshift File.expand_path(File.dirname(__FILE__))
2
2
  require 'avatar/source/abstract_source'
3
3
  require 'avatar/source/gravatar_source'
4
- require 'avatar/source/static_url_source'
5
- require 'avatar/source/nil_source'
6
4
 
7
5
  # Helpers for displaying avatars.
8
6
  # Usage in Rails:
@@ -12,12 +10,10 @@ require 'avatar/source/nil_source'
12
10
  # # in app/views/profiles/show.html.erb:
13
11
  # <%= avatar_for @person =>
14
12
  #
15
- # By default, Avatar::source is a GravatarSource with
16
- # StaticUrlSource as its default.
17
- # The latter has the url '/images/default_avatar.png'.
13
+ # By default, Avatar::source is a GravatarSource
18
14
  module Avatar
19
15
 
20
- @@source = Avatar::Source::NilSource.new
16
+ @@source = Avatar::Source::GravatarSource.new
21
17
  @@default_avatar_options = {}
22
18
 
23
19
  def self.source
@@ -38,7 +34,4 @@ module Avatar
38
34
  @@options = options
39
35
  end
40
36
 
41
- end
42
-
43
- url_source = Avatar::Source::StaticUrlSource.new('/images/default_avatar.png')
44
- Avatar.source = Avatar::Source::GravatarSource.new(url_source)
37
+ end
@@ -0,0 +1,8 @@
1
+ unless Object.method_defined?(:returning)
2
+ Object.class_eval do
3
+ def returning(value)
4
+ yield(value)
5
+ value
6
+ end
7
+ end
8
+ end
@@ -1,12 +1,3 @@
1
- unless Object.method_defined?(:returning)
2
- Object.class_eval do
3
- def returning(value)
4
- yield(value)
5
- value
6
- end
7
- end
8
- end
9
-
10
1
  module Avatar # :nodoc:
11
2
  module Source # :nodoc:
12
3
  # To be included by classes that generate avatar URLs from profiles.
@@ -1,3 +1,4 @@
1
+ require 'avatar/object_support'
1
2
  require 'avatar/source/abstract_source'
2
3
  require 'avatar/source/static_url_source'
3
4
  require 'avatar/source/nil_source'
@@ -23,9 +24,9 @@ module Avatar # :nodoc:
23
24
  'http://www.gravatar.com/avatar/'
24
25
  end
25
26
 
26
- # ['G', 'PG', 'R', 'X']
27
+ # ['G', 'PG', 'R', 'X', 'any']
27
28
  def self.allowed_ratings
28
- ['G', 'PG', 'R', 'X']
29
+ ['G', 'PG', 'R', 'X', 'any']
29
30
  end
30
31
 
31
32
  # Arguments:
@@ -40,7 +41,7 @@ module Avatar # :nodoc:
40
41
  # Generates a Gravatar URL. Returns nil if person is nil.
41
42
  # Options:
42
43
  # * <code>:gravatar_field (Symbol)</code> - the field to call from person. By default, <code>:email</code>.
43
- # * <code>:default (String)</code> - override the default generated by <code>default_source</code>.
44
+ # * <code>:gravatar_default_url (String)</code> - override the default generated by <code>default_source</code>.
44
45
  # * <code>:gravatar_size or size or :s</code> - the size in pixels of the avatar to render.
45
46
  # * <code>:gravatar_rating or rating or :r</code> - the maximum rating; one of ['G', 'PG', 'R', 'X']
46
47
  def avatar_url_for(person, options = {})
@@ -49,8 +50,12 @@ module Avatar # :nodoc:
49
50
  field = options.delete(:gravatar_field)
50
51
  raise ArgumentError.new('No field specified; either specify a default field or pass in a value for :gravatar_field (probably :email)') unless field
51
52
 
53
+ email = person.send(field)
54
+ return nil if email.nil? || email.to_s.blank?
55
+ email = email.to_s.downcase
56
+
52
57
  returning(self.class.base_url) do |url|
53
- url << Digest::MD5::hexdigest(person.send(field)).strip
58
+ url << Digest::MD5::hexdigest(email).strip
54
59
  options.each do |k, v|
55
60
  next if v.nil?
56
61
  url << (url.include?('?') ? '&' : '?')
@@ -68,13 +73,15 @@ module Avatar # :nodoc:
68
73
  returning({}) do |result|
69
74
  result[:gravatar_field] = options[:gravatar_field] || default_field
70
75
 
71
- result[:default] = options[:default] || default_avatar_url_for(person, options)
76
+ default = options[:gravatar_default_url] || default_avatar_url_for(person, options)
77
+ raise "default must be a fully-qualified URL with port and host" unless self.class.valid_default_url?(default)
78
+ result[:default] = default
72
79
 
73
- size = options[:gravatar_size] || options[:size] || options[:s]
74
- result[:size] = size if size.to_s =~ /^\d*/
80
+ size = (options[:gravatar_size] || options[:size] || options[:s] || '').to_s.to_i
81
+ result[:size] = size if size > 0
75
82
 
76
83
  rating = options[:gravatar_rating] || options[:rating] || options[:r]
77
- result[:rating] = rating.upcase if rating and self.class.allowed_ratings.include?(rating.to_s)
84
+ result[:rating] = rating if rating and self.class.allowed_ratings.include?(rating.to_s)
78
85
  end
79
86
  end
80
87
 
@@ -93,6 +100,10 @@ module Avatar # :nodoc:
93
100
  raise ArgumentError.new("#{default} must be either a String or an instance of #{AbstractSource}")
94
101
  end
95
102
  end
103
+
104
+ def self.valid_default_url?(url)
105
+ url.nil? || url =~ /^http[s]?\:/
106
+ end
96
107
 
97
108
  private
98
109
 
@@ -0,0 +1,64 @@
1
+ require 'avatar/string_substitution'
2
+ require 'avatar/source/abstract_source'
3
+ require 'action_view/helpers/asset_tag_helper'
4
+
5
+ module Avatar # :nodoc:
6
+ module Source # :nodoc:
7
+ # Source representing a constant path. Allows string variable
8
+ # substitution (see link:classes/Avatar/StringSubstitution.html).
9
+ # Good as a default or last-resort source in Rails projects.
10
+ class RailsAssetSource
11
+ include StringSubstitution
12
+ include AbstractSource
13
+
14
+ attr_accessor :path
15
+ attr_accessor :default_options
16
+ attr_reader :url_helper
17
+
18
+ private :url_helper
19
+
20
+ # Create a new source with static path +path+.
21
+ # Raises an error unless +path+ exists.
22
+ # +default_options+ can include any variables
23
+ # to be substituted into +path+ as defaults.
24
+ # Additionally, it can contain the key :only_path,
25
+ # which determines whether a path or full URI is generated
26
+ # by default, :only_path is false.
27
+ def initialize(path, default_options = {})
28
+ raise ArgumentError.new("path cannot be nil") if path.nil?
29
+ self.path = path.to_s
30
+ self.default_options = { :only_path => false }.merge(default_options)
31
+ @url_helper = Object.new
32
+ @url_helper.extend(ActionView::Helpers::AssetTagHelper)
33
+ end
34
+
35
+ def only_path?
36
+ default_options[:default_path]
37
+ end
38
+
39
+ def default_options=(opts)
40
+ @default_options = opts || {}
41
+ end
42
+
43
+ # Returns nil if person is nil; the static path or URI otherwise.
44
+ # Options:
45
+ # * :only_path (Boolean) - whether to output only the path or a fully-qualified URI; defaults to object-level value
46
+ # Raises an error if both +options[:only_path]+ and the object-level default are both false
47
+ # and the url returned would only be a path. Try setting
48
+ # <code>ActionController::Base.asset_host</code> to avoid this error.
49
+ #
50
+ # Note: +only_path+ being true is not a guarantee
51
+ # that only a path will be generated; if it is false,
52
+ # however, generated URLs will be full URIs.
53
+ def avatar_url_for(person, options = {})
54
+ return nil if person.nil?
55
+ options = default_options.merge(options)
56
+ path = apply_substitution(self.path, options)
57
+ uri = url_helper.image_path(path)
58
+ raise "could not generate protocol and host for #{uri}" unless uri =~ /^http[s]?\:\/\// || options[:only_path]
59
+ substitution_needed?(uri) ? nil : uri
60
+ end
61
+
62
+ end
63
+ end
64
+ end
@@ -1,3 +1,4 @@
1
+ require 'avatar/string_substitution'
1
2
  require 'avatar/source/abstract_source'
2
3
 
3
4
  module Avatar # :nodoc:
@@ -8,19 +9,21 @@ module Avatar # :nodoc:
8
9
  # url = source.avatar_url_for(@person, :gender => :female, :size => :large)
9
10
  # # => 'female_icon_large.png'
10
11
  class StringSubstitutionSource
12
+ include StringSubstitution
11
13
  include AbstractSource
12
14
 
13
15
  attr_accessor :url
16
+ attr_accessor :default_options
14
17
 
15
18
  # Create a new source with static url +url+, which can contain any number
16
- # of variables to be subsituted through +options+. Strings should
17
- # be of the form '...#{variable_a}...#{variable_b}...'. <em>note the
18
- # single quotes</em>. Double quotes will cause the variables to be
19
- # substituted at Source-creation (when #new is called), which is almost
20
- # certainly <strong>not</strong> what you want.
21
- def initialize(url)
19
+ # of variables to be subsituted through +options+. See link:classes/Avatar/StringSubstitution.html
20
+ #
21
+ # Optionally, can pass in +default _options+ to be applied in replacement, overwritable
22
+ # by the +options+ passed to :avatar_url_for.
23
+ def initialize(url, default_options = {})
22
24
  raise ArgumentError.new("URL cannot be nil") if url.nil?
23
- @url = url.to_s
25
+ self.url = url.to_s
26
+ self.default_options = default_options || {}
24
27
  end
25
28
 
26
29
  # Returns nil if +person+ is nil or if variables in <code>url</code>
@@ -29,18 +32,12 @@ module Avatar # :nodoc:
29
32
  # with the value of the corresponding key within +options+.
30
33
  def avatar_url_for(person, options = {})
31
34
  return nil if person.nil?
32
- result = apply_replacement(options)
33
- result =~ /#\{.*\}/ ? nil : result
35
+ result = apply_substitution(self.url, self.default_options.merge(options))
36
+ substitution_needed?(result) ? nil : result
34
37
  end
35
38
 
36
- private
37
-
38
- def apply_replacement(options)
39
- result = self.url
40
- options.each do |k,v|
41
- result = result.gsub(Regexp.new('#\{' + "#{k}" + '\}'), "#{v}")
42
- end
43
- result
39
+ def default_options=(opts)
40
+ @default_options = opts || {}
44
41
  end
45
42
 
46
43
  end
@@ -0,0 +1,28 @@
1
+ require 'avatar/object_support'
2
+
3
+ module Avatar # :nodoc:
4
+
5
+ # Allows runtime variable substitution into a String.
6
+ module StringSubstitution
7
+
8
+ # For each key in +options+ replaces '#{key}' in +string+ with the
9
+ # corresponding value in +options+.
10
+ # +string+ should
11
+ # be of the form '...#{variable_a}...#{variable_b}...'. <em>Note the
12
+ # single quotes</em>. Double quotes will cause the variables to be
13
+ # substituted before this method is run, which is almost
14
+ # certainly <strong>not</strong> what you want.
15
+ def apply_substitution(string, options)
16
+ returning(string.dup) do |result|
17
+ options.each do |k,v|
18
+ result.gsub!(Regexp.new('#\{' + "#{k}" + '\}'), "#{v}")
19
+ end
20
+ end
21
+ end
22
+
23
+ def substitution_needed?(string)
24
+ string =~ /#\{.*\}/
25
+ end
26
+
27
+ end
28
+ end
@@ -2,7 +2,7 @@ module Avatar #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 3
5
+ TINY = 4
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -20,35 +20,45 @@ class TestGravatarSource < Test::Unit::TestCase
20
20
  end
21
21
 
22
22
  def test_field
23
- name_hash = Digest::MD5::hexdigest(@gary.name)
23
+ name_hash = Digest::MD5::hexdigest(@gary.name.downcase)
24
24
  assert_equal "http://www.gravatar.com/avatar/#{name_hash}", @source.avatar_url_for(@gary, :gravatar_field => :name)
25
25
  end
26
26
 
27
27
  def test_site_wide_default_string
28
- @source.default_source = 'fazbot'
29
- assert_equal "http://www.gravatar.com/avatar/#{@email_hash}?default=fazbot", @source.avatar_url_for(@gary)
28
+ @source.default_source = 'http://fazbot.com'
29
+ assert_equal "http://www.gravatar.com/avatar/#{@email_hash}?default=http://fazbot.com", @source.avatar_url_for(@gary)
30
30
  end
31
31
 
32
32
  def test_site_wide_default_source
33
- @source.default_source = Avatar::Source::StaticUrlSource.new('funky')
34
- assert_equal "http://www.gravatar.com/avatar/#{@email_hash}?default=funky", @source.avatar_url_for(@gary)
33
+ @source.default_source = Avatar::Source::StaticUrlSource.new('http://funky.com')
34
+ assert_equal "http://www.gravatar.com/avatar/#{@email_hash}?default=http://funky.com", @source.avatar_url_for(@gary)
35
35
  end
36
36
 
37
37
  def test_site_wide_default_nil
38
- @source.default_source = Avatar::Source::StaticUrlSource.new('plumb')
38
+ @source.default_source = Avatar::Source::StaticUrlSource.new('http://plumb.com')
39
39
  @source.default_source = nil
40
40
  assert_equal "http://www.gravatar.com/avatar/#{@email_hash}", @source.avatar_url_for(@gary)
41
41
  end
42
42
 
43
43
  def test_default_override
44
44
  @source.default_source = Avatar::Source::StaticUrlSource.new('does it really matter?')
45
- assert_equal "http://www.gravatar.com/avatar/#{@email_hash}?default=gonzo", @source.avatar_url_for(@gary, :default => 'gonzo')
45
+ assert_equal "http://www.gravatar.com/avatar/#{@email_hash}?default=http://gonzo.com", @source.avatar_url_for(@gary, :gravatar_default_url => 'http://gonzo.com')
46
+ end
47
+
48
+ def test_raises_error_if_default_only_path
49
+ assert_raises(RuntimeError) {
50
+ @source.avatar_url_for(@gary, :gravatar_default_url => 'foo')
51
+ }
46
52
  end
47
53
 
48
54
  def test_size
49
55
  assert_equal "http://www.gravatar.com/avatar/#{@email_hash}?size=70", @source.avatar_url_for(@gary, :gravatar_size => 70)
50
56
  assert_equal "http://www.gravatar.com/avatar/#{@email_hash}?size=109", @source.avatar_url_for(@gary, :size => 109)
51
- assert_equal "http://www.gravatar.com/avatar/#{@email_hash}?size=62", @source.avatar_url_for(@gary, :s => 62)
57
+ assert_equal "http://www.gravatar.com/avatar/#{@email_hash}?size=62", @source.avatar_url_for(@gary, :s => '62x62')
58
+ end
59
+
60
+ def test_invalid_size_does_not_pass_through
61
+ assert_equal "http://www.gravatar.com/avatar/#{@email_hash}", @source.avatar_url_for(@gary, :s => :small)
52
62
  end
53
63
 
54
64
  def test_rating
@@ -57,4 +67,8 @@ class TestGravatarSource < Test::Unit::TestCase
57
67
  assert_equal "http://www.gravatar.com/avatar/#{@email_hash}?rating=PG", @source.avatar_url_for(@gary, :r => 'PG')
58
68
  end
59
69
 
70
+ def test_invalid_rating_does_not_pass_through
71
+ assert_equal "http://www.gravatar.com/avatar/#{@email_hash}", @source.avatar_url_for(@gary, :r => 'EVIL')
72
+ end
73
+
60
74
  end
@@ -0,0 +1,50 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+ require 'avatar/source/rails_asset_source'
3
+ require 'action_controller/base'
4
+
5
+ class TestRailsAssetSource < Test::Unit::TestCase
6
+
7
+ def setup
8
+ ActionController::Base.asset_host = 'http://test.com'
9
+ end
10
+
11
+ def test_fully_qualified_uri
12
+ source = Avatar::Source::RailsAssetSource.new('http://example.com/images/avatar.png')
13
+ assert_equal 'http://example.com/images/avatar.png', source.avatar_url_for(3)
14
+ end
15
+
16
+ def test_string_substitution
17
+ source = Avatar::Source::RailsAssetSource.new('http://example.com/images/avatar_#{size}.png')
18
+ assert_equal 'http://example.com/images/avatar_huge.png', source.avatar_url_for(4, {:size => 'huge'})
19
+ end
20
+
21
+ def test_uses_asset_host
22
+ source = Avatar::Source::RailsAssetSource.new('/images/avatar.png')
23
+ assert_equal 'http://test.com/images/avatar.png', source.avatar_url_for(4)
24
+ end
25
+
26
+ def test_error_if_cannot_generate_full_uri_and_only_path_false
27
+ ActionController::Base.asset_host = ''
28
+ source = Avatar::Source::RailsAssetSource.new('/images/avatar.png')
29
+ assert_raise(RuntimeError) {
30
+ source.avatar_url_for(4)
31
+ }
32
+ end
33
+
34
+ def test_no_error_if_cannot_generate_full_uri_and_only_path_true
35
+ ActionController::Base.asset_host = ''
36
+ source = Avatar::Source::RailsAssetSource.new('/images/avatar.png')
37
+ assert_equal '/images/avatar.png', source.avatar_url_for(12, :only_path => true)
38
+ end
39
+
40
+ def test_no_url_generated_if_person_is_nil
41
+ source = Avatar::Source::RailsAssetSource.new('/images/avatar.png')
42
+ assert_nil source.avatar_url_for(nil)
43
+ end
44
+
45
+ def test_no_url_generated_if_substitution_incomplete
46
+ source = Avatar::Source::RailsAssetSource.new('/images/avatar_#{size}.png')
47
+ assert_nil source.avatar_url_for(8)
48
+ end
49
+
50
+ end
@@ -0,0 +1,28 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+ require 'avatar/string_substitution'
3
+
4
+ class TestStringSubstitution < Test::Unit::TestCase
5
+
6
+ def setup
7
+ @foo = Object.new
8
+ @foo.extend Avatar::StringSubstitution
9
+ @string = 'I don\'t like #{a}, #{b}, or #{c}'
10
+ end
11
+
12
+ def test_apply_complete_substitution
13
+ assert_equal "I don't like Detroit, jam, or the letter e", @foo.apply_substitution(@string, {:a => 'Detroit', :b => 'jam', :c => 'the letter e'})
14
+ end
15
+
16
+ def test_apply_incomplete_substitution
17
+ assert_equal 'I don\'t like #{a}, jam, or #{c}', @foo.apply_substitution(@string, {:b => 'jam'})
18
+ end
19
+
20
+ def test_substitution_not_needed
21
+ assert !@foo.substitution_needed?('foo # bar { baz }# { yoo}')
22
+ end
23
+
24
+ def test_substitution_needed
25
+ assert @foo.substitution_needed?('foo #{bar} #{baz}')
26
+ end
27
+
28
+ end
@@ -33,7 +33,7 @@
33
33
  <h1>Avatar</h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/avatar"; return false'>
35
35
  <p>Get Version</p>
36
- <a href="http://rubyforge.org/projects/avatar" class="numbers">0.0.3</a>
36
+ <a href="http://rubyforge.org/projects/avatar" class="numbers">0.0.4</a>
37
37
  </div>
38
38
  <h1>&#x2192; &#8216;Avatar&#8217;</h1>
39
39
 
@@ -45,27 +45,28 @@ support for avatars</h2>
45
45
  <h2>Installing</h2>
46
46
 
47
47
 
48
- <p><pre class='syntax'><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">avatar</span></pre></p>
48
+ <p><pre class='syntax'>sudo gem install avatar</pre></p>
49
49
 
50
50
 
51
51
  <h2>The basics
52
- Set up Avatar::source (by default, a Gravatar with a StaticUrl as the default)</h2>
52
+ Set up Avatar::source (by default, a Gravatar)
53
+ Use Avatar::source.avatar_url_for(person, options) or a view helper</h2>
53
54
 
54
55
 
55
56
  <h2>Demonstration of usage</h2>
56
57
 
57
58
 
58
- app/helpers/people_helper.rb:
59
- <pre><code class='ruby'>
60
- class PeopleHelper
61
- include Avatar::View::ActionViewSupport
62
- end
63
- </code></pre>
59
+ <p>app/helpers/people_helper.rb:
60
+ <pre class='syntax'><span class="keyword">class </span><span class="class">PeopleHelper</span>
61
+ <span class="ident">include</span> <span class="constant">Avatar</span><span class="punct">::</span><span class="constant">View</span><span class="punct">::</span><span class="constant">ActionViewSupport</span>
62
+ <span class="keyword">end</span>
63
+ </pre></p>
64
+
65
+
66
+ <p>app/views/people/show.html.erb:
67
+ <pre class='syntax'><span class="punct">&lt;%=</span><span class="string"> avatar_tag(@current_user, :size </span><span class="punct">=&gt;</span> <span class="number">40</span><span class="punct">)</span> <span class="punct">%&gt;</span><span class="string"><span class="normal">
68
+ </span></span></pre></p>
64
69
 
65
- app/views/people/show.html.erb:
66
- <pre><code class='ruby erb'>
67
- &lt;%= avatar_tag(@current_user, :size =&gt; 40) %&gt;
68
- </code></pre>
69
70
 
70
71
  <h2>Forum</h2>
71
72
 
@@ -93,7 +94,7 @@ app/views/people/show.html.erb:
93
94
 
94
95
  <p>Comments are welcome. Put them on the <a href="http://groups.google.com/group/ruby-avatar">forum</a></p>
95
96
  <p class="coda">
96
- <a href="FIXME email">FIXME full name</a>, 27th March 2008<br>
97
+ <a href="FIXME email">FIXME full name</a>, 28th March 2008<br>
97
98
  Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
98
99
  </p>
99
100
  </div>
@@ -8,25 +8,24 @@ support for avatars
8
8
 
9
9
  h2. Installing
10
10
 
11
- <pre syntax="ruby">sudo gem install avatar</pre>
11
+ <pre syntax="bsd">sudo gem install avatar</pre>
12
12
 
13
13
  h2. The basics
14
- Set up Avatar::source (by default, a Gravatar with a StaticUrl as the default)
14
+ Set up Avatar::source (by default, a Gravatar)
15
+ Use Avatar::source.avatar_url_for(person, options) or a view helper
15
16
 
16
17
 
17
18
  h2. Demonstration of usage
18
19
 
19
20
  app/helpers/people_helper.rb:
20
- <pre><code class='ruby'>
21
- class PeopleHelper
21
+ <pre syntax='ruby'>class PeopleHelper
22
22
  include Avatar::View::ActionViewSupport
23
23
  end
24
- </code></pre>
24
+ </pre>
25
25
 
26
26
  app/views/people/show.html.erb:
27
- <pre><code class='ruby erb'>
28
- <%= avatar_tag(@current_user, :size => 40) %>
29
- </code></pre>
27
+ <pre syntax='ruby'><%= avatar_tag(@current_user, :size => 40) %>
28
+ </pre>
30
29
 
31
30
 
32
31
  h2. Forum
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avatar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Rosen
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-03-27 00:00:00 -04:00
12
+ date: 2008-03-28 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -36,14 +36,17 @@ files:
36
36
  - config/hoe.rb
37
37
  - config/requirements.rb
38
38
  - lib/avatar.rb
39
+ - lib/avatar/object_support.rb
39
40
  - lib/avatar/source.rb
40
41
  - lib/avatar/source/abstract_source.rb
41
42
  - lib/avatar/source/file_column_source.rb
42
43
  - lib/avatar/source/gravatar_source.rb
43
44
  - lib/avatar/source/nil_source.rb
45
+ - lib/avatar/source/rails_asset_source.rb
44
46
  - lib/avatar/source/source_chain.rb
45
47
  - lib/avatar/source/static_url_source.rb
46
48
  - lib/avatar/source/string_substitution_source.rb
49
+ - lib/avatar/string_substitution.rb
47
50
  - lib/avatar/version.rb
48
51
  - lib/avatar/view.rb
49
52
  - lib/avatar/view/abstract_view_support.rb
@@ -92,8 +95,10 @@ files:
92
95
  - test/test_gravatar_source.rb
93
96
  - test/test_helper.rb
94
97
  - test/test_nil_source.rb
98
+ - test/test_rails_asset_source.rb
95
99
  - test/test_source_chain.rb
96
100
  - test/test_static_url_source.rb
101
+ - test/test_string_substitution.rb
97
102
  - test/test_string_substitution_source.rb
98
103
  - website/index.html
99
104
  - website/index.txt
@@ -136,6 +141,8 @@ test_files:
136
141
  - test/test_gravatar_source.rb
137
142
  - test/test_helper.rb
138
143
  - test/test_nil_source.rb
144
+ - test/test_rails_asset_source.rb
139
145
  - test/test_source_chain.rb
140
146
  - test/test_static_url_source.rb
147
+ - test/test_string_substitution.rb
141
148
  - test/test_string_substitution_source.rb