joint 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/joint.rb +2 -7
- data/lib/joint/io.rb +2 -2
- data/lib/joint/version.rb +1 -1
- data/test/joint/test_io.rb +2 -2
- data/test/test_joint.rb +6 -16
- metadata +3 -3
data/lib/joint.rb
CHANGED
@@ -26,13 +26,8 @@ module Joint
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.type(file)
|
29
|
-
|
30
|
-
|
31
|
-
if blank?(type)
|
32
|
-
type = Wand.wave(file.path, :original_filename => Joint.name(file))
|
33
|
-
end
|
34
|
-
|
35
|
-
type
|
29
|
+
return file.type if file.is_a?(Joint::IO)
|
30
|
+
Wand.wave(file.path, :original_filename => Joint.name(file))
|
36
31
|
end
|
37
32
|
|
38
33
|
private
|
data/lib/joint/io.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
module Joint
|
2
2
|
class IO
|
3
|
-
attr_accessor :name, :content, :
|
3
|
+
attr_accessor :name, :content, :type, :size
|
4
4
|
|
5
5
|
def initialize(attrs={})
|
6
6
|
attrs.each { |key, value| send("#{key}=", value) }
|
7
|
-
@
|
7
|
+
@type ||= 'plain/text'
|
8
8
|
@size ||= @content.size unless @content.nil?
|
9
9
|
end
|
10
10
|
|
data/lib/joint/version.rb
CHANGED
data/test/joint/test_io.rb
CHANGED
@@ -7,8 +7,8 @@ class IOTest < Test::Unit::TestCase
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
should "default
|
11
|
-
Joint::IO.new.
|
10
|
+
should "default type to plain text" do
|
11
|
+
Joint::IO.new.type.should == 'plain/text'
|
12
12
|
end
|
13
13
|
|
14
14
|
should "default size to content size" do
|
data/test/test_joint.rb
CHANGED
@@ -43,18 +43,8 @@ class JointTest < Test::Unit::TestCase
|
|
43
43
|
end
|
44
44
|
|
45
45
|
context ".type" do
|
46
|
-
should "return
|
47
|
-
|
48
|
-
'plain/text'
|
49
|
-
end
|
50
|
-
Joint.type(@image).should == 'plain/text'
|
51
|
-
end
|
52
|
-
|
53
|
-
should "fall back to Wand if content_type is blank" do
|
54
|
-
def @image.content_type; '' end
|
55
|
-
Joint.type(@image).should == 'image/jpeg'
|
56
|
-
|
57
|
-
def @image.content_type; ' ' end
|
46
|
+
should "return type if Joint::Io instance" do
|
47
|
+
file = Joint::IO.new(:type => 'image/jpeg')
|
58
48
|
Joint.type(@image).should == 'image/jpeg'
|
59
49
|
end
|
60
50
|
|
@@ -354,10 +344,10 @@ class JointTest < Test::Unit::TestCase
|
|
354
344
|
context "Assigning joint io instance" do
|
355
345
|
setup do
|
356
346
|
io = Joint::IO.new({
|
357
|
-
:name
|
358
|
-
:
|
359
|
-
:content
|
360
|
-
:size
|
347
|
+
:name => 'foo.txt',
|
348
|
+
:type => 'plain/text',
|
349
|
+
:content => 'This is my stuff',
|
350
|
+
:size => 19,
|
361
351
|
})
|
362
352
|
@asset = Asset.create(:file => io)
|
363
353
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: joint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 5
|
10
|
+
version: 0.5.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- John Nunemaker
|