joint 0.5.3 → 0.5.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.
- data/lib/joint.rb +11 -4
 - data/lib/joint/version.rb +1 -1
 - data/test/fixtures/example.m4r +0 -0
 - data/test/fixtures/font.eot +0 -0
 - data/test/test_joint.rb +39 -1
 - metadata +7 -3
 
    
        data/lib/joint.rb
    CHANGED
    
    | 
         @@ -26,11 +26,18 @@ module Joint 
     | 
|
| 
       26 
26 
     | 
    
         
             
              end
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
       28 
28 
     | 
    
         
             
              def self.type(file)
         
     | 
| 
       29 
     | 
    
         
            -
                if file.respond_to?(:content_type)
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
                 
     | 
| 
       32 
     | 
    
         
            -
                  Wand.wave(file.path, :original_filename => Joint.name(file))
         
     | 
| 
      
 29 
     | 
    
         
            +
                type = file.content_type if file.respond_to?(:content_type)
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                if blank?(type)
         
     | 
| 
      
 32 
     | 
    
         
            +
                  type = Wand.wave(file.path, :original_filename => Joint.name(file))
         
     | 
| 
       33 
33 
     | 
    
         
             
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                type
         
     | 
| 
      
 36 
     | 
    
         
            +
              end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            private
         
     | 
| 
      
 39 
     | 
    
         
            +
              def self.blank?(str)
         
     | 
| 
      
 40 
     | 
    
         
            +
                str.nil? || str !~ /\S/
         
     | 
| 
       34 
41 
     | 
    
         
             
              end
         
     | 
| 
       35 
42 
     | 
    
         
             
            end
         
     | 
| 
       36 
43 
     | 
    
         | 
    
        data/lib/joint/version.rb
    CHANGED
    
    
| 
         Binary file 
     | 
| 
         Binary file 
     | 
    
        data/test/test_joint.rb
    CHANGED
    
    | 
         @@ -43,13 +43,21 @@ class JointTest < Test::Unit::TestCase 
     | 
|
| 
       43 
43 
     | 
    
         
             
              end
         
     | 
| 
       44 
44 
     | 
    
         | 
| 
       45 
45 
     | 
    
         
             
              context ".type" do
         
     | 
| 
       46 
     | 
    
         
            -
                should "return  
     | 
| 
      
 46 
     | 
    
         
            +
                should "return content_type if responds to it" do
         
     | 
| 
       47 
47 
     | 
    
         
             
                  def @image.content_type
         
     | 
| 
       48 
48 
     | 
    
         
             
                    'plain/text'
         
     | 
| 
       49 
49 
     | 
    
         
             
                  end
         
     | 
| 
       50 
50 
     | 
    
         
             
                  Joint.type(@image).should == 'plain/text'
         
     | 
| 
       51 
51 
     | 
    
         
             
                end
         
     | 
| 
       52 
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
         
     | 
| 
      
 58 
     | 
    
         
            +
                  Joint.type(@image).should == 'image/jpeg'
         
     | 
| 
      
 59 
     | 
    
         
            +
                end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
       53 
61 
     | 
    
         
             
                should "fall back to Wand" do
         
     | 
| 
       54 
62 
     | 
    
         
             
                  Joint.type(@image).should == 'image/jpeg'
         
     | 
| 
       55 
63 
     | 
    
         
             
                end
         
     | 
| 
         @@ -361,4 +369,34 @@ class JointTest < Test::Unit::TestCase 
     | 
|
| 
       361 
369 
     | 
    
         
             
                  @asset.file.read.should == 'This is my stuff'
         
     | 
| 
       362 
370 
     | 
    
         
             
                end
         
     | 
| 
       363 
371 
     | 
    
         
             
              end
         
     | 
| 
      
 372 
     | 
    
         
            +
             
     | 
| 
      
 373 
     | 
    
         
            +
              context "A font file" do
         
     | 
| 
      
 374 
     | 
    
         
            +
                setup do
         
     | 
| 
      
 375 
     | 
    
         
            +
                  @file = open_file('font.eot')
         
     | 
| 
      
 376 
     | 
    
         
            +
                  @doc = Asset.create(:file => @file)
         
     | 
| 
      
 377 
     | 
    
         
            +
                end
         
     | 
| 
      
 378 
     | 
    
         
            +
                subject { @doc }
         
     | 
| 
      
 379 
     | 
    
         
            +
             
     | 
| 
      
 380 
     | 
    
         
            +
                should "assign joint keys" do
         
     | 
