avatar 0.0.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/History.txt +7 -0
  2. data/{README.txt → README.rdoc} +12 -4
  3. data/init.rb +5 -0
  4. data/lib/avatar.rb +3 -2
  5. data/lib/avatar/source/pavatar_source.rb +109 -0
  6. data/lib/avatar/source/wrapper/rails_asset_source_wrapper.rb +3 -1
  7. data/lib/avatar/version.rb +2 -2
  8. data/rails/init.rb +1 -0
  9. metadata +28 -125
  10. data/.gitignore +0 -8
  11. data/Manifest.txt +0 -104
  12. data/Rakefile +0 -10
  13. data/config/hoe.rb +0 -70
  14. data/config/requirements.rb +0 -17
  15. data/script/destroy +0 -14
  16. data/script/generate +0 -14
  17. data/script/txt2html +0 -74
  18. data/setup.rb +0 -1585
  19. data/tasks/deployment.rake +0 -34
  20. data/tasks/environment.rake +0 -7
  21. data/tasks/testing.rake +0 -37
  22. data/tasks/website.rake +0 -17
  23. data/test/.gitignore +0 -3
  24. data/test/lib/database.rb +0 -2
  25. data/test/lib/database.yml +0 -10
  26. data/test/lib/file_column/CHANGELOG +0 -69
  27. data/test/lib/file_column/README +0 -54
  28. data/test/lib/file_column/Rakefile +0 -36
  29. data/test/lib/file_column/TODO +0 -6
  30. data/test/lib/file_column/init.rb +0 -13
  31. data/test/lib/file_column/lib/file_column.rb +0 -720
  32. data/test/lib/file_column/lib/file_column_helper.rb +0 -150
  33. data/test/lib/file_column/lib/file_compat.rb +0 -28
  34. data/test/lib/file_column/lib/magick_file_column.rb +0 -260
  35. data/test/lib/file_column/lib/rails_file_column.rb +0 -19
  36. data/test/lib/file_column/lib/test_case.rb +0 -124
  37. data/test/lib/file_column/lib/validations.rb +0 -112
  38. data/test/lib/file_column/test/abstract_unit.rb +0 -63
  39. data/test/lib/file_column/test/connection.rb +0 -17
  40. data/test/lib/file_column/test/file_column_helper_test.rb +0 -97
  41. data/test/lib/file_column/test/file_column_test.rb +0 -650
  42. data/test/lib/file_column/test/fixtures/entry.rb +0 -32
  43. data/test/lib/file_column/test/fixtures/invalid-image.jpg +0 -1
  44. data/test/lib/file_column/test/fixtures/kerb.jpg +0 -0
  45. data/test/lib/file_column/test/fixtures/mysql.sql +0 -25
  46. data/test/lib/file_column/test/fixtures/schema.rb +0 -10
  47. data/test/lib/file_column/test/fixtures/skanthak.png +0 -0
  48. data/test/lib/file_column/test/magick_test.rb +0 -380
  49. data/test/lib/file_column/test/magick_view_only_test.rb +0 -21
  50. data/test/lib/paperclip/README +0 -32
  51. data/test/lib/paperclip/Rakefile +0 -41
  52. data/test/lib/paperclip/generators/paperclip/USAGE +0 -5
  53. data/test/lib/paperclip/generators/paperclip/paperclip_generator.rb +0 -27
  54. data/test/lib/paperclip/generators/paperclip/templates/paperclip_migration.rb +0 -17
  55. data/test/lib/paperclip/init.rb +0 -3
  56. data/test/lib/paperclip/lib/paperclip.rb +0 -197
  57. data/test/lib/paperclip/lib/paperclip/attachment.rb +0 -230
  58. data/test/lib/paperclip/lib/paperclip/geometry.rb +0 -109
  59. data/test/lib/paperclip/lib/paperclip/iostream.rb +0 -43
  60. data/test/lib/paperclip/lib/paperclip/thumbnail.rb +0 -80
  61. data/test/lib/paperclip/lib/paperclip/upfile.rb +0 -32
  62. data/test/lib/paperclip/tasks/paperclip_tasks.rake +0 -38
  63. data/test/lib/paperclip/test/database.yml +0 -5
  64. data/test/lib/paperclip/test/fixtures/12k.png +0 -0
  65. data/test/lib/paperclip/test/fixtures/5k.png +0 -0
  66. data/test/lib/paperclip/test/fixtures/bad.png +0 -1
  67. data/test/lib/paperclip/test/helper.rb +0 -38
  68. data/test/lib/paperclip/test/test_attachment.rb +0 -99
  69. data/test/lib/paperclip/test/test_geometry.rb +0 -142
  70. data/test/lib/paperclip/test/test_integration.rb +0 -76
  71. data/test/lib/paperclip/test/test_iostream.rb +0 -60
  72. data/test/lib/paperclip/test/test_paperclip.rb +0 -83
  73. data/test/lib/paperclip/test/test_thumbnail.rb +0 -76
  74. data/test/lib/schema.rb +0 -20
  75. data/test/lib/user_suit.png +0 -0
  76. data/test/test_abstract_view_support.rb +0 -22
  77. data/test/test_action_view_support.rb +0 -30
  78. data/test/test_avatar.rb +0 -12
  79. data/test/test_file_column_source.rb +0 -38
  80. data/test/test_gravatar_source.rb +0 -79
  81. data/test/test_helper.rb +0 -27
  82. data/test/test_nil_source.rb +0 -18
  83. data/test/test_paperclip_source.rb +0 -52
  84. data/test/test_rails_asset_source_wrapper.rb +0 -37
  85. data/test/test_source_chain.rb +0 -44
  86. data/test/test_static_url_source.rb +0 -18
  87. data/test/test_string_substitution_source_wrapper.rb +0 -25
  88. data/website/index.html +0 -105
  89. data/website/index.txt +0 -48
  90. data/website/javascripts/rounded_corners_lite.inc.js +0 -285
  91. data/website/stylesheets/screen.css +0 -138
  92. data/website/template.rhtml +0 -48
