easy-s3 0.2.0 → 0.3.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.
- data/CHANGELOG.md +5 -2
- data/Gemfile +2 -0
- data/README.md +5 -5
- data/lib/easy-s3/version.rb +1 -1
- data/lib/easy-s3.rb +3 -1
- data/spec/easy-s3_spec.rb +5 -5
- metadata +4 -4
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/Gemfile
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -22,22 +22,22 @@ Or install it yourself as: | |
| 22 22 |  | 
| 23 23 | 
             
            ## Usage
         | 
| 24 24 |  | 
| 25 | 
            -
            Create instance of EasyS3:
         | 
| 25 | 
            +
            Create an instance of EasyS3:
         | 
| 26 26 |  | 
| 27 | 
            -
                s3 = EasyS3.new('my-bucket', access_key_id: 'XXX', secret_access_key: 'XXXX')
         | 
| 27 | 
            +
                s3 = EasyS3.new('my-bucket', access_key_id: 'XXX', secret_access_key: 'XXXX', region: 'eu-west-1')
         | 
| 28 28 |  | 
| 29 | 
            -
            Create private or public file:
         | 
| 29 | 
            +
            Create a private or a public file:
         | 
| 30 30 |  | 
| 31 31 | 
             
                file_url = s3.create_file(path_to_file) # private
         | 
| 32 32 | 
             
                file_url = s3.create_file(path_to_file, public: true) # public
         | 
| 33 33 | 
             
                file_url = s3.create_file(path_to_file, digest: true) # with digest
         | 
| 34 34 |  | 
| 35 | 
            -
            Delete file by url:
         | 
| 35 | 
            +
            Delete a file by url:
         | 
| 36 36 |  | 
| 37 37 | 
             
                file_url = s3.create_file(path_to_file)
         | 
| 38 38 | 
             
                s3.delete_file(file_url)
         | 
| 39 39 |  | 
| 40 | 
            -
            Get all files in bucket:
         | 
| 40 | 
            +
            Get all files in the bucket:
         | 
| 41 41 |  | 
| 42 42 | 
             
                s3.files
         | 
| 43 43 |  | 
    
        data/lib/easy-s3/version.rb
    CHANGED
    
    
    
        data/lib/easy-s3.rb
    CHANGED
    
    | @@ -11,10 +11,12 @@ class EasyS3 | |
| 11 11 | 
             
              def initialize(dir_name, options={})
         | 
| 12 12 | 
             
                options[:access_key_id]     ||= Fog.credentials[:aws_access_key_id]
         | 
| 13 13 | 
             
                options[:secret_access_key] ||= Fog.credentials[:aws_secret_access_key]
         | 
| 14 | 
            +
                options[:region]            ||= Fog.credentials[:region]
         | 
| 14 15 |  | 
| 15 16 | 
             
                Fog.credentials = {
         | 
| 16 17 | 
             
                    aws_access_key_id:      options[:access_key_id],
         | 
| 17 | 
            -
                    aws_secret_access_key:  options[:secret_access_key]
         | 
| 18 | 
            +
                    aws_secret_access_key:  options[:secret_access_key],
         | 
| 19 | 
            +
                    region:                 options[:region]
         | 
| 18 20 | 
             
                }
         | 
| 19 21 |  | 
| 20 22 | 
             
                begin
         | 
    
        data/spec/easy-s3_spec.rb
    CHANGED
    
    | @@ -2,29 +2,29 @@ require 'spec_helper' | |
| 2 2 | 
             
            require 'easy-s3'
         | 
| 3 3 | 
             
            require 'fog'
         | 
| 4 4 |  | 
| 5 | 
            -
             | 
| 6 5 | 
             
            describe EasyS3 do
         | 
| 7 6 | 
             
              let(:bucket_name)             { 'my-bucket' }
         | 
| 8 7 | 
             
              let(:bucket_not_exist_name)   { 'test' }
         | 
| 8 | 
            +
              let(:region)                  { 'eu-west-1' }
         | 
| 9 9 | 
             
              let(:s3)                      { EasyS3.new(bucket_name) }
         | 
| 10 10 | 
             
              let(:file_path)               { File.join('spec', 'support', 'file.txt') }
         | 
| 11 11 | 
             
              let(:file_not_exist_path)     { File.join('spec', 'support', 'file_not_exist.txt') }
         | 
| 12 12 |  | 
| 13 13 | 
             
              before :all do
         | 
| 14 14 | 
             
                Fog.mock!
         | 
| 15 | 
            -
                Fog.credentials = { aws_access_key_id: 'XXX', aws_secret_access_key: 'XXXX' }
         | 
| 15 | 
            +
                Fog.credentials = { aws_access_key_id: 'XXX', aws_secret_access_key: 'XXXX' , region: 'eu-west-1' }
         | 
| 16 16 | 
             
                connection = Fog::Storage.new(provider: 'AWS')
         | 
| 17 17 | 
             
                connection.directories.create(key: 'my-bucket')
         | 
| 18 18 | 
             
              end
         | 
| 19 19 |  | 
| 20 20 | 
             
              context '.initialize' do
         | 
| 21 21 | 
             
                it 'should raise exception if call method without argument directory name' do
         | 
| 22 | 
            -
                  expect{ EasyS3.new }.to raise_error | 
| 22 | 
            +
                  expect{ EasyS3.new }.to raise_error ArgumentError
         | 
| 23 23 | 
             
                end
         | 
| 24 24 |  | 
| 25 25 | 
             
                it 'should accept options hash as the second argument' do
         | 
| 26 26 | 
             
                  Fog.credentials = {}
         | 
| 27 | 
            -
                  EasyS3.new(bucket_name, access_key_id: 'XXX', secret_access_key: 'XXXX').should be_an_instance_of EasyS3
         | 
| 27 | 
            +
                  EasyS3.new(bucket_name, access_key_id: 'XXX', secret_access_key: 'XXXX', region: 'eu-west-1').should be_an_instance_of EasyS3
         | 
| 28 28 | 
             
                end
         | 
| 29 29 |  | 
| 30 30 | 
             
                it 'should raise exception if missing options access_key_id or secret_access_key' do
         | 
| @@ -50,7 +50,7 @@ describe EasyS3 do | |
| 50 50 |  | 
| 51 51 | 
             
                it 'should create file with digest' do
         | 
| 52 52 | 
             
                  url = s3.create_file(file_path, digest: true, public: true)
         | 
| 53 | 
            -
                  url.should == "https://#{bucket_name}.s3.amazonaws.com/#{File.basename(file_path)}_#{Digest::SHA1.hexdigest(File.basename(file_path))}"
         | 
| 53 | 
            +
                  url.should == "https://#{bucket_name}.s3-#{region}.amazonaws.com/#{File.basename(file_path)}_#{Digest::SHA1.hexdigest(File.basename(file_path))}"
         | 
| 54 54 | 
             
                end
         | 
| 55 55 |  | 
| 56 56 | 
             
                it 'should create a public file' do
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: easy-s3
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.3.0
         | 
| 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: 2013- | 
| 12 | 
            +
            date: 2013-11-06 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: fog
         | 
| @@ -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: 3515566908045062486
         | 
| 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: 3515566908045062486
         | 
| 124 124 | 
             
            requirements: []
         | 
| 125 125 | 
             
            rubyforge_project: 
         | 
| 126 126 | 
             
            rubygems_version: 1.8.23
         |