Skip to content

Commit

Permalink
Merge branch 'release/2.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
staturecrane committed Aug 4, 2017
2 parents 3a800f8 + 1ce5347 commit a090a9e
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 101 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*.rbc
*.bundle
.rspec_status
Gemfile.lock

/.config
/coverage/
Expand Down
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Filestack-Ruby Changelog

## 2.0.0
- First release, includes uploads, transformations, conversions and tagging
## 2.1.0 (August 4, 2017)
- FS-1452 Rename Client to FilestackClient, Filelink to FilestackFilelink

## 2.0.1 (July 11, 2017)
- FS-1389 Fix import error when calling './lib' in client class
- FS-1389 Fix import error when calling './lib' in client class

## 2.0.0
- First release, includes uploads, transformations, conversions and tagging
67 changes: 0 additions & 67 deletions Gemfile.lock

This file was deleted.

12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@ Or install it yourself as:

## Usage

## IMPORTANT

A recent change (2.1.0) has renamed the Client to FilestackClient, and the Filelink to FilestackFilelink. Please make neccessary changes before upgrading to newest release if you run 2.0.1 or 2.0.0. This was to address namespace concerns by users with models and attributes named Client, and to be more consistent.

```ruby
require 'filestack'
```
Intialize the client using your API key, and security if you are using it.
```ruby
client = Client.new('YOUR_API_KEY', security: security_object)
client = FilestackClient.new('YOUR_API_KEY', security: security_object)
```
### Uploading
Filestack uses multipart uploading by default, which is faster for larger files. This can be turned off by passing in ```multipart: false```. Multipart is disabled when uploading external URLs.
Expand All @@ -52,11 +56,11 @@ If security is enabled on your account, or if you are using certain actions that

```ruby
security = FilestackSecurity.new('YOUR_APP_SECRET', options: {call: %w[read store pick]})
client = client.new('YOUR_API_KEY', security: security)
client = FilestackClient.new('YOUR_API_KEY', security: security)
```

### Using Filelinks
Filelink objects are representation of a file handle. You can download, get raw file content, delete and overwrite file handles directly. Security is required for overwrite and delete methods.
### Using FilestackFilelinks
FilestackFilelink objects are representation of a file handle. You can download, get raw file content, delete and overwrite file handles directly. Security is required for overwrite and delete methods.

### Transformations
Transforms can be initiated one of two ways. The first, by calling ```transform``` on a filelink:
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.1.0
2 changes: 1 addition & 1 deletion filestack-ruby.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "parallel", "~> 1.11.2"
spec.add_dependency "mimemagic", "~> 0.3.2"

spec.add_development_dependency "bundler", "~> 1.15"
spec.add_development_dependency "bundler", "~> 1.7"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "simplecov", "~> 0.14"
Expand Down
10 changes: 5 additions & 5 deletions lib/filestack/models/filelink.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
# This class represents a file stored on your Filestack
# storage. Once initialized, you may perform transformations, conversions,
# get metadata, update, or delete it.
class Filelink
class FilestackFilelink
include FilestackCommon
include UploadUtils
attr_reader :handle, :apikey, :security

# Initialize Filelink
# Initialize FilestackFilelink
#
# @param [String] file_handle The Filelink handle
# @param [String] file_handle The FilestackFilelink handle
# @param [String] apikey Your Filestack API Key (optional)
# @param [FilestackSecurity] security Filestack security object, if
# security is enabled.
Expand All @@ -31,7 +31,7 @@ def get_content
send_get_content(url)
end

# Download Filelink
# Download FilestackFilelink
#
# @param [String] filepath The local destination of the
# downloaded filelink
Expand Down Expand Up @@ -78,7 +78,7 @@ def sfw
send_tags('sfw', @handle, @security)
end

# Get the URL of the Filelink
# Get the URL of the FilestackFilelink
#
# @return [String]
def url
Expand Down
4 changes: 2 additions & 2 deletions lib/filestack/models/filestack_av.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ def initialize(url, apikey: nil, security: nil)

# Turns AV into filelink if video conversion is complete
#
# @return [Filestack::Filelink]
# @return [Filestack::FilestackFilelink]
def to_filelink
return 'Video conversion incomplete' unless status == 'completed'
response = UploadUtils.make_call(@url, 'get').body
handle = response['data']['url'].split('/').last
Filelink.new(handle, apikey: @apikey, security: @security)
FilestackFilelink.new(handle, apikey: @apikey, security: @security)
end

