carrierwave-ftp 0.2.0 → 0.2.1
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/README.md +1 -1
 - data/lib/carrierwave/storage/ftp/version.rb +1 -1
 - data/lib/carrierwave/storage/ftp.rb +11 -5
 - data/lib/carrierwave/storage/sftp.rb +11 -5
 - data/spec/ftp_spec.rb +6 -1
 - data/spec/sftp_spec.rb +6 -1
 - metadata +4 -4
 
    
        data/README.md
    CHANGED
    
    | 
         @@ -14,7 +14,7 @@ Require it in your code: 
     | 
|
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
            Or, in Rails you can add it to your Gemfile:
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
                gem 'carrierwave-ftp', :require => 'carrierwave/storage/all' # both FTP/SFTP
         
     | 
| 
      
 17 
     | 
    
         
            +
                gem 'carrierwave-ftp', :require => 'carrierwave/storage/ftp/all' # both FTP/SFTP
         
     | 
| 
       18 
18 
     | 
    
         
             
                gem 'carrierwave-ftp', :require => 'carrierwave/storage/ftp' # FTP only
         
     | 
| 
       19 
19 
     | 
    
         
             
                gem 'carrierwave-ftp', :require => 'carrierwave/storage/sftp' # SFTP only
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
         @@ -53,7 +53,15 @@ module CarrierWave 
     | 
|
| 
       53 
53 
     | 
    
         
             
                    end
         
     | 
| 
       54 
54 
     | 
    
         | 
| 
       55 
55 
     | 
    
         
             
                    def read
         
     | 
| 
       56 
     | 
    
         
            -
                       
     | 
| 
      
 56 
     | 
    
         
            +
                      file.body
         
     | 
| 
      
 57 
     | 
    
         
            +
                    end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                    def content_type
         
     | 
| 
      
 60 
     | 
    
         
            +
                      @content_type || file.content_type
         
     | 
| 
      
 61 
     | 
    
         
            +
                    end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                    def content_type=(new_content_type)
         
     | 
| 
      
 64 
     | 
    
         
            +
                      @content_type = new_content_type
         
     | 
| 
       57 
65 
     | 
    
         
             
                    end
         
     | 
| 
       58 
66 
     | 
    
         | 
| 
       59 
67 
     | 
    
         
             
                    def delete
         
     | 
| 
         @@ -65,15 +73,13 @@ module CarrierWave 
     | 
|
| 
       65 
73 
     | 
    
         | 
| 
       66 
74 
     | 
    
         
             
                    private
         
     | 
| 
       67 
75 
     | 
    
         | 
| 
       68 
     | 
    
         
            -
                    def  
     | 
| 
      
 76 
     | 
    
         
            +
                    def file
         
     | 
| 
       69 
77 
     | 
    
         
             
                      require 'net/http'
         
     | 
| 
       70 
78 
     | 
    
         
             
                      url = URI.parse(url)
         
     | 
| 
       71 
79 
     | 
    
         
             
                      req = Net::HTTP::Get.new(url.path)
         
     | 
| 
       72 
     | 
    
         
            -
                       
     | 
| 
      
 80 
     | 
    
         
            +
                      Net::HTTP.start(url.host, url.port) do |http|
         
     | 
| 
       73 
81 
     | 
    
         
             
                        http.request(req)
         
     | 
| 
       74 
82 
     | 
    
         
             
                      end
         
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
                      res.body
         
     | 
| 
       77 
83 
     | 
    
         
             
                    end
         
     | 
| 
       78 
84 
     | 
    
         | 
| 
       79 
85 
     | 
    
         
             
                    def connection
         
     | 
| 
         @@ -51,7 +51,15 @@ module CarrierWave 
     | 
|
| 
       51 
51 
     | 
    
         
             
                    end
         
     | 
| 
       52 
52 
     | 
    
         | 
| 
       53 
53 
     | 
    
         
             
                    def read
         
     | 
| 
       54 
     | 
    
         
            -
                       
     | 
| 
      
 54 
     | 
    
         
            +
                      file.body
         
     | 
| 
      
 55 
     | 
    
         
            +
                    end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                    def content_type
         
     | 
| 
      
 58 
     | 
    
         
            +
                      @content_type || file.content_type
         
     | 
| 
      
 59 
     | 
    
         
            +
                    end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                    def content_type=(new_content_type)
         
     | 
| 
      
 62 
     | 
    
         
            +
                      @content_type = new_content_type
         
     | 
| 
       55 
63 
     | 
    
         
             
                    end
         
     | 
| 
       56 
64 
     | 
    
         | 
| 
       57 
65 
     | 
    
         
             
                    def delete
         
     | 
| 
         @@ -66,15 +74,13 @@ module CarrierWave 
     | 
|
| 
       66 
74 
     | 
    
         
             
                      "#{@uploader.sftp_folder}/#{path}"
         
     | 
| 
       67 
75 
     | 
    
         
             
                    end
         
     | 
| 
       68 
76 
     | 
    
         | 
| 
       69 
     | 
    
         
            -
                    def  
     | 
