avatar 0.0.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +7 -0
- data/{README.txt → README.rdoc} +12 -4
- data/init.rb +5 -0
- data/lib/avatar.rb +3 -2
- data/lib/avatar/source/pavatar_source.rb +109 -0
- data/lib/avatar/source/wrapper/rails_asset_source_wrapper.rb +3 -1
- data/lib/avatar/version.rb +2 -2
- data/rails/init.rb +1 -0
- metadata +28 -125
- data/.gitignore +0 -8
- data/Manifest.txt +0 -104
- data/Rakefile +0 -10
- data/config/hoe.rb +0 -70
- data/config/requirements.rb +0 -17
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/script/txt2html +0 -74
- data/setup.rb +0 -1585
- data/tasks/deployment.rake +0 -34
- data/tasks/environment.rake +0 -7
- data/tasks/testing.rake +0 -37
- data/tasks/website.rake +0 -17
- data/test/.gitignore +0 -3
- data/test/lib/database.rb +0 -2
- data/test/lib/database.yml +0 -10
- data/test/lib/file_column/CHANGELOG +0 -69
- data/test/lib/file_column/README +0 -54
- data/test/lib/file_column/Rakefile +0 -36
- data/test/lib/file_column/TODO +0 -6
- data/test/lib/file_column/init.rb +0 -13
- data/test/lib/file_column/lib/file_column.rb +0 -720
- data/test/lib/file_column/lib/file_column_helper.rb +0 -150
- data/test/lib/file_column/lib/file_compat.rb +0 -28
- data/test/lib/file_column/lib/magick_file_column.rb +0 -260
- data/test/lib/file_column/lib/rails_file_column.rb +0 -19
- data/test/lib/file_column/lib/test_case.rb +0 -124
- data/test/lib/file_column/lib/validations.rb +0 -112
- data/test/lib/file_column/test/abstract_unit.rb +0 -63
- data/test/lib/file_column/test/connection.rb +0 -17
- data/test/lib/file_column/test/file_column_helper_test.rb +0 -97
- data/test/lib/file_column/test/file_column_test.rb +0 -650
- data/test/lib/file_column/test/fixtures/entry.rb +0 -32
- data/test/lib/file_column/test/fixtures/invalid-image.jpg +0 -1
- data/test/lib/file_column/test/fixtures/kerb.jpg +0 -0
- data/test/lib/file_column/test/fixtures/mysql.sql +0 -25
- data/test/lib/file_column/test/fixtures/schema.rb +0 -10
- data/test/lib/file_column/test/fixtures/skanthak.png +0 -0
- data/test/lib/file_column/test/magick_test.rb +0 -380
- data/test/lib/file_column/test/magick_view_only_test.rb +0 -21
- data/test/lib/paperclip/README +0 -32
- data/test/lib/paperclip/Rakefile +0 -41
- data/test/lib/paperclip/generators/paperclip/USAGE +0 -5
- data/test/lib/paperclip/generators/paperclip/paperclip_generator.rb +0 -27
- data/test/lib/paperclip/generators/paperclip/templates/paperclip_migration.rb +0 -17
- data/test/lib/paperclip/init.rb +0 -3
- data/test/lib/paperclip/lib/paperclip.rb +0 -197
- data/test/lib/paperclip/lib/paperclip/attachment.rb +0 -230
- data/test/lib/paperclip/lib/paperclip/geometry.rb +0 -109
- data/test/lib/paperclip/lib/paperclip/iostream.rb +0 -43
- data/test/lib/paperclip/lib/paperclip/thumbnail.rb +0 -80
- data/test/lib/paperclip/lib/paperclip/upfile.rb +0 -32
- data/test/lib/paperclip/tasks/paperclip_tasks.rake +0 -38
- data/test/lib/paperclip/test/database.yml +0 -5
- data/test/lib/paperclip/test/fixtures/12k.png +0 -0
- data/test/lib/paperclip/test/fixtures/5k.png +0 -0
- data/test/lib/paperclip/test/fixtures/bad.png +0 -1
- data/test/lib/paperclip/test/helper.rb +0 -38
- data/test/lib/paperclip/test/test_attachment.rb +0 -99
- data/test/lib/paperclip/test/test_geometry.rb +0 -142
- data/test/lib/paperclip/test/test_integration.rb +0 -76
- data/test/lib/paperclip/test/test_iostream.rb +0 -60
- data/test/lib/paperclip/test/test_paperclip.rb +0 -83
- data/test/lib/paperclip/test/test_thumbnail.rb +0 -76
- data/test/lib/schema.rb +0 -20
- data/test/lib/user_suit.png +0 -0
- data/test/test_abstract_view_support.rb +0 -22
- data/test/test_action_view_support.rb +0 -30
- data/test/test_avatar.rb +0 -12
- data/test/test_file_column_source.rb +0 -38
- data/test/test_gravatar_source.rb +0 -79
- data/test/test_helper.rb +0 -27
- data/test/test_nil_source.rb +0 -18
- data/test/test_paperclip_source.rb +0 -52
- data/test/test_rails_asset_source_wrapper.rb +0 -37
- data/test/test_source_chain.rb +0 -44
- data/test/test_static_url_source.rb +0 -18
- data/test/test_string_substitution_source_wrapper.rb +0 -25
- data/website/index.html +0 -105
- data/website/index.txt +0 -48
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -138
- data/website/template.rhtml +0 -48
data/test/lib/user_suit.png
DELETED
Binary file
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
-
require 'avatar/view/abstract_view_support'
|
3
|
-
require 'avatar/source/static_url_source'
|
4
|
-
|
5
|
-
class TestAbstractViewSupport < Test::Unit::TestCase
|
6
|
-
|
7
|
-
def setup
|
8
|
-
Avatar::source = Avatar::Source::StaticUrlSource.new('golfing.png')
|
9
|
-
@view_class = Class.new
|
10
|
-
@view_class.send :include, Avatar::View::AbstractViewSupport
|
11
|
-
@view = @view_class.new
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_includes_basic_view_support
|
15
|
-
assert @view.kind_of?(Avatar::View::AbstractViewSupport)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_avatar_url_for_with_no_arguments
|
19
|
-
assert_equal 'golfing.png', @view.avatar_url_for(:a_person)
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
-
require 'avatar/view/action_view_support'
|
3
|
-
require 'avatar/source/static_url_source'
|
4
|
-
|
5
|
-
class TestActionViewSupport < Test::Unit::TestCase
|
6
|
-
|
7
|
-
def setup
|
8
|
-
Avatar::source = Avatar::Source::StaticUrlSource.new('i-am-oscar-wilde.png')
|
9
|
-
@view_class = Class.new(ActionView::Base)
|
10
|
-
@view_class.send :include, Avatar::View::ActionViewSupport
|
11
|
-
@view = @view_class.new
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_includes_basic_view_support
|
15
|
-
assert @view.kind_of?(Avatar::View::AbstractViewSupport)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_avatar_tag_empty_if_person_is_nil
|
19
|
-
assert_equal "", @view.avatar_tag(nil)
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_avatar_tag_with_no_options
|
23
|
-
assert_equal "<img alt=\"I-am-oscar-wilde\" src=\"/images/i-am-oscar-wilde.png\" />", @view.avatar_tag(:a_person)
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_avatar_tag_with_html_options
|
27
|
-
assert_equal "<img alt=\"I-am-oscar-wilde\" class=\"avatar\" src=\"/images/i-am-oscar-wilde.png\" />", @view.avatar_tag(:a_person, {}, {:class => :avatar})
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
data/test/test_avatar.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
-
|
3
|
-
class TestAvatar < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
end
|
7
|
-
|
8
|
-
def test_load_path_includes_avatar_lib
|
9
|
-
lib_path = File.expand_path(File.join(File.dirname(__FILE__), ['..', 'lib']))
|
10
|
-
assert $:.include?(lib_path)
|
11
|
-
end
|
12
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
$: << File.expand_path(File.join(File.dirname(__FILE__), ['lib', 'file_column', 'lib']))
|
2
|
-
require File.join(File.dirname(__FILE__), 'test_helper.rb')
|
3
|
-
require File.join(File.dirname(__FILE__), ['lib', 'file_column', 'init'])
|
4
|
-
require 'file_column'
|
5
|
-
require 'avatar/source/file_column_source'
|
6
|
-
|
7
|
-
class FileColumnUser < ActiveRecord::Base
|
8
|
-
file_column :avatar
|
9
|
-
file_column :icon
|
10
|
-
end
|
11
|
-
|
12
|
-
class TestFileColumnSource < Test::Unit::TestCase
|
13
|
-
|
14
|
-
def setup
|
15
|
-
@source = Avatar::Source::FileColumnSource.new
|
16
|
-
png = File.new(File.join(File.dirname(__FILE__), ['lib', 'user_suit.png']))
|
17
|
-
@user_with_avatar = FileColumnUser.create!(:email => 'joe@example.com', :avatar => png)
|
18
|
-
@user_with_icon = FileColumnUser.create!(:email => 'terry@example.com', :icon => png)
|
19
|
-
@user_without_avatar = FileColumnUser.create!(:email => 'sue@example.com')
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_avatar_url_is_nil_if_person_is_nil
|
23
|
-
assert_nil @source.avatar_url_for(nil)
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_avatar_url_is_nil_if_person_has_no_avatar
|
27
|
-
assert_nil @source.avatar_url_for(@user_without_avatar)
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_avatar_url_for_person_with_avatar
|
31
|
-
assert_equal "/file_column_user/avatar/#{@user_with_avatar.id}/0/user_suit.png", @source.avatar_url_for(@user_with_avatar)
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_avatar_url_for_person_with_icon_and_custom_file_column_field
|
35
|
-
assert_equal "/file_column_user/icon/#{@user_with_icon.id}/0/user_suit.png", @source.avatar_url_for(@user_with_icon, :file_column_field => :icon)
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
-
require 'avatar/source/gravatar_source'
|
3
|
-
require 'avatar/source/static_url_source'
|
4
|
-
require 'digest/md5'
|
5
|
-
|
6
|
-
class TestGravatarSource < Test::Unit::TestCase
|
7
|
-
|
8
|
-
def setup
|
9
|
-
@source = Avatar::Source::GravatarSource.new
|
10
|
-
@gary = Person.new('gary@example.com', 'Gary Glumph')
|
11
|
-
@email_hash = Digest::MD5::hexdigest(@gary.email)
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_nil_when_person_is_nil
|
15
|
-
assert_nil @source.avatar_url_for(nil)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_not_nil_when_person_is_not_nil
|
19
|
-
assert_equal "http://www.gravatar.com/avatar/#{@email_hash}", @source.avatar_url_for(@gary)
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_field
|
23
|
-
name_hash = Digest::MD5::hexdigest(@gary.name.downcase)
|
24
|
-
assert_equal "http://www.gravatar.com/avatar/#{name_hash}", @source.avatar_url_for(@gary, :gravatar_field => :name)
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_site_wide_default_string
|
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
|
-
end
|
31
|
-
|
32
|
-
def test_site_wide_default_source
|
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
|
-
end
|
36
|
-
|
37
|
-
def test_site_wide_default_nil
|
38
|
-
@source.default_source = Avatar::Source::StaticUrlSource.new('http://plumb.com')
|
39
|
-
@source.default_source = nil
|
40
|
-
assert_equal "http://www.gravatar.com/avatar/#{@email_hash}", @source.avatar_url_for(@gary)
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_default_override
|
44
|
-
@source.default_source = Avatar::Source::StaticUrlSource.new('does it really matter?')
|
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
|
-
}
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_size
|
55
|
-
assert_equal "http://www.gravatar.com/avatar/#{@email_hash}?size=70", @source.avatar_url_for(@gary, :gravatar_size => 70)
|
56
|
-
assert_equal "http://www.gravatar.com/avatar/#{@email_hash}?size=109", @source.avatar_url_for(@gary, :size => 109)
|
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)
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_rating
|
65
|
-
assert_equal "http://www.gravatar.com/avatar/#{@email_hash}?rating=G", @source.avatar_url_for(@gary, :gravatar_rating => 'G')
|
66
|
-
assert_equal "http://www.gravatar.com/avatar/#{@email_hash}?rating=R", @source.avatar_url_for(@gary, :rating => 'R')
|
67
|
-
assert_equal "http://www.gravatar.com/avatar/#{@email_hash}?rating=PG", @source.avatar_url_for(@gary, :r => 'PG')
|
68
|
-
end
|
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
|
-
|
74
|
-
def test_default_always_at_end
|
75
|
-
assert_equal "http://www.gravatar.com/avatar/#{@email_hash}?rating=any&default=http://gonzo.com", @source.avatar_url_for(@gary, :gravatar_rating => :any, :gravatar_default_url => 'http://gonzo.com')
|
76
|
-
assert_equal "http://www.gravatar.com/avatar/#{@email_hash}?size=110&default=http://gonzo.com", @source.avatar_url_for(@gary, :gravatar_size => 110, :gravatar_default_url => 'http://gonzo.com')
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# for Rails-specific tests:
|
2
|
-
RAILS_ROOT = "#{File.dirname(__FILE__)}" unless defined?(RAILS_ROOT)
|
3
|
-
RAILS_ENV = 'test' unless defined?(RAILS_ENV)
|
4
|
-
require 'test/unit'
|
5
|
-
require 'rubygems'
|
6
|
-
require 'active_record'
|
7
|
-
require 'active_support'
|
8
|
-
require 'action_controller'
|
9
|
-
require 'action_view'
|
10
|
-
|
11
|
-
#$: << File.expand_path(File.join(File.dirname(__FILE__), ['lib', 'file_column', 'lib']))
|
12
|
-
#$: << File.expand_path(File.join(File.dirname(__FILE__), ['lib', 'paperclip', 'lib']))
|
13
|
-
|
14
|
-
#require File.join(File.dirname(__FILE__), ['lib', 'file_column', 'init'])
|
15
|
-
#require File.join(File.dirname(__FILE__), ['lib', 'paperclip', 'init'])
|
16
|
-
|
17
|
-
require File.join(File.dirname(__FILE__), ['lib', 'database'])
|
18
|
-
require File.join(File.dirname(__FILE__), ['lib', 'schema'])
|
19
|
-
require File.join(File.dirname(__FILE__), ['..', 'lib', 'avatar'])
|
20
|
-
|
21
|
-
class Person
|
22
|
-
attr_accessor :email, :name
|
23
|
-
def initialize(email, name = nil)
|
24
|
-
@email = email
|
25
|
-
@name = name || email
|
26
|
-
end
|
27
|
-
end
|
data/test/test_nil_source.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
-
require 'avatar/source/nil_source'
|
3
|
-
|
4
|
-
class TestNilSource < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@source = Avatar::Source::NilSource.new
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_nil_when_person_is_nil
|
11
|
-
assert_nil @source.avatar_url_for(nil)
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_nil_when_person_is_not_nil
|
15
|
-
assert_nil @source.avatar_url_for(49329)
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
$: << File.expand_path(File.join(File.dirname(__FILE__), ['lib', 'paperclip', 'lib']))
|
2
|
-
require File.join(File.dirname(__FILE__), 'test_helper.rb')
|
3
|
-
require File.join(File.dirname(__FILE__), ['lib', 'paperclip', 'init'])
|
4
|
-
require 'avatar/source/paperclip_source'
|
5
|
-
|
6
|
-
class PaperclipUser < ActiveRecord::Base
|
7
|
-
has_attached_file :avatar,
|
8
|
-
:styles => { :medium => "300x300>",
|
9
|
-
:thumb => "100x100>" },
|
10
|
-
:default_style => :medium,
|
11
|
-
:path => ":rails_root/public/images/:class/:id/:attachment/:style/:basename.:extension",
|
12
|
-
:url => "/images/:class/:id/:attachment/:style/:basename.:extension"
|
13
|
-
|
14
|
-
has_attached_file :icon,
|
15
|
-
:styles => { :small => "80x80" },
|
16
|
-
:default_style => :small,
|
17
|
-
:path => ":rails_root/public/images/:class/:id/:attachment/:style/:basename.:extension",
|
18
|
-
:url => "/images/:class/:id/:attachment/:style/:basename.:extension"
|
19
|
-
end
|
20
|
-
|
21
|
-
class TestPaperclipSource < Test::Unit::TestCase
|
22
|
-
|
23
|
-
def setup
|
24
|
-
@source = Avatar::Source::PaperclipSource.new
|
25
|
-
png = File.new(File.join(File.dirname(__FILE__), ['lib', 'user_suit.png']))
|
26
|
-
assert File.exists?(png.path)
|
27
|
-
@user_with_avatar = PaperclipUser.create!(:email => 'clarence@example.com', :avatar => png)
|
28
|
-
@user_with_icon = PaperclipUser.create!(:email => 'bobbi@example.com', :icon => png)
|
29
|
-
@user_without_avatar = PaperclipUser.create!(:email => 'brunhilde@example.com')
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_avatar_url_is_nil_if_person_is_nil
|
33
|
-
assert_nil @source.avatar_url_for(nil)
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_avatar_url_is_nil_if_person_has_no_avatar
|
37
|
-
assert_nil @source.avatar_url_for(@user_without_avatar)
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_avatar_url_for_person_with_avatar
|
41
|
-
assert_equal "/images/paperclipusers/#{@user_with_avatar.id}/avatars/medium/user_suit.png", @source.avatar_url_for(@user_with_avatar)
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_avatar_url_is_nil_for_invalid_size
|
45
|
-
assert_nil @source.avatar_url_for(@user_with_avatar, :paperclip_style => :not_a_valid_style)
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_avatar_url_for_person_with_icon_and_custom_file_column_field
|
49
|
-
assert_equal "/images/paperclipusers/#{@user_with_icon.id}/icons/small/user_suit.png", @source.avatar_url_for(@user_with_icon, :paperclip_field => :icon)
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
-
require 'avatar/source/wrapper/rails_asset_source_wrapper'
|
3
|
-
require 'avatar/source/static_url_source'
|
4
|
-
require 'action_controller/base'
|
5
|
-
|
6
|
-
class TestRailsAssetSourceWrapper < Test::Unit::TestCase
|
7
|
-
|
8
|
-
def setup
|
9
|
-
ActionController::Base.asset_host = 'http://test.com'
|
10
|
-
@source = Avatar::Source::StaticUrlSource.new('/')
|
11
|
-
@wrapper = Avatar::Source::Wrapper::RailsAssetSourceWrapper.new(@source)
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_returns_nil_if_underlying_source_returns_nil
|
15
|
-
@source.instance_eval { def avatar_url_for(*args); nil; end }
|
16
|
-
assert_nil @wrapper.avatar_url_for(:a_person)
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_does_not_change_fully_qualified_uri
|
20
|
-
@source.url = 'http://example.com/images/avatar.png'
|
21
|
-
assert_equal 'http://example.com/images/avatar.png', @wrapper.avatar_url_for(3)
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_uses_asset_host
|
25
|
-
@source.url = '/images/avatar.png'
|
26
|
-
assert_equal 'http://test.com/images/avatar.png', @wrapper.avatar_url_for(4)
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_error_if_cannot_generate_full_uri
|
30
|
-
ActionController::Base.asset_host = ''
|
31
|
-
@source.url = '/images/avatar.png'
|
32
|
-
assert_raise(RuntimeError) {
|
33
|
-
@wrapper.avatar_url_for(4)
|
34
|
-
}
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
data/test/test_source_chain.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
-
require 'avatar/source/abstract_source'
|
3
|
-
require 'avatar/source/static_url_source'
|
4
|
-
require 'avatar/source/source_chain'
|
5
|
-
|
6
|
-
class FooSource
|
7
|
-
include Avatar::Source::AbstractSource
|
8
|
-
def avatar_url_for(person, options = {})
|
9
|
-
'foobar' if person.to_s == 'foobar'
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class TestSourceChain < Test::Unit::TestCase
|
14
|
-
|
15
|
-
def setup
|
16
|
-
@source = Avatar::Source::SourceChain.new
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_nil_when_person_is_nil
|
20
|
-
assert_nil @source.avatar_url_for(nil)
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_nil_when_person_is_not_nil
|
24
|
-
assert_nil @source.avatar_url_for(:scottish_terrier)
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_avatar_url_for
|
28
|
-
@source << FooSource.new
|
29
|
-
assert_equal 'foobar', @source.avatar_url_for(:foobar)
|
30
|
-
assert_nil @source.avatar_url_for(:fazbot)
|
31
|
-
|
32
|
-
@source << Avatar::Source::StaticUrlSource.new('default_avatar.png')
|
33
|
-
assert_equal 'foobar', @source.avatar_url_for(:foobar)
|
34
|
-
assert_equal 'default_avatar.png', @source.avatar_url_for(:fazbot)
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_clear!
|
38
|
-
@source << FooSource.new
|
39
|
-
@source << Avatar::Source::StaticUrlSource.new('eeek_a_mouse!')
|
40
|
-
@source.clear!
|
41
|
-
assert @source.empty?
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
-
require 'avatar/source/static_url_source'
|
3
|
-
|
4
|
-
class TestStaticUrlSource < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@source = Avatar::Source::StaticUrlSource.new('foobar')
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_nil_when_person_is_nil
|
11
|
-
assert_nil @source.avatar_url_for(nil)
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_not_nil_when_person_is_not_nil
|
15
|
-
assert_equal 'foobar', @source.avatar_url_for(7)
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
-
require 'avatar/source/static_url_source'
|
3
|
-
require 'avatar/source/wrapper/string_substitution_source_wrapper'
|
4
|
-
|
5
|
-
class TestStringSubstitutionSourceWrapper < Test::Unit::TestCase
|
6
|
-
|
7
|
-
def setup
|
8
|
-
@source = Avatar::Source::StaticUrlSource.new('#{a} and #{b} but not {b}')
|
9
|
-
@wrapper = Avatar::Source::Wrapper::StringSubstitutionSourceWrapper.new(@source)
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_returns_nil_if_underlying_source_returns_nil
|
13
|
-
@source.instance_eval { def avatar_url_for(*args); nil; end }
|
14
|
-
assert_nil @wrapper.avatar_url_for(:a_person)
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_avatar_url_nil_when_not_all_variables_replaced
|
18
|
-
assert_nil @wrapper.avatar_url_for(:bar, :b => 'ham')
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_avatar_url_when_all_variables_replaced
|
22
|
-
assert_equal 'green eggs and ham but not {b}', @wrapper.avatar_url_for(:bar, :a => 'green eggs', :b => 'ham')
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
data/website/index.html
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
-
<head>
|
5
|
-
<link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
|
6
|
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
7
|
-
<title>
|
8
|
-
Avatar
|
9
|
-
</title>
|
10
|
-
<script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script>
|
11
|
-
<style>
|
12
|
-
|
13
|
-
</style>
|
14
|
-
<script type="text/javascript">
|
15
|
-
window.onload = function() {
|
16
|
-
settings = {
|
17
|
-
tl: { radius: 10 },
|
18
|
-
tr: { radius: 10 },
|
19
|
-
bl: { radius: 10 },
|
20
|
-
br: { radius: 10 },
|
21
|
-
antiAlias: true,
|
22
|
-
autoPad: true,
|
23
|
-
validTags: ["div"]
|
24
|
-
}
|
25
|
-
var versionBox = new curvyCorners(settings, document.getElementById("version"));
|
26
|
-
versionBox.applyCornersToAll();
|
27
|
-
}
|
28
|
-
</script>
|
29
|
-
</head>
|
30
|
-
<body>
|
31
|
-
<div id="main">
|
32
|
-
|
33
|
-
<h1>Avatar</h1>
|
34
|
-
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/avatar"; return false'>
|
35
|
-
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/avatar" class="numbers">0.0.5</a>
|
37
|
-
</div>
|
38
|
-
<h1>→ ‘Avatar’</h1>
|
39
|
-
|
40
|
-
|
41
|
-
<h2>What
|
42
|
-
support for avatars</h2>
|
43
|
-
|
44
|
-
|
45
|
-
<h2>Installing</h2>
|
46
|
-
|
47
|
-
|
48
|
-
<p><pre class='syntax'>sudo gem install avatar</pre></p>
|
49
|
-
|
50
|
-
|
51
|
-
<h2>The basics
|
52
|
-
Set up Avatar::source (by default, a Gravatar)
|
53
|
-
Use Avatar::source.avatar_url_for(person, options) or a view helper</h2>
|
54
|
-
|
55
|
-
|
56
|
-
<h2>Demonstration of usage</h2>
|
57
|
-
|
58
|
-
|
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"><%=</span><span class="string"> avatar_tag(@current_user, :size </span><span class="punct">=></span> <span class="number">40</span><span class="punct">)</span> <span class="punct">%></span><span class="string"><span class="normal">
|
68
|
-
</span></span></pre></p>
|
69
|
-
|
70
|
-
|
71
|
-
<h2>Forum</h2>
|
72
|
-
|
73
|
-
|
74
|
-
<p><a href="http://groups.google.com/group/ruby-avatar">http://groups.google.com/group/ruby-avatar</a></p>
|
75
|
-
|
76
|
-
|
77
|
-
<h2>How to submit patches</h2>
|
78
|
-
|
79
|
-
|
80
|
-
<p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people’s code</a> and for section <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups">8b: Submit patch to Google Groups</a>, use the Google Group above.</p>
|
81
|
-
|
82
|
-
|
83
|
-
<p>The project is hosted on <a href="http://github.com/gcnovus/avatar/tree/master">GitHub</a></p>
|
84
|
-
|
85
|
-
|
86
|
-
<h2>License</h2>
|
87
|
-
|
88
|
-
|
89
|
-
<p>This code is free to use under the terms of the <span class="caps">MIT</span> license.</p>
|
90
|
-
|
91
|
-
|
92
|
-
<h2>Contact</h2>
|
93
|
-
|
94
|
-
|
95
|
-
<p>Comments are welcome. Put them on the <a href="http://groups.google.com/group/ruby-avatar">forum</a></p>
|
96
|
-
<p class="coda">
|
97
|
-
<a href="FIXME email">FIXME full name</a>, 28th March 2008<br>
|
98
|
-
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
99
|
-
</p>
|
100
|
-
</div>
|
101
|
-
|
102
|
-
<!-- insert site tracking codes here, like Google Urchin -->
|
103
|
-
|
104
|
-
</body>
|
105
|
-
</html>
|