@@ -1,142 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
-
5
- require File.join(File.dirname(__FILE__), '..', 'lib', 'paperclip', 'geometry.rb')
6
-
7
- class GeometryTest < Test::Unit::TestCase
8
- context "Paperclip::Geometry" do
9
- should "correctly report its given dimensions" do
10
- assert @geo = Paperclip::Geometry.new(1024, 768)
11
- assert_equal 1024, @geo.width
12
- assert_equal 768, @geo.height
13
- end
14
-
15
- should "correctly create a square if the height dimension is missing" do
16
- assert @geo = Paperclip::Geometry.new(1024)
17
- assert_equal 1024, @geo.width
18
- assert_equal 1024, @geo.height
19
- end
20
-
21
- should "correctly create a square if the width dimension is missing" do
22
- assert @geo = Paperclip::Geometry.new(nil, 768)
23
- assert_equal 768, @geo.width
24
- assert_equal 768, @geo.height
25
- end
26
-
27
- should "be generated from a WxH-formatted string" do
28
- assert @geo = Paperclip::Geometry.parse("800x600")
29
- assert_equal 800, @geo.width
30
- assert_equal 600, @geo.height
31
- end
32
-
33
- should "be generated from a xH-formatted string" do
34
- assert @geo = Paperclip::Geometry.parse("x600")
35
- assert_equal 600, @geo.width
36
- assert_equal 600, @geo.height
37
- end
38
-
39
- should "be generated from a Wx-formatted string" do
40
- assert @geo = Paperclip::Geometry.parse("800x")
41
- assert_equal 800, @geo.width
42
- assert_equal 800, @geo.height
43
- end
44
-
45
- should "ensure the modifier is nil if only one dimension present" do
46
- assert @geo = Paperclip::Geometry.parse("123x")
47
- assert_nil @geo.modifier
48
- end
49
-
50
- should "ensure the modifier is nil if not present" do
51
- assert @geo = Paperclip::Geometry.parse("123x456")
52
- assert_nil @geo.modifier
53
- end
54
-
55
- ['>', '<', '#', '@', '%', '^', '!'].each do |mod|
56
- should "ensure the modifier #{mod} is preserved" do
57
- assert @geo = Paperclip::Geometry.parse("123x456#{mod}")
58
- assert_equal mod, @geo.modifier
59
- end
60
- end
61
-
62
- should "make sure the modifier gets passed during transformation_to" do
63
- assert @src = Paperclip::Geometry.parse("123x456")
64
- assert @dst = Paperclip::Geometry.parse("123x456>")
65
- assert_equal "123x456>", @src.transformation_to(@dst).to_s
66
- end
67
-
68
- should "be generated from a file" do
69
- file = File.join(File.dirname(__FILE__), "fixtures", "5k.png")
70
- file = File.new(file)
71
- assert_nothing_raised{ @geo = Paperclip::Geometry.from_file(file) }
72
- assert @geo.height > 0
73
- assert @geo.width > 0
74
- end
75
-
76
- should "be generated from a file path" do
77
- file = File.join(File.dirname(__FILE__), "fixtures", "5k.png")
78
- assert_nothing_raised{ @geo = Paperclip::Geometry.from_file(file) }
79
- assert @geo.height > 0
80
- assert @geo.width > 0
81
- end
82
-
83
- should "not generate from a bad file" do
84
- file = "/home/This File Does Not Exist.omg"
85
- assert_raise(Errno::ENOENT){ @geo = Paperclip::Geometry.from_file(file) }
86
- end
87
-
88
- [['vertical', 900, 1440, true, false, false, 1440, 900, 0.625],
89
- ['horizontal', 1024, 768, false, true, false, 1024, 768, 1.3333],
90
- ['square', 100, 100, false, false, true, 100, 100, 1]].each do |args|
91
- context "performing calculations on a #{args[0]} viewport" do
92
- setup do
93
- @geo = Paperclip::Geometry.new(args[1], args[2])
94
- end
95
-
96
- should "#{args[3] ? "" : "not"} be vertical" do
97
- assert_equal args[3], @geo.vertical?
98
- end
99
-
100
- should "#{args[4] ? "" : "not"} be horizontal" do
101
- assert_equal args[4], @geo.horizontal?
102
- end
103
-
104
- should "#{args[5] ? "" : "not"} be square" do
105
- assert_equal args[5], @geo.square?
106
- end
107
-
108
- should "report that #{args[6]} is the larger dimension" do
109
- assert_equal args[6], @geo.larger
110
- end
111
-
112
- should "report that #{args[7]} is the smaller dimension" do
113
- assert_equal args[7], @geo.smaller
114
- end
115
-
116
- should "have an aspect ratio of #{args[8]}" do
117
- assert_in_delta args[8], @geo.aspect, 0.0001
118
- end
119
- end
120
- end
121
-
122
- [[ [1000, 100], [64, 64], "x64", "64x64+288+0" ],
123
- [ [100, 1000], [50, 950], "x950", "50x950+22+0" ],
124
- [ [100, 1000], [50, 25], "50x", "50x25+0+237" ]]. each do |args|
125
- context "of #{args[0].inspect} and given a Geometry #{args[1].inspect} and sent transform_to" do
126
- setup do
127
- @geo = Paperclip::Geometry.new(*args[0])
128
- @dst = Paperclip::Geometry.new(*args[1])
129
- @scale, @crop = @geo.transformation_to @dst, true
130
- end
131
-
132
- should "be able to return the correct scaling transformation geometry #{args[2]}" do
133
- assert_equal args[2], @scale
134
- end
135
-
136
- should "be able to return the correct crop transformation geometry #{args[3]}" do
137
- assert_equal args[3], @crop
138
- end
139
- end
140
- end
141
- end
142
- end
@@ -1,76 +0,0 @@
1
- require 'test/helper.rb'
2
-
3
- class PaperclipTest < Test::Unit::TestCase
4
- context "A model with an attachment" do
5
- setup do
6
- rebuild_model :styles => { :large => "300x300>",
7
- :medium => "100x100",
8
- :thumb => ["32x32#", :gif] },
9
- :default_style => :medium,
10
- :url => "/:attachment/:class/:style/:id/:basename.:extension",
11
- :path => ":rails_root/tmp/:attachment/:class/:style/:id/:basename.:extension"
12
- end
13
-
14
- should "integrate" do
15
- @dummy = Dummy.new
16
- @file = File.new(File.join(FIXTURES_DIR, "5k.png"))
17
- @bad_file = File.new(File.join(FIXTURES_DIR, "bad.png"))
18
-
19
- assert @dummy.avatar = @file
20
- assert @dummy.valid?
21
- assert @dummy.save
22
-
23
- [["100x15", nil],
24
- ["434x66", :original],
25
- ["300x46", :large],
26
- ["100x15", :medium],
27
- ["32x32", :thumb]].each do |geo, style|
28
- cmd = %Q[identify -format "%wx%h" #{@dummy.avatar.to_io(style).path}]
29
- assert_equal geo, `#{cmd}`.chomp, cmd
30
- end
31
-
32
- saved_paths = [:thumb, :medium, :large, :original].collect{|s| @dummy.avatar.to_io(s).path }
33
-
34
- @d2 = Dummy.find(@dummy.id)
35
- assert_equal "100x15", `identify -format "%wx%h" #{@dummy.avatar.to_io.path}`.chomp
36
- assert_equal "434x66", `identify -format "%wx%h" #{@dummy.avatar.to_io(:original).path}`.chomp
37
- assert_equal "300x46", `identify -format "%wx%h" #{@d2.avatar.to_io(:large).path}`.chomp
38
- assert_equal "100x15", `identify -format "%wx%h" #{@d2.avatar.to_io(:medium).path}`.chomp
39
- assert_equal "32x32", `identify -format "%wx%h" #{@d2.avatar.to_io(:thumb).path}`.chomp
40
-
41
- @dummy.avatar = nil
42
- assert_nil @dummy.avatar_file_name
43
- assert @dummy.valid?
44
- assert @dummy.save
45
-
46
- saved_paths.each do |p|
47
- assert ! File.exists?(p)
48
- end
49
-
50
- @d2 = Dummy.find(@dummy.id)
51
- assert_nil @d2.avatar_file_name
52
-
53
- @d2.avatar = @bad_file
54
- assert ! @d2.valid?
55
- @d2.avatar = nil
56
- assert @d2.valid?
57
-
58
- Dummy.validates_attachment_presence :avatar
59
- @d3 = Dummy.find(@d2.id)
60
- @d3.avatar = @file
61
- assert @d3.valid?
62
- @d3.avatar = @bad_file
63
- assert ! @d3.valid?
64
- @d3.avatar = nil
65
- assert ! @d3.valid?
66
-
67
- @dummy.avatar = @file
68
- assert @dummy.save
69
- @dummy.avatar = nil
70
- assert_nil @dummy.avatar_file_name
71
- @dummy.reload
72
- assert_equal "5k.png", @dummy.avatar_file_name
73
- end
74
- end
75
- end
76
-
@@ -1,60 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'stringio'
4
- require 'tempfile'
5
- require 'shoulda'
6
-
7
- require File.join(File.dirname(__FILE__), '..', 'lib', 'paperclip', 'iostream.rb')
8
-
9
- class IOStreamTest < Test::Unit::TestCase
10
- context "IOStream" do
11
- should "be included in IO, File, Tempfile, and StringIO" do
12
- [IO, File, Tempfile, StringIO].each do |klass|
13
- assert klass.included_modules.include?(IOStream), "Not in #{klass}"
14
- end
15
- end
16
- end
17
-
18
- context "A file" do
19
- setup do
20
- @file = File.new(File.join(File.dirname(__FILE__), "fixtures", "5k.png"))
21
- end
22
-
23
- context "that is sent #stream_to" do
24
-
25
- [["/tmp/iostream.string.test", File],
26
- [Tempfile.new('iostream.test'), Tempfile]].each do |args|
27
-
28
- context "and given a #{args[0].class.to_s}" do
29
- setup do
30
- assert @result = @file.stream_to(args[0])
31
- end
32
-
33
- should "return a #{args[1].to_s}" do
34
- assert @result.is_a?(args[1])
35
- end
36
-
37
- should "contain the same data as the original file" do
38
- @file.rewind; @result.rewind
39
- assert_equal @file.read, @result.read
40
- end
41
- end
42
- end
43
- end
44
-
45
- context "that is sent #to_tempfile" do
46
- setup do
47
- assert @tempfile = @file.to_tempfile
48
- end
49
-
50
- should "convert it to a Tempfile" do
51
- assert @tempfile.is_a?(Tempfile)
52
- end
53
-
54
- should "have the Tempfile contain the same data as the file" do
55
- @file.rewind; @tempfile.rewind
56
- assert_equal @file.read, @tempfile.read
57
- end
58
- end
59
- end
60
- end
@@ -1,83 +0,0 @@
1
- require 'test/helper.rb'
2
-
3
- class PaperclipTest < Test::Unit::TestCase
4
- context "An ActiveRecord model with an 'avatar' attachment" do
5
- setup do
6
- rebuild_model
7
- @file = File.new(File.join(FIXTURES_DIR, "5k.png"))
8
- end
9
-
10
- context "that is attr_protected" do
11
- setup do
12
- Dummy.class_eval do
13
- attr_protected :avatar
14
- end
15
- @dummy = Dummy.new
16
- end
17
-
18
- should "not assign the avatar on mass-set" do
19
- @dummy.logger.expects(:debug)
20
-
21
- @dummy.attributes = { :other => "I'm set!",
22
- :avatar => @file }
23
-
24
- assert_equal "I'm set!", @dummy.other
25
- assert ! @dummy.avatar?
26
- end
27
-
28
- should "still allow assigment on normal set" do
29
- @dummy.logger.expects(:debug).times(0)
30
-
31
- @dummy.other = "I'm set!"
32
- @dummy.avatar = @file
33
-
34
- assert_equal "I'm set!", @dummy.other
35
- assert @dummy.avatar?
36
- end
37
- end
38
-
39
- should "have an #avatar method" do
40
- assert Dummy.new.respond_to?(:avatar)
41
- end
42
-
43
- should "have an #avatar= method" do
44
- assert Dummy.new.respond_to?(:avatar=)
45
- end
46
-
47
- [[:presence, nil, "5k.png", nil],
48
- [:size, {:in => 1..10240}, "5k.png", "12k.png"]].each do |args|
49
- context "with #{args[0]} validations" do
50
- setup do
51
- Dummy.class_eval do
52
- send(*[:"validates_attachment_#{args[0]}", :avatar, args[1]].compact)
53
- end
54
- @dummy = Dummy.new
55
- end
56
-
57
- context "and a valid file" do
58
- setup do
59
- @file = args[2] && File.new(File.join(FIXTURES_DIR, args[2]))
60
- end
61
-
62
- should "not have any errors" do
63
- @dummy.avatar = @file
64
- assert @dummy.avatar.valid?
65
- assert_equal 0, @dummy.avatar.errors.length
66
- end
67
- end
68
-
69
- context "and an invalid file" do
70
- setup do
71
- @file = args[3] && File.new(File.join(FIXTURES_DIR, args[3]))
72
- end
73
-
74
- should "have errors" do
75
- @dummy.avatar = @file
76
- assert ! @dummy.avatar.valid?
77
- assert_equal 1, @dummy.avatar.errors.length
78
- end
79
- end
80
- end
81
- end
82
- end
83
- end
@@ -1,76 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
- require 'mocha'
5
- require 'tempfile'
6
-
7
- require File.join(File.dirname(__FILE__), '..', 'lib', 'paperclip', 'geometry.rb')
8
- require File.join(File.dirname(__FILE__), '..', 'lib', 'paperclip', 'thumbnail.rb')
9
-
10
- class ThumbnailTest < Test::Unit::TestCase
11
-
12
- context "A Paperclip Tempfile" do
13
- setup do
14
- @tempfile = Paperclip::Tempfile.new("file.jpg")
15
- end
16
-
17
- should "have its path contain a real extension" do
18
- assert_equal ".jpg", File.extname(@tempfile.path)
19
- end
20
-
21
- should "be a real Tempfile" do
22
- assert @tempfile.is_a?(::Tempfile)
23
- end
24
- end
25
-
26
- context "Another Paperclip Tempfile" do
27
- setup do
28
- @tempfile = Paperclip::Tempfile.new("file")
29
- end
30
-
31
- should "not have an extension if not given one" do
32
- assert_equal "", File.extname(@tempfile.path)
33
- end
34
-
35
- should "still be a real Tempfile" do
36
- assert @tempfile.is_a?(::Tempfile)
37
- end
38
- end
39
-
40
- context "An image" do
41
- setup do
42
- @file = File.new(File.join(File.dirname(__FILE__), "fixtures", "5k.png"))
43
- end
44
-
45
- context "being thumbnailed at 100x50 with cropping" do
46
- setup do
47
- @thumb = Paperclip::Thumbnail.new(@file, "100x50#")
48
- end
49
-
50
- should "report its correct current and target geometries" do
51
- assert_equal "100x50#", @thumb.target_geometry.to_s
52
- assert_equal "434x66", @thumb.current_geometry.to_s
53
- end
54
-
55
- should "report its correct format" do
56
- assert_nil @thumb.format
57
- end
58
-
59
- should "have whiny_thumbnails turned on by default" do
60
- assert @thumb.whiny_thumbnails
61
- end
62
-
63
- should "send the right command to convert when sent #make" do
64
- @thumb.expects(:system).with do |arg|
65
- arg.match %r{convert\s+"#{File.expand_path(@thumb.file.path)}"\s+-scale\s+\"x50\"\s+-crop\s+\"100x50\+114\+0\"\s+\+repage\s+".*?"}
66
- end
67
- @thumb.make
68
- end
69
-
70
- should "create the thumbnail when sent #make" do
71
- dst = @thumb.make
72
- assert_match /100x50/, `identify #{dst.path}`
73
- end
74
- end
75
- end
76
- end
@@ -1,20 +0,0 @@
1
- ActiveRecord::Schema.define :version => 0 do
2
- create_table :file_column_users, :force => true do |t|
3
- t.column :name, :text, :nil => false
4
- t.column :email, :text, :nil => false
5
- t.column :avatar, :string
6
- t.column :icon, :string
7
- end
8
- create_table :paperclip_users, :force => true do |t|
9
- t.column :name, :text, :nil => false
10
- t.column :email, :text, :nil => false
11
-
12
- t.column :avatar_file_name, :string
13
- t.column :avatar_content_type, :string
14
- t.column :avatar_file_size, :integer
15
-
16
- t.column :icon_file_name, :string
17
- t.column :icon_content_type, :string
18
- t.column :icon_file_size, :integer
19
- end
20
- end