| 
      
 77 
     | 
    
         
            +
                    def file
         
     | 
| 
       70 
78 
     | 
    
         
             
                      require 'net/http'
         
     | 
| 
       71 
79 
     | 
    
         
             
                      url = URI.parse(url)
         
     | 
| 
       72 
80 
     | 
    
         
             
                      req = Net::HTTP::Get.new(url.path)
         
     | 
| 
       73 
     | 
    
         
            -
                       
     | 
| 
      
 81 
     | 
    
         
            +
                      Net::HTTP.start(url.host, url.port) do |http|
         
     | 
| 
       74 
82 
     | 
    
         
             
                        http.request(req)
         
     | 
| 
       75 
83 
     | 
    
         
             
                      end
         
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
                      res.body
         
     | 
| 
       78 
84 
     | 
    
         
             
                    end
         
     | 
| 
       79 
85 
     | 
    
         | 
| 
       80 
86 
     | 
    
         
             
                    def connection
         
     | 
    
        data/spec/ftp_spec.rb
    CHANGED
    
    | 
         @@ -90,8 +90,13 @@ describe CarrierWave::Storage::FTP do 
     | 
|
| 
       90 
90 
     | 
    
         
             
                end
         
     | 
| 
       91 
91 
     | 
    
         | 
| 
       92 
92 
     | 
    
         
             
                it "returns the content of the file" do
         
     | 
| 
       93 
     | 
    
         
            -
                  @stored.should_receive(: 
     | 
| 
      
 93 
     | 
    
         
            +
                  @stored.should_receive(:file).and_return(Struct.new(:body).new('some content'))
         
     | 
| 
       94 
94 
     | 
    
         
             
                  @stored.read.should == 'some content'
         
     | 
| 
       95 
95 
     | 
    
         
             
                end
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
                it "returns the content_type of the file" do
         
     | 
| 
      
 98 
     | 
    
         
            +
                  @stored.should_receive(:file).and_return(Struct.new(:content_type).new('some/type'))
         
     | 
| 
      
 99 
     | 
    
         
            +
                  @stored.content_type.should == 'some/type'
         
     | 
| 
      
 100 
     | 
    
         
            +
                end
         
     | 
| 
       96 
101 
     | 
    
         
             
              end
         
     | 
| 
       97 
102 
     | 
    
         
             
            end
         
     | 
    
        data/spec/sftp_spec.rb
    CHANGED
    
    | 
         @@ -88,8 +88,13 @@ describe CarrierWave::Storage::SFTP do 
     | 
|
| 
       88 
88 
     | 
    
         
             
                end
         
     | 
| 
       89 
89 
     | 
    
         | 
| 
       90 
90 
     | 
    
         
             
                it "returns the content of the file" do
         
     | 
| 
       91 
     | 
    
         
            -
                  @stored.should_receive(: 
     | 
| 
      
 91 
     | 
    
         
            +
                  @stored.should_receive(:file).and_return(Struct.new(:body).new('some content'))
         
     | 
| 
       92 
92 
     | 
    
         
             
                  @stored.read.should == 'some content'
         
     | 
| 
       93 
93 
     | 
    
         
             
                end
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
                it "returns the content_type of the file" do
         
     | 
| 
      
 96 
     | 
    
         
            +
                  @stored.should_receive(:file).and_return(Struct.new(:content_type).new('some/type'))
         
     | 
| 
      
 97 
     | 
    
         
            +
                  @stored.content_type.should == 'some/type'
         
     | 
| 
      
 98 
     | 
    
         
            +
                end
         
     | 
| 
       94 
99 
     | 
    
         
             
              end
         
     | 
| 
       95 
100 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: carrierwave-ftp
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.2. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.2.1
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -9,7 +9,7 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2012-08- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2012-08-28 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: carrierwave
         
     | 
| 
         @@ -111,7 +111,7 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       111 
111 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       112 
112 
     | 
    
         
             
                  segments:
         
     | 
| 
       113 
113 
     | 
    
         
             
                  - 0
         
     | 
| 
       114 
     | 
    
         
            -
                  hash:  
     | 
| 
      
 114 
     | 
    
         
            +
                  hash: 2900138492913729311
         
     | 
| 
       115 
115 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       116 
116 
     | 
    
         
             
              none: false
         
     | 
| 
       117 
117 
     | 
    
         
             
              requirements:
         
     | 
| 
         @@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       120 
120 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       121 
121 
     | 
    
         
             
                  segments:
         
     | 
| 
       122 
122 
     | 
    
         
             
                  - 0
         
     | 
| 
       123 
     | 
    
         
            -
                  hash:  
     | 
| 
      
 123 
     | 
    
         
            +
                  hash: 2900138492913729311
         
     | 
| 
       124 
124 
     | 
    
         
             
            requirements: []
         
     | 
| 
       125 
125 
     | 
    
         
             
            rubyforge_project: carrierwave-ftp
         
     | 
| 
       126 
126 
     | 
    
         
             
            rubygems_version: 1.8.23
         
     |