breadbox 1.3.0 → 1.4.0
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.
- checksums.yaml +4 -4
 - data/README.md +1 -0
 - data/breadbox.gemspec +1 -1
 - data/lib/breadbox/client.rb +1 -2
 - data/lib/breadbox/dropbox_client.rb +3 -1
 - data/lib/breadbox/s3_client.rb +2 -1
 - data/lib/breadbox/version.rb +1 -1
 - data/spec/breadbox/dropbox_client_spec.rb +11 -0
 - data/spec/breadbox/s3_client_spec.rb +27 -0
 - metadata +4 -4
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: b634f857a942ff27b4e9d5910efec955dca6bfe8
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 133007d2560f3e7929587aecc519d9bbd5236b4c
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 3eec8a130d1e0889d29fb5f35e038553124c35fc8b7f96eebb3c8d5e43c299271517e64276efee3a759a3b499647fd1e680cf97ccfcb32daf631ebfff13454fb
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 241255df8c6631f51f028e549ff6b45bb9de2a5919412539d27f247dcad081bf587ad05435c0d1f8c5fcf150fe6a4321a35d0dab4b4f9d931d8164a70e16aeb3
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -82,6 +82,7 @@ end 
     | 
|
| 
       82 
82 
     | 
    
         
             
            - `path`: defaults to `nil`, but this is where you put a custom folder if you so wish (in relation
         
     | 
| 
       83 
83 
     | 
    
         
             
              to your `root_path`, which if you didn't configure in your initializer, will be your root Dropbox
         
     | 
| 
       84 
84 
     | 
    
         
             
              folder `/`.
         
     | 
| 
      
 85 
     | 
    
         
            +
            - `filename`: defaults to the name of the file you are uploading, but you can specify a custom name here.
         
     | 
| 
       85 
86 
     | 
    
         
             
            - `file`: The file object that you are uploading, ex: `file = File.open('./path-to-local-file').
         
     | 
| 
       86 
87 
     | 
    
         
             
            - `cleanup`: defaults to `false`, but if you pass `true` - it will remove the local file after uploading.
         
     | 
| 
       87 
88 
     | 
    
         
             
            - `public`: defaults to `false`. Pass `true` if you'd like to set the file permission level to world readable.
         
     | 
    
        data/breadbox.gemspec
    CHANGED
    
    | 
         @@ -18,7 +18,7 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       18 
18 
     | 
    
         
             
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         
     | 
| 
       19 
19 
     | 
    
         
             
              spec.require_paths = ["lib"]
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
              spec.add_dependency "dropbox-sdk", "~> 1.6"
         
     | 
| 
      
 21 
     | 
    
         
            +
              spec.add_dependency "dropbox-sdk", "~> 1.6.4"
         
     | 
| 
       22 
22 
     | 
    
         
             
              spec.add_dependency "aws-sdk", "~> 2.1.7"
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
24 
     | 
    
         
             
              spec.add_development_dependency "bundler", "~> 1.6"
         
     | 
    
        data/lib/breadbox/client.rb
    CHANGED
    
    | 
         @@ -23,8 +23,7 @@ module Breadbox 
     | 
|
| 
       23 
23 
     | 
    
         | 
| 
       24 
24 
     | 
    
         
             
                protected
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
                def  
     | 
| 
       27 
     | 
    
         
            -
                  filename = File.basename(file)
         
     | 
| 
      
 26 
     | 
    
         
            +
                def filepath_from_paths_and_filename(root_path, path, filename)
         
     | 
| 
       28 
27 
     | 
    
         
             
                  [root_path, path, filename].join("/").gsub(/\/{2,}/, "/")
         
     | 
| 
       29 
28 
     | 
    
         
             
                end
         
     | 
| 
       30 
29 
     | 
    
         | 
| 
         @@ -10,9 +10,11 @@ module Breadbox 
     | 
|
| 
       10 
10 
     | 
    
         
             
                def upload(options = {})
         
     | 
| 
       11 
11 
     | 
    
         
             
                  path      = options[:path]
         
     | 
| 
       12 
12 
     | 
    
         
             
                  file      = options[:file]
         
     | 
| 
      
 13 
     | 
    
         
            +
                  filename  = options[:filename]  || File.basename(file)
         
     | 
| 
       13 
14 
     | 
    
         
             
                  overwrite = options[:overwrite] || false
         
     | 
| 
       14 
15 
     | 
    
         
             
                  share     = options[:share]
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                  filepath  = filepath_from_paths_and_filename(root_path, path, filename)
         
     | 
| 
       16 
18 
     | 
    
         
             
                  result    = client.put_file(filepath, file, overwrite)
         
     | 
| 
       17 
19 
     | 
    
         | 
| 
       18 
20 
     | 
    
         
             
                  if share && result
         
     | 
    
        data/lib/breadbox/s3_client.rb
    CHANGED
    
    | 
         @@ -14,9 +14,10 @@ module Breadbox 
     | 
|
| 
       14 
14 
     | 
    
         
             
                def upload(options = {})
         
     | 
| 
       15 
15 
     | 
    
         
             
                  path          = options[:path]
         
     | 
| 
       16 
16 
     | 
    
         
             
                  file          = options[:file]
         
     | 
| 
      
 17 
     | 
    
         
            +
                  filename      = options[:filename] || File.basename(file)
         
     | 
| 
       17 
18 
     | 
    
         
             
                  acl           = options[:public] ? :public_read : :private
         
     | 
| 
       18 
19 
     | 
    
         
             
                  content_type  = options[:content_type]
         
     | 
| 
       19 
     | 
    
         
            -
                  filepath      =  
     | 
| 
      
 20 
     | 
    
         
            +
                  filepath      = filepath_from_paths_and_filename(root_path, path, filename)[1..-1]
         
     | 
| 
       20 
21 
     | 
    
         
             
                  s3_object     = s3_bucket_object.object(filepath)
         
     | 
| 
       21 
22 
     | 
    
         | 
| 
       22 
23 
     | 
    
         
             
                  result = s3_object.put(body: file, acl: acl, content_type: content_type)
         
     | 
    
        data/lib/breadbox/version.rb
    CHANGED
    
    
| 
         @@ -63,6 +63,17 @@ module Breadbox 
     | 
|
| 
       63 
63 
     | 
    
         | 
| 
       64 
64 
     | 
    
         
             
                    client.upload(path: "/", file: file)
         
     | 
| 
       65 
65 
     | 
    
         
             
                  end
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
                  it "allows for a filename to be passed as an option" do
         
     | 
| 
      
 68 
     | 
    
         
            +
                    file           = File.open("./tmp/new-file.jpg")
         
     | 
| 
      
 69 
     | 
    
         
            +
                    client         = DropboxClient.new(configuration)
         
     | 
| 
      
 70 
     | 
    
         
            +
                    dropbox_client = instance_double(::DropboxClient)
         
     | 
| 
      
 71 
     | 
    
         
            +
                    allow(client).to receive(:client).and_return(dropbox_client)
         
     | 
| 
      
 72 
     | 
    
         
            +
                    expect(dropbox_client).to receive(:put_file)
         
     | 
| 
      
 73 
     | 
    
         
            +
                                              .with("/my-cool-file.jpg", file, false)
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                    client.upload(path: "/", file: file, filename: "my-cool-file.jpg")
         
     | 
| 
      
 76 
     | 
    
         
            +
                  end
         
     | 
| 
       66 
77 
     | 
    
         
             
                end
         
     | 
| 
       67 
78 
     | 
    
         
             
              end
         
     | 
| 
       68 
79 
     | 
    
         
             
            end
         
     | 
| 
         @@ -112,6 +112,33 @@ module Breadbox 
     | 
|
| 
       112 
112 
     | 
    
         | 
| 
       113 
113 
     | 
    
         
             
                    client.upload(path: "/", file: file, public: nil, content_type: "image/jpeg")
         
     | 
| 
       114 
114 
     | 
    
         
             
                  end
         
     | 
| 
      
 115 
     | 
    
         
            +
             
     | 
| 
      
 116 
     | 
    
         
            +
                  it "passes path parameter" do
         
     | 
| 
      
 117 
     | 
    
         
            +
                    file    = File.open("./tmp/new-file.jpg")
         
     | 
| 
      
 118 
     | 
    
         
            +
                    bucket_object = client.s3_bucket_object.object("new-file.jpg")
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
                    expect_any_instance_of(Aws::S3::Bucket).to receive(:object)
         
     | 
| 
      
 121 
     | 
    
         
            +
                      .with("my-path/new-file.jpg").and_return(bucket_object)
         
     | 
| 
      
 122 
     | 
    
         
            +
                    expect(bucket_object).to receive(:put)
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
      
 124 
     | 
    
         
            +
                    client.upload(path: "my-path", file: file, content_type: "image/jpeg")
         
     | 
| 
      
 125 
     | 
    
         
            +
                  end
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
                  it "passes filename parameter" do
         
     | 
| 
      
 128 
     | 
    
         
            +
                    file    = File.open("./tmp/new-file.jpg")
         
     | 
| 
      
 129 
     | 
    
         
            +
                    bucket_object = client.s3_bucket_object.object("my-cool-filename.jpg")
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
                    expect_any_instance_of(Aws::S3::Bucket).to receive(:object)
         
     | 
| 
      
 132 
     | 
    
         
            +
                      .with("my-cool-filename.jpg").and_return(bucket_object)
         
     | 
| 
      
 133 
     | 
    
         
            +
                    expect(bucket_object).to receive(:put)
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
      
 135 
     | 
    
         
            +
                    client.upload(
         
     | 
| 
      
 136 
     | 
    
         
            +
                      path: "/",
         
     | 
| 
      
 137 
     | 
    
         
            +
                      file: file,
         
     | 
| 
      
 138 
     | 
    
         
            +
                      filename: "my-cool-filename.jpg",
         
     | 
| 
      
 139 
     | 
    
         
            +
                      content_type: "image/jpeg"
         
     | 
| 
      
 140 
     | 
    
         
            +
                    )
         
     | 
| 
      
 141 
     | 
    
         
            +
                  end
         
     | 
| 
       115 
142 
     | 
    
         
             
                end
         
     | 
| 
       116 
143 
     | 
    
         
             
              end
         
     | 
| 
       117 
144 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: breadbox
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.4.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Nathaniel Watts
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2015-07- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-07-20 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: dropbox-sdk
         
     | 
| 
         @@ -16,14 +16,14 @@ dependencies: 
     | 
|
| 
       16 
16 
     | 
    
         
             
                requirements:
         
     | 
| 
       17 
17 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       18 
18 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       19 
     | 
    
         
            -
                    version:  
     | 
| 
      
 19 
     | 
    
         
            +
                    version: 1.6.4
         
     | 
| 
       20 
20 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       21 
21 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       22 
22 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       23 
23 
     | 
    
         
             
                requirements:
         
     | 
| 
       24 
24 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       25 
25 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
     | 
    
         
            -
                    version:  
     | 
| 
      
 26 
     | 
    
         
            +
                    version: 1.6.4
         
     | 
| 
       27 
27 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       28 
28 
     | 
    
         
             
              name: aws-sdk
         
     | 
| 
       29 
29 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     |