# Checks the status of the video conversion
Expand Down
10 changes: 5 additions & 5 deletions lib/filestack/models/filestack_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
require 'filestack/models/filestack_transform'
require 'filestack/utils/utils'

# The Filestack Client class acts as a hub for all
# The Filestack FilestackClient class acts as a hub for all
# Filestack actions that do not require a file handle, including
# uploading files (both local and external), initiating an external
# transformation, and other tasks
class Client
class FilestackClient
include MultipartUploadUtils
include UploadUtils
attr_reader :apikey, :security

# Initialize Client
# Initialize FilestackClient
#
# @param [String] apikey Your Filestack API key
# @param [FilestackSecurity] security A Filestack security object,
Expand All @@ -28,7 +28,7 @@ def initialize(apikey, security: nil)
# (Default: true)
# @param [Hash] options User-supplied upload options
#
# return [Filestack::Filelink]
# return [Filestack::FilestackFilelink]
def upload(filepath: nil, external_url: nil, multipart: true, options: nil, storage: 's3')
if filepath && external_url
return 'You cannot upload a URL and file at the same time'
Expand All @@ -45,7 +45,7 @@ def upload(filepath: nil, external_url: nil, multipart: true, options: nil, stor
storage: storage
)
end
Filelink.new(response['handle'], security: @security, apikey: @apikey)
FilestackFilelink.new(response['handle'], security: @security, apikey: @apikey)
end

def transform_external(external_url)
Expand Down
4 changes: 2 additions & 2 deletions lib/filestack/models/filestack_transform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ def debug

# Stores a transformation URL and returns a filelink
#
# @return [Filestack::Filelink]
# @return [Filestack::FilestackFilelink]
def store
@transform_tasks.push(
add_transform_task('store', {})
)
response = UploadUtils.make_call(url, 'get')
handle = response.body['url'].split('/').last
Filelink.new(handle, apikey: @apikey, security: @security)
FilestackFilelink.new(handle, apikey: @apikey, security: @security)
end

# Override default method (best practice when overriding method_missing)
Expand Down
2 changes: 1 addition & 1 deletion lib/filestack/ruby/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Filestack
module Ruby
VERSION = '2.0.1'.freeze
VERSION = '2.1.0'.freeze
end
end
6 changes: 3 additions & 3 deletions lib/filestack/utils/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ def send_upload(apikey, filepath: nil, external_url: nil, security: nil, options
raise response.body
end

# Generates the URL for a Filelink object
# Generates the URL for a FilestackFilelink object
# @param [String] base The base Filestack URL
# @param [String] handle The Filelink handle (optional)
# @param [String] handle The FilestackFilelink handle (optional)
# @param [String] path The specific API path (optional)
# @param [String] security Security for the Filelink (optional)
# @param [String] security Security for the FilestackFilelink (optional)
#
# return [String]
def get_url(base, handle: nil, path: nil, security: nil)
Expand Down
14 changes: 7 additions & 7 deletions spec/filestack/ruby_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ def initialize(body_content)
location_url: @start_response[:location_url]
}
@response = Response.new
@test_client = Client.new(@test_apikey)
@test_filelink = Filelink.new(@test_handle)
@test_client = FilestackClient.new(@test_apikey)
@test_filelink = FilestackFilelink.new(@test_handle)
@test_security = FilestackSecurity.new(@test_secret)
@test_secure_client = Client.new(@test_apikey, security: @test_security)
@test_secure_filelink = Filelink.new(@test_apikey, security: @test_security)
@test_secure_client = FilestackClient.new(@test_apikey, security: @test_security)
@test_secure_filelink = FilestackFilelink.new(@test_apikey, security: @test_security)
@test_transform = Transform.new(apikey: @test_apikey, handle: @test_handle, security: @test_security)
end

Expand Down Expand Up @@ -99,11 +99,11 @@ def initialize(body_content)
expect(signed_url).to include('signature=')
end

it 'Filelink makes correct url' do
it 'FilestackFilelink makes correct url' do
expect(@test_secure_filelink.url)
end

it 'Filelink uploads without multipart' do
it 'FilestackFilelink uploads without multipart' do
class UploadResponse
def code
200
Expand All @@ -119,7 +119,7 @@ def body
expect(filelink.handle).to eq('somehandle')
end

it 'Filelink uploads external without multipart' do
it 'FilestackFilelink uploads external without multipart' do
class UploadResponse
def code
200
Expand Down

0 comments on commit a090a9e

Please sign in to comment.