| 
      
 381 
     | 
    
         
            +
                  subject.file_size.should   == 17610
         
     | 
| 
      
 382 
     | 
    
         
            +
                  subject.file_type.should   == "application/octet-stream"
         
     | 
| 
      
 383 
     | 
    
         
            +
                  subject.file_id.should_not be_nil
         
     | 
| 
      
 384 
     | 
    
         
            +
                  subject.file_id.should be_instance_of(BSON::ObjectId)
         
     | 
| 
      
 385 
     | 
    
         
            +
                end
         
     | 
| 
      
 386 
     | 
    
         
            +
              end
         
     | 
| 
      
 387 
     | 
    
         
            +
             
     | 
| 
      
 388 
     | 
    
         
            +
              context "A music file" do
         
     | 
| 
      
 389 
     | 
    
         
            +
                setup do
         
     | 
| 
      
 390 
     | 
    
         
            +
                  @file = open_file('example.m4r')
         
     | 
| 
      
 391 
     | 
    
         
            +
                  @doc = Asset.create(:file => @file)
         
     | 
| 
      
 392 
     | 
    
         
            +
                end
         
     | 
| 
      
 393 
     | 
    
         
            +
                subject { @doc }
         
     | 
| 
      
 394 
     | 
    
         
            +
             
     | 
| 
      
 395 
     | 
    
         
            +
                should "assign joint keys" do
         
     | 
| 
      
 396 
     | 
    
         
            +
                  subject.file_size.should   == 50790
         
     | 
| 
      
 397 
     | 
    
         
            +
                  subject.file_type.should   == "audio/mp4"
         
     | 
| 
      
 398 
     | 
    
         
            +
                  subject.file_id.should_not be_nil
         
     | 
| 
      
 399 
     | 
    
         
            +
                  subject.file_id.should be_instance_of(BSON::ObjectId)
         
     | 
| 
      
 400 
     | 
    
         
            +
                end
         
     | 
| 
      
 401 
     | 
    
         
            +
              end
         
     | 
| 
       364 
402 
     | 
    
         
             
            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: 3
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       6 
6 
     | 
    
         
             
              segments: 
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 0
         
     | 
| 
       8 
8 
     | 
    
         
             
              - 5
         
     | 
| 
       9 
     | 
    
         
            -
              -  
     | 
| 
       10 
     | 
    
         
            -
              version: 0.5. 
     | 
| 
      
 9 
     | 
    
         
            +
              - 4
         
     | 
| 
      
 10 
     | 
    
         
            +
              version: 0.5.4
         
     | 
| 
       11 
11 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       12 
12 
     | 
    
         
             
            authors: 
         
     | 
| 
       13 
13 
     | 
    
         
             
            - John Nunemaker
         
     | 
| 
         @@ -128,6 +128,8 @@ files: 
     | 
|
| 
       128 
128 
     | 
    
         
             
            - lib/joint/io.rb
         
     | 
| 
       129 
129 
     | 
    
         
             
            - lib/joint/version.rb
         
     | 
| 
       130 
130 
     | 
    
         
             
            - specs.watchr
         
     | 
| 
      
 131 
     | 
    
         
            +
            - test/fixtures/example.m4r
         
     | 
| 
      
 132 
     | 
    
         
            +
            - test/fixtures/font.eot
         
     | 
| 
       131 
133 
     | 
    
         
             
            - test/fixtures/harmony.png
         
     | 
| 
       132 
134 
     | 
    
         
             
            - test/fixtures/mr_t.jpg
         
     | 
| 
       133 
135 
     | 
    
         
             
            - test/fixtures/test1.txt
         
     | 
| 
         @@ -171,6 +173,8 @@ signing_key: 
     | 
|
| 
       171 
173 
     | 
    
         
             
            specification_version: 3
         
     | 
| 
       172 
174 
     | 
    
         
             
            summary: MongoMapper and GridFS joined in file upload love.
         
     | 
| 
       173 
175 
     | 
    
         
             
            test_files: 
         
     | 
| 
      
 176 
     | 
    
         
            +
            - test/fixtures/example.m4r
         
     | 
| 
      
 177 
     | 
    
         
            +
            - test/fixtures/font.eot
         
     | 
| 
       174 
178 
     | 
    
         
             
            - test/fixtures/harmony.png
         
     | 
| 
       175 
179 
     | 
    
         
             
            - test/fixtures/mr_t.jpg
         
     | 
| 
       176 
180 
     | 
    
         
             
            - test/fixtures/test1.txt
